From patchwork Fri Aug 16 11:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Karwatzki X-Patchwork-Id: 13766002 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 BF29CC3DA4A for ; Fri, 16 Aug 2024 11:14:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D3926B0168; Fri, 16 Aug 2024 07:14:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73ADA6B0163; Fri, 16 Aug 2024 07:14:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EEEE8D0070; Fri, 16 Aug 2024 07:14:37 -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 28E486B015E for ; Fri, 16 Aug 2024 07:14:37 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DCD5B81AE7 for ; Fri, 16 Aug 2024 11:14:36 +0000 (UTC) X-FDA: 82457850552.10.9860558 Received: from mout.web.de (mout.web.de [212.227.17.11]) by imf19.hostedemail.com (Postfix) with ESMTP id D73E41A0002 for ; Fri, 16 Aug 2024 11:14:34 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=W7Tn0jRd; dmarc=pass (policy=quarantine) header.from=web.de; spf=pass (imf19.hostedemail.com: domain of spasswolf@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=spasswolf@web.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723806792; 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=ZrQQQZT7ARQFRs0tgv1kX7XArulslu7aLmdVZtTsOAs=; b=CQ1rhis2d9vZJfNi1/Iq0VBeGQSa67ziqjlCH5RZcfEJOEFm+SQqlmSm7YgmfxIEIvbJCW WZ9u3dgLFtzklDKUY3T7t3+sS/ecE7i24jIN9RV226v5GUoASIO3zrCHID3Mpfpx0PKooe Jq5XFZp2Fnh8j2xDLELs5IJOl8rBXaI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723806792; a=rsa-sha256; cv=none; b=RxVZ3odKknuy3KsbGKj7SlXLLgOfGyJ0bPuE8yi3N4Cmz4VTw3NI4WldAjIzKjmETWsB9d ApuRwCprzlv59oxA+0yXPCwkpy1xN5B+2b/mQnJc1Tl2okOr4fKfeyLIIPabQzDTR2+NTE fEUk1l4+r6anYkxKQSPb0rKBx8dgmeY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=W7Tn0jRd; dmarc=pass (policy=quarantine) header.from=web.de; spf=pass (imf19.hostedemail.com: domain of spasswolf@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=spasswolf@web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1723806867; x=1724411667; i=spasswolf@web.de; bh=ZrQQQZT7ARQFRs0tgv1kX7XArulslu7aLmdVZtTsOAs=; 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=W7Tn0jRd5zBYzYAbHIabP66dwywTX/boxQILpw6V8lqFe3+nJkS2Wi2xzo34Azh6 R78dHG+LAbrdfPDE9KQBWTVmpBWKV7VtbTJBsMNqbb8lbtRI1eVv9nSkhzL3aOpiN Pnj/gfq9OJkl26gulZN16B5V2S6USoSW6zmGKAJw9TXfTVGXAAXqowFi+YcNHs8a6 XISXMn6AbT/OoKEtz+f2ShBnNs1IK52zh1BTDaF2Y9Lkn9M++0GpioYDv7xmrliDC m4W7H/lTAPB8vjcGN0I14bsuNArJ81ZZZcPhaMIrWW5yNQI5ADh4jU0yGoktQvhuJ Qcs7cjh9kHclEw9Gxg== 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 1MnpKq-1rprmT2gsE-00apSa; Fri, 16 Aug 2024 13:14:27 +0200 From: Bert Karwatzki To: "Liam R . Howlett" Cc: Bert Karwatzki , Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Jiri Olsa , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Kees Cook , Jeff Xu , Lorenzo Stoakes Subject: [PATCH v5.1 07/19] mm/mmap: Extract validate_mm() from vma_complete() Date: Fri, 16 Aug 2024 13:13:48 +0200 Message-ID: <20240816111405.11793-8-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 X-Provags-ID: V03:K1:PeHNp6vd5g1Yuna7MwxF2eluiE5lGDtciQJQOfuIb655M/kSqfx rpu/JA/CNPZ80YnrYGfyMRECVf0kWQAzgsq1VZMIfL7snPdj6pSTkY/z9xT9wO/mQwSfpU3 oPEVAcFZyj4JnbU+/81JPz/dpnHrr72PWZcmKYYxhk4lBORwLEP9oLHS6k3c+3OukPKCoa8 TZO6Z9/DCccnVx7rEmaKA== UI-OutboundReport: notjunk:1;M01:P0:NAqq5pnOTuo=;FJgYYPfe70gjTOnVZLDmq2sgskM eFjDI3YQ30p3NBtcBus+7MAQ110HGDd7L6JI//poo0vtKQl2j83FqbW7GBFXuxvOTQFV8YJ8Y eenAkNojKhVm1B24OYAvHYryZqP3mQ7XxCpJPaWP0E/pSRhSRng3RuYeWLYKO3WkY1+hvRCZd pPKkDhSf7UMrR79hDL0G9bOC0Aj/YTIwIC7j6Evhh1VnsOMQ2bJhDkgSBYJ7Tq29ViozX/tNT x1VWHrd0XD1mbm11Hb4cby6sCcAT7FuVOhq28+Lkk63FBz8vOev0YI47lz6xLHLhE7AttRYkw ODmEdJWyO2PiXAdTn9ue7PWpJ06SqECKj7xiaQAVyIDiJ6+xRwXn6kRW9KxhLjRlWjc4Fwkeh B/J51S+tpaqW5+bfDSFoJUBbMoWJb1FdFSp6A1opGntqHbKystc3vWxdYPaRwGgIkV37GuiYm rNMF32g6/XPM56IrcC3a7ECgsudgME9gVd9LInmnn4Q1HRJmax/wLkXObPocXqHRGRr5ObJ0A MI+srh7vlbTPsy/Weq8q8Xt9lYWHBRkc/4TP5EajiuZNsNULMdwQl4uW/RwFZ//Gfn4Xxzp7K yYuKsB0F8ra27xyFMPBBTDR18jgLkmyMX+Y9jbO7R47C12O62vsHOCgihwiIQZMELnGCgYKRi QH/zBsi1SguQb4661LrWttUmv3N9CJto0bmsBb0gxz0nMEeJ/UpBfD6t1Oi9aEq+FUFitXPwX pQMc6WfYmF7w2NB+q/4NRJbGubU6zpQl26uZjCQAz+35vHANrBy7E0eYf7lsrQsu8+cunAEBV BZmlCQ9ofOm4jQpu2sfsPSeA== X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D73E41A0002 X-Stat-Signature: kax58xngqsp6f4k3aopu7kgpjnfbxpsa X-Rspam-User: X-HE-Tag: 1723806874-825334 X-HE-Meta: U2FsdGVkX1+rNDiIA2kyVKRcVnriYm81GCzldpIXg6ESszv1pd+86IxPaA9s9SyZJijlxUsSUvkarjY0jrvH9us/shC+wOUdP1zPW5eKTVN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MDC8fvY5VT+en7gIj8ENQT9SqMYYdF70iYtAS8RgqAWm+g0oEpkhBVWJfEA1L9ZTOZFRxMBWkLLCOOLcs7KghYnKDZbJB+hdIREKr4aXxzSF4bCZXjtNnbf 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: List-Subscribe: List-Unsubscribe: vma_complete() will need to be called during an unsafe time to call validate_mm(). Extract the call in all places now so that only one location can be modified in the next change. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 1 + mm/vma.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.45.2 diff --git a/mm/mmap.c b/mm/mmap.c index 1da0e8325b33..6aed0b769cc4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1805,6 +1805,7 @@ static int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(vma, flags); goto out; } diff --git a/mm/vma.c b/mm/vma.c index 816736c4f82e..e4677364082b 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -242,6 +242,7 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, /* vma_complete stores the new vma */ vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); /* Success. */ if (new_below) @@ -548,6 +549,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); return 0; nomem: @@ -589,6 +591,7 @@ int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_clear(vmi); vma_set_range(vma, start, end, pgoff); vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); return 0; } @@ -668,7 +671,6 @@ void vma_complete(struct vma_prepare *vp, } if (vp->insert && vp->file) uprobe_mmap(vp->insert); - validate_mm(mm); } /* @@ -1196,6 +1198,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res;