From patchwork Wed Sep 4 16:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13791210 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 0CAC6CD4853 for ; Wed, 4 Sep 2024 17:04:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8033C6B017A; Wed, 4 Sep 2024 13:04:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B0D26B017E; Wed, 4 Sep 2024 13:04:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DD3E6B017A; Wed, 4 Sep 2024 13:04:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3E4BF6B0166 for ; Wed, 4 Sep 2024 13:04:12 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D77B3405E1 for ; Wed, 4 Sep 2024 17:04:11 +0000 (UTC) X-FDA: 82527678702.11.A6A3D23 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf15.hostedemail.com (Postfix) with ESMTP id B8D41A0019 for ; Wed, 4 Sep 2024 17:04:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F1QsO8bB; spf=pass (imf15.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725469373; 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:in-reply-to:references:references:dkim-signature; bh=Bz3C7ip+vOqdYUBtFwXjoZBVCb+Y80r5zgvbfNPVBHc=; b=ZcvERbj/XMnZ9qQTxPhKg6fWscLN0nQL2QDrex+PJJyWRTAbvQq0LZCn2LPp2ENCL77Xr9 s3j16fdREhxHJ9e4H77+UPWmw1q2ne3S4NnQRkJAOWtMPHtp7Ju8vxpgR+mJny4o+hJzkp rYNdtxXpmrqU2I412Iu0k8wbfyKBIuc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F1QsO8bB; spf=pass (imf15.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725469373; a=rsa-sha256; cv=none; b=Pbh+9NBQJul1Oc1K8d04BC/ENoeHgkcS5ySr7VuWZhg6lgHA4myJ3YZ4/BeSOiXymcqHT3 zNk4JLu26YiwHW/ZaxDIUdU2zFcHPPlNgI6BXHoe+bf/3gra4k9oiBLU4092kEaX/2bl8C 2c75EGZpuaC1lVYTIhLsRSQcuj7cQ9w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C7D67A4460D; Wed, 4 Sep 2024 17:04:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1404DC4CEC6; Wed, 4 Sep 2024 17:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725469448; bh=68K3QvD0tkKZDAR0UpFpD5XCk8KfcxipD1vhxu8hMF4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=F1QsO8bBJsx0AmPMFiW+aZLLp30OJ6WLUYtazU9cKiD6dYSxRrM5367mxKhnrYiYR 85yB8fFfMOjKTBpSlO8MxTRyv/+24AMKHEZNs759hHseiBj/tQt8LtzNo3gCqV7zJC uQh2rfX5CP6fSwpG+0wWFMriyE1+Q3TPMGbaKlm0vf/W8yTi6YtQEtz57I1nH30eGI uk1925ANdluBVwDdwvc2Uf445CgIHw/GtnY5jubFmpPqI82baUpZ0luZINbPivJThF /Qam2M175ofqQE8+/UGiTVrujbpbV7dCEBmi8Bo0pRE+eOwh3Yh5xEtK4CuLi+kg5V YjDq5wP3d56DQ== From: Mark Brown Date: Wed, 04 Sep 2024 17:58:00 +0100 Subject: [PATCH v2 2/3] mm: Pass vm_flags to generic_get_unmapped_area() MIME-Version: 1.0 Message-Id: <20240904-mm-generic-shadow-stack-guard-v2-2-a46b8b6dc0ed@kernel.org> References: <20240904-mm-generic-shadow-stack-guard-v2-0-a46b8b6dc0ed@kernel.org> In-Reply-To: <20240904-mm-generic-shadow-stack-guard-v2-0-a46b8b6dc0ed@kernel.org> To: Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Guo Ren , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Chris Zankel , Max Filippov , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, "Liam R. Howlett" , Mark Brown X-Mailer: b4 0.15-dev-99b12 X-Developer-Signature: v=1; a=openpgp-sha256; l=4205; i=broonie@kernel.org; h=from:subject:message-id; bh=68K3QvD0tkKZDAR0UpFpD5XCk8KfcxipD1vhxu8hMF4=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBm2JLomVTv4ECj2BO6KAA82Rg2LfwONZpcDKcZ/rOe Hb8SxguJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZtiS6AAKCRAk1otyXVSH0NQyB/ 9kxVcf9SZZ8gEenXIUM2v+Sc6WxUmySDKe8lr2m+hILlbK4d90FD7dZLYCCDeqEkNNrGh6dxpDiVEV hgDmQdrZolUYW4Y/p0jjVeCPzreQXwXMZ8W7N1D5N/l3wwkb+vqQ2RrrMKJvOtbhi0bp2xlKOK1YUk Xa2D8ExFcS60FeUbuVMhU7VgyzPwDG2vup548nR3kM6HbkaB9mUGdYgfOtvd53NRTyvp0fcvcw/+v1 p7p/kh7y4x1kYmGXa2Fhb2LKN3b8Jefvr2v8QIwR+T8VtgPWj4GQAuO+p7ai3SjpR3X5Rsd6NwJmYS YFA9nPiuXiHzme8MHUHh0LCDrrUpLW X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Stat-Signature: r7shhou9e8oebaumqfipmr14r86pnm5x X-Rspam-User: X-Rspamd-Queue-Id: B8D41A0019 X-Rspamd-Server: rspam02 X-HE-Tag: 1725469449-819745 X-HE-Meta: U2FsdGVkX1+WWgSnRqTbgSmGtl59/p1HocUyY2kLyQ0nDdCDPxufEuz5XEtAPlPqdxtJRWab1uVoJwfN7c1d6wKR3yOYbAIYtEuChBd6s7N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BQ9zlMsuaLAPQwmH1L9NlBVAVadzJmYr0hig1q+31uPRQaDqX6+9VT3mJFGvufe4Ru/YYeCnHVvYJrCRTuCq7yti3COvQv5Onp9EVjzmbQ== 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: In preparation for using vm_flags to ensure guard pages for shadow stacks supply them as an argument to generic_get_unmapped_area(). The only user outside of the core code is the PowerPC book3s64 implementation which is trivially wrapping the generic implementation in the radix_enabled() case. No functional changes. Acked-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett Acked-by: Michael Ellerman Signed-off-by: Mark Brown --- arch/powerpc/mm/book3s64/slice.c | 4 ++-- include/linux/sched/mm.h | 4 ++-- mm/mmap.c | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index ada6bf896ef8..87307d0fc3b8 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -641,7 +641,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, vm_flags_t vm_flags) { if (radix_enabled()) - return generic_get_unmapped_area(filp, addr, len, pgoff, flags); + return generic_get_unmapped_area(filp, addr, len, pgoff, flags, vm_flags); return slice_get_unmapped_area(addr, len, flags, mm_ctx_user_psize(¤t->mm->context), 0); @@ -655,7 +655,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, vm_flags_t vm_flags) { if (radix_enabled()) - return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags); + return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags, vm_flags); return slice_get_unmapped_area(addr0, len, flags, mm_ctx_user_psize(¤t->mm->context), 1); diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index c4d34abc45d4..07bb8d4181d7 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -204,11 +204,11 @@ unsigned long mm_get_unmapped_area_vmflags(struct mm_struct *mm, unsigned long generic_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, - unsigned long flags); + unsigned long flags, vm_flags_t vm_flags); unsigned long generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, - unsigned long flags); + unsigned long flags, vm_flags_t vm_flags); #else static inline void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) {} diff --git a/mm/mmap.c b/mm/mmap.c index 7528146f886f..b06ba847c96e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1789,7 +1789,7 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) unsigned long generic_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, - unsigned long flags) + unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma, *prev; @@ -1823,7 +1823,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - return generic_get_unmapped_area(filp, addr, len, pgoff, flags); + return generic_get_unmapped_area(filp, addr, len, pgoff, flags, + vm_flags); } #endif @@ -1834,7 +1835,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, - unsigned long flags) + unsigned long flags, vm_flags_t vm_flags) { struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; @@ -1887,7 +1888,8 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); + return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags, + vm_flags); } #endif