From patchwork Tue Mar 22 21:42:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12789122 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 41FF0C433FE for ; Tue, 22 Mar 2022 21:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2A526B00C8; Tue, 22 Mar 2022 17:42:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB3336B00C9; Tue, 22 Mar 2022 17:42:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2DAC6B00CA; Tue, 22 Mar 2022 17:42:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 9DAB66B00C8 for ; Tue, 22 Mar 2022 17:42:44 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6477221C29 for ; Tue, 22 Mar 2022 21:42:44 +0000 (UTC) X-FDA: 79273347048.07.28D01C1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id E4AA8160013 for ; Tue, 22 Mar 2022 21:42:43 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3A00F60A1B; Tue, 22 Mar 2022 21:42:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 906AFC340EC; Tue, 22 Mar 2022 21:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985362; bh=nLd/e0wfjnqccZgkuzXkEmRaOX/nNoEF/3WrCYYj7oI=; h=Date:To:From:In-Reply-To:Subject:From; b=FM55E8451rTYyUODUG37K9nGKHXIJtTlFGD9wxEk97PtcQjbBC3Rv+eqM4wmHdCta SXwjGvRq3G8btTfxIvmRxN9p554BOLMmbQ71J6ygxjqVG/ox3+jawbzYOylnhEU0wk 82kVrKdW9aTprGaVHwpuE5sPYJV1YhSSYUDWsqZA= Date: Tue, 22 Mar 2022 14:42:41 -0700 To: david@redhat.com,linmiaohe@huawei.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 082/227] mm/mremap:: use vma_lookup() instead of find_vma() Message-Id: <20220322214242.906AFC340EC@smtp.kernel.org> X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=FM55E845; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E4AA8160013 X-Stat-Signature: ekyitgoegy39bexuzrogricfbu3twr6x X-HE-Tag: 1647985363-536263 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: Miaohe Lin Subject: mm/mremap:: use vma_lookup() instead of find_vma() Using vma_lookup() verifies the address is contained in the found vma. This results in easier to read code. Link: https://lkml.kernel.org/r/20220312083118.48284-1-linmiaohe@huawei.com Signed-off-by: Miaohe Lin Reviewed-by: Andrew Morton Reviewed-by: David Hildenbrand Signed-off-by: Andrew Morton --- mm/mremap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/mremap.c~mm-mremap-use-vma_lookup-instead-of-find_vma +++ a/mm/mremap.c @@ -942,8 +942,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, a if (mmap_write_lock_killable(current->mm)) return -EINTR; - vma = find_vma(mm, addr); - if (!vma || vma->vm_start > addr) { + vma = vma_lookup(mm, addr); + if (!vma) { ret = EFAULT; goto out; }