From patchwork Thu Sep 2 21:56:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12473083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55185C433EF for ; Thu, 2 Sep 2021 21:56:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E09A60E8B for ; Thu, 2 Sep 2021 21:56:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E09A60E8B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BAB0C6B0125; Thu, 2 Sep 2021 17:56:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B34506B0126; Thu, 2 Sep 2021 17:56:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A49ED6B0127; Thu, 2 Sep 2021 17:56:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 96BC06B0125 for ; Thu, 2 Sep 2021 17:56:51 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6695782F4BEF for ; Thu, 2 Sep 2021 21:56:51 +0000 (UTC) X-FDA: 78543993822.17.21ECA2C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP id 279B810000A3 for ; Thu, 2 Sep 2021 21:56:51 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 305996056B; Thu, 2 Sep 2021 21:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1630619810; bh=0WEpHpJtrMp2mQPHxZHpffhGxtMqBhTfmXF1/L0ayN0=; h=Date:From:To:Subject:In-Reply-To:From; b=ZhI898lZv2FkPCdoI6kG1ZdYbbFbqglRjHb7GYd8kK9qNE3mVTm7DCAgEV/+fO0aU TEmFv43vmudR0o43z61v6vG2kWUED9xJ6xZ+BYEGov2QRtN0fTh+TLFLCbmisp4Eqy CrqdO6UwubcpnfJnj5WK6X8I/vhr47jlVnYDTi3E= Date: Thu, 02 Sep 2021 14:56:49 -0700 From: Andrew Morton To: akpm@linux-foundation.org, david@redhat.com, Liam.Howlett@Oracle.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 128/212] remap_file_pages: Use vma_lookup() instead of find_vma() Message-ID: <20210902215649.Oak625hS4%akpm@linux-foundation.org> In-Reply-To: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ZhI898lZ; spf=pass (imf12.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 279B810000A3 X-Stat-Signature: 78k8xxbpk9ko6bn9i4e3dxtc1qqxg1ij X-HE-Tag: 1630619811-987349 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: "Liam R. Howlett" Subject: remap_file_pages: Use vma_lookup() instead of find_vma() Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read code. Link: https://lkml.kernel.org/r/20210817135234.1550204-1-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett Reviewed-by: David Hildenbrand Signed-off-by: Andrew Morton --- mm/mmap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/mm/mmap.c~remap_file_pages-use-vma_lookup-instead-of-find_vma +++ a/mm/mmap.c @@ -2994,14 +2994,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsign if (mmap_write_lock_killable(mm)) return -EINTR; - vma = find_vma(mm, start); + vma = vma_lookup(mm, start); if (!vma || !(vma->vm_flags & VM_SHARED)) goto out; - if (start < vma->vm_start) - goto out; - if (start + size > vma->vm_end) { struct vm_area_struct *next;