Message ID | 20240816111405.11793-9-spasswolf@web.de (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 1AB2BC531DC for <linux-mm@archiver.kernel.org>; Fri, 16 Aug 2024 11:14:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE0E66B0163; Fri, 16 Aug 2024 07:14:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA3826B0167; Fri, 16 Aug 2024 07:14:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 894806B0169; Fri, 16 Aug 2024 07:14:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5F9EE6B0163 for <linux-mm@kvack.org>; Fri, 16 Aug 2024 07:14:38 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1DA6F161ADC for <linux-mm@kvack.org>; Fri, 16 Aug 2024 11:14:38 +0000 (UTC) X-FDA: 82457850636.24.741D1BB Received: from mout.web.de (mout.web.de [212.227.17.11]) by imf14.hostedemail.com (Postfix) with ESMTP id 1DCA3100013 for <linux-mm@kvack.org>; Fri, 16 Aug 2024 11:14:35 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=QP7zv1ZA; spf=pass (imf14.hostedemail.com: domain of spasswolf@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=spasswolf@web.de; dmarc=pass (policy=quarantine) header.from=web.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723806803; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N4bRnjjY8T58BB1QJ9rqpGkDs7lyqxXGca+v1fWnuPk=; b=e1dwOvZbBBBouVPv0ujw5sbY/ASyEID3hCPlBZvq8ylV1Dn8SK3yCR/yN9i/6IzYwxoOGu 1wgqsIp7I5gEAq5f4LvF9FpB7LrBJ8tw9vpFsHXTTA7iT3zmOkvyr+ge9FNmkRgNC1XiBO h3vowyzvSAzywfUZ91Say5ku/2IkFlM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723806803; a=rsa-sha256; cv=none; b=XRgh9IV10iZ35JrkrnUuMA49i10HSN6hA0N+INnyT+FfeE8kLOvuqgxu0AaU8fgjzdU6+Y ZYLkdIrAhlr/By7hT6xxxLnkBg2BrqQMulHol9+Bdjtc2LqMD94JhmVL+r1/NY+yucokvc v471XE832G+JNO5dxRENduCUPE060kg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=QP7zv1ZA; spf=pass (imf14.hostedemail.com: domain of spasswolf@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=spasswolf@web.de; dmarc=pass (policy=quarantine) header.from=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1723806868; x=1724411668; i=spasswolf@web.de; bh=N4bRnjjY8T58BB1QJ9rqpGkDs7lyqxXGca+v1fWnuPk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=QP7zv1ZAEuhAIjBwUYNku0TL5L13CaL0eizszYyTdLpa7TJjMDv9oQR5icA0cCvr FTyKxgOf+sU0gXe2sS3xIsMHFdXfLVc0V7bf5pHIcFdPU7MW5BsMbp+MjCIHZiHUm BiYKJGohUJPRgukF430bogFOYxojXR4WQQjdkayk3F7Rkx2FZp+wYjauZoID5BwJ5 pWL0poZl59A/3CeraUguyFtviI4Zy7J8yGtgCbi4Yjoez/n/YpMhxdUxkMPGBsPV+ KPVUXlqCYaP51P9MxXi7mV0Zq1j5QxcX1lHvpT0aUjGutRUZy6P75exwsMR62ofVX tXOZVoj/AoA0PN/5tQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from localhost.localdomain ([84.119.92.193]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N4NDQ-1sD2R82wGk-00xraG; Fri, 16 Aug 2024 13:14:28 +0200 From: Bert Karwatzki <spasswolf@web.de> To: "Liam R . Howlett" <Liam.Howlett@oracle.com> Cc: Bert Karwatzki <spasswolf@web.de>, Suren Baghdasaryan <surenb@google.com>, Vlastimil Babka <vbabka@suse.cz>, Lorenzo Stoakes <lstoakes@gmail.com>, Matthew Wilcox <willy@infradead.org>, sidhartha.kumar@oracle.com, "Paul E . McKenney" <paulmck@kernel.org>, Jiri Olsa <olsajiri@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>, Kees Cook <kees@kernel.org>, Jeff Xu <jeffxu@chromium.org>, "Liam R . Howlett" <Liam.Howlett@Oracle.com>, Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Subject: [PATCH v5.1 08/19] mm/mmap: Inline munmap operation in mmap_region() Date: Fri, 16 Aug 2024 13:13:49 +0200 Message-ID: <20240816111405.11793-9-spasswolf@web.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240816111405.11793-1-spasswolf@web.de> References: <20240816111405.11793-1-spasswolf@web.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:TPOfyyR3SiBeEM2qoJMPq/2uyQCzoa7BZ7yudO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bpYz2HtVbZlXYDMTAUO BfORgFaN WRi6mFnvM7KDSbIEjprZ1WqEZZMhuj5sJSLR2icozqZMjqgMGNojR8DPTVr8IFA+BXtv81NPuxGhJErOfPaMfolLWAR+7G17EgzmnUTAPCczme1ZjjICK6i18KCFWqijwp0PS4BHYbluRZBMbGY45XgstF+7c53N2+9Iri096fV3WGAdnta6bSbmZ/g0Hmd4Ehj/Xc3b7F+N0B4rMkfltdHHSQQWMHGePTBMUufpaVJKwCTJvf0+ohLTLhyR13YXG4NaEGpvPvv8ICoJfhFT8iguQZOfDH742QjtkwXIr9sRfSiKXb6PLBEycWHeMRCwIz0nO 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Rebase v5 patchset to next-20240816
|
expand
|
diff --git a/mm/mmap.c b/mm/mmap.c index 6aed0b769cc4..6ed27cf12217 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1388,12 +1388,21 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return -ENOMEM; } - /* Unmap any existing mapping in the area */ - error = do_vmi_munmap(&vmi, mm, addr, len, uf, false); - if (error == -EPERM) - return error; - else if (error) - return -ENOMEM; + + if (unlikely(!can_modify_mm(mm, addr, end))) + return -EPERM; + + /* arch_unmap() might do unmaps itself. */ + arch_unmap(mm, addr, end); + + /* Find the first overlapping VMA */ + vma = vma_find(&vmi, end); + if (vma) { + /* Unmap any existing mapping in the area */ + if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false)) + return -ENOMEM; + vma = NULL; + } /* * Private writable mapping: check memory availability