From patchwork Mon Apr 17 00:39:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13213106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5878CC77B61 for ; Mon, 17 Apr 2023 00:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AB198E0002; Sun, 16 Apr 2023 20:39:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65BA38E0001; Sun, 16 Apr 2023 20:39:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 549EF8E0002; Sun, 16 Apr 2023 20:39:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 455848E0001 for ; Sun, 16 Apr 2023 20:39:34 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 15256A032A for ; Mon, 17 Apr 2023 00:39:34 +0000 (UTC) X-FDA: 80689024668.23.B890714 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 3CB6A140007 for ; Mon, 17 Apr 2023 00:39:29 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681691972; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=vtgkDSGGXh5D5EWBb1g4lLqBgy8KgoEu83yaKxnCXGM=; b=PGRUZaFYA0d874FBw4IPT0OG0IQUmtKCbOSQGZSzXkHHfUFEjZisJpYLQGVsyHDAzT3Rcy A4IMOnv6ijqPVRC7kqYIg8vk/bYcgNNs7gCrDHPMl7QAFijUzfWht8MOxrEpS4nkdwnlKb 9OwafYLDPROSz33xty1b1h0ei4DEL2U= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681691972; a=rsa-sha256; cv=none; b=6eSflR5Ik4USZTMPyUxIcKbMORfX5aAS0ZoR6smbJM0oWg/7/lrauwiKNxyf6oNu4Dz33+ hYv8IarKe74fQkGbaoYivf07XW4U4do5sSkOYpOBJoJqKEJFR4SS3kWjyKE+DfUx+iienu ZTQeacFuw9mP6f45NNudoLute/cV9vk= Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q07PQ4p75zSs0x; Mon, 17 Apr 2023 08:35:22 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 17 Apr 2023 08:39:25 +0800 From: Peng Zhang To: , , CC: , , , ZhangPeng Subject: [PATCH] userfaultfd: use helper function range_in_vma() Date: Mon, 17 Apr 2023 08:39:19 +0800 Message-ID: <20230417003919.930515-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Stat-Signature: pmyo9crb8dnu6tbs84k1hx7rdxy54z6z X-Rspam-User: X-Rspamd-Queue-Id: 3CB6A140007 X-Rspamd-Server: rspam06 X-HE-Tag: 1681691969-939763 X-HE-Meta: U2FsdGVkX19tcxjTCmFhgu67/8TSN09X5JtmUyCifu/OJbIrSyzw6ZcjSDTkqT0oahyZEDE3Rl1GkjdTlcjW+pymv4Jig8KDVi6aBOvDJRl9Bi+apiNgWNDCxLyASu4S2RfXM6AC0umiv5eLeKjZb9RxKgfjzRFOev1E1VFOErH+j672kb8fKp0VvUin5KqhUgDLalKhKCxTGww9A8ZTC1kg+4A2JbUsv9cqV+RZYs0Big0zXVm/J7zXnH39m3oXD7kItHRRZoOnDxuwGd/F1Tgwa+kBCNY7D9y0gz99iwE030e4Je+XCf2R72mVuKa18F/kaTgawlYCGBgOOl/MLrfhktrajNaf4XR6LQ5xqJOS7yLPD0T4DBzYeOJfrZD/C0bmZmNkI605H/Xgte+lMGJ7MDOxwqgo+RWftkCHs8Lq5RHjAz8o1YmWVdMmETMbzw2efwnRu5QF5STm4Q+v5UO2NUkWhY/ull0F49N03VYEqcr36hLXkacb1esM8+cufRO6A/IiND4J7f1b4w5HelZoJkhp6Dp3XvewjySe7ieGREN9Pbdwro/gWVLDuOHHu4LSw6rT5OtHVTVQC0vESbMlkQwkZUVJDJvWC7+38gkLdJdLXjChrCWO3UAfZhEEnZh15kvzGkPCoobFCqUobZAdHGuJJkUdYuhen+RmTOqT5GKqtmqRtdR7l1wSLQmHKpJ3TfGZsdfHoq3DB8CkzJ95LxoyM6slcH/woHt8Q5o/xwdR+hmId0emUbYu4xNxT9BxUxBaqB2E8NUyo8Ufyibm3/N0tkhCtiqAyg/eArPZqldbs4C9N++minwtsEUfm1vwyvLPLl/I2d9kjs496vprTNtGaFkhvhjt0q9xtJlb1/iPxjHB4CJ6IfRLLSN1m9vuvIbQ6uyq5hIPuTuJYXxk3b/t/+T0YurPakEAltqx8vETso81CuXjikU3Oy45cSnc3DQ26w2/Qw2Lvtq 6dqAqvjS 4wZ1jLXjl11lIqY0UD7FItyTbHXvi6sLIFFl8tZpmuJfAw482696buQOVdYEj3Grul6z+sJjdJJD27hY2+91Vp7+DpxhYOFQNwFseWbrbGzSoxPG2mlVWI3fbeEtPT9wlj7q4gcolLth6OOKaIe3pg3/+wcggMpP+NK+u5WhcST1WhTTSc2anA7DkB8s+wECKyjSa3xrCMgw+QdcfxQtjormWzA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: ZhangPeng We could use range_in_vma() to check if dst_start, dst_start + len are within the dst_vma range. Minor readability improvement. Signed-off-by: ZhangPeng Reviewed-by: David Hildenbrand --- mm/userfaultfd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 11cfd82c6726..e97a0b4889fc 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -31,11 +31,7 @@ struct vm_area_struct *find_dst_vma(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma; dst_vma = find_vma(dst_mm, dst_start); - if (!dst_vma) - return NULL; - - if (dst_start < dst_vma->vm_start || - dst_start + len > dst_vma->vm_end) + if (!range_in_vma(dst_vma, dst_start, dst_start + len)) return NULL; /*