From mboxrd@z Thu Jan 1 00:00:00 1970 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 4623BC433EF for ; Tue, 14 Dec 2021 17:11:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2E676B0071; Tue, 14 Dec 2021 12:11:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADDEA6B0073; Tue, 14 Dec 2021 12:11:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6076B0074; Tue, 14 Dec 2021 12:11:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 8D2276B0071 for ; Tue, 14 Dec 2021 12:11:37 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 55557180DA174 for ; Tue, 14 Dec 2021 17:11:27 +0000 (UTC) X-FDA: 78917041014.31.96A9D98 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf21.hostedemail.com (Postfix) with ESMTP id 82BBD1C000F for ; Tue, 14 Dec 2021 17:11:24 +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 ams.source.kernel.org (Postfix) with ESMTPS id 441D7B81B9D; Tue, 14 Dec 2021 17:11:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0FD9C34604; Tue, 14 Dec 2021 17:11:20 +0000 (UTC) Date: Tue, 14 Dec 2021 17:11:17 +0000 From: Catalin Marinas To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , Andrew Morton , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH mm v3 25/38] kasan, vmalloc, arm64: mark vmalloc mappings as pgprot_tagged Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 82BBD1C000F X-Stat-Signature: d4nr7skenchswbs59rnbxfgkzg7gpnkr Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-HE-Tag: 1639501884-6958 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: On Mon, Dec 13, 2021 at 10:54:21PM +0100, andrey.konovalov@linux.dev wrote: > diff --git a/arch/arm64/include/asm/vmalloc.h b/arch/arm64/include/asm/vmalloc.h > index b9185503feae..3d35adf365bf 100644 > --- a/arch/arm64/include/asm/vmalloc.h > +++ b/arch/arm64/include/asm/vmalloc.h > @@ -25,4 +25,14 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot) > > #endif > > +#define arch_vmalloc_pgprot_modify arch_vmalloc_pgprot_modify > +static inline pgprot_t arch_vmalloc_pgprot_modify(pgprot_t prot) > +{ > + if (IS_ENABLED(CONFIG_KASAN_HW_TAGS) && > + (pgprot_val(prot) == pgprot_val(PAGE_KERNEL))) > + prot = pgprot_tagged(prot); > + > + return prot; > +} > + > #endif /* _ASM_ARM64_VMALLOC_H */ > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > index 28becb10d013..760caeedd749 100644 > --- a/include/linux/vmalloc.h > +++ b/include/linux/vmalloc.h > @@ -115,6 +115,13 @@ static inline int arch_vmap_pte_supported_shift(unsigned long size) > } > #endif > > +#ifndef arch_vmalloc_pgprot_modify > +static inline pgprot_t arch_vmalloc_pgprot_modify(pgprot_t prot) > +{ > + return prot; > +} > +#endif > + > /* > * Highlevel APIs for driver use > */ > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 837ed355bfc6..58bd2f7f86d7 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3060,6 +3060,8 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, > return NULL; > } > > + prot = arch_vmalloc_pgprot_modify(prot); > + > if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) { > unsigned long size_per_node; I wonder whether we could fix the prot bits in the caller instead and we won't need to worry about the exec or the module_alloc() case. Something like: diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d2a00ad4e1dd..4e8c61255b92 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3112,7 +3112,7 @@ void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask, int node, const void *caller) { return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END, - gfp_mask, PAGE_KERNEL, 0, node, caller); + gfp_mask, pgprot_hwasan(PAGE_KERNEL), 0, node, caller); } /* * This is only for performance analysis of vmalloc and stress purpose. @@ -3161,7 +3161,7 @@ EXPORT_SYMBOL(vmalloc); void *vmalloc_no_huge(unsigned long size) { return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, - GFP_KERNEL, PAGE_KERNEL, VM_NO_HUGE_VMAP, + GFP_KERNEL, pgprot_hwasan(PAGE_KERNEL), VM_NO_HUGE_VMAP, NUMA_NO_NODE, __builtin_return_address(0)); } EXPORT_SYMBOL(vmalloc_no_huge); with pgprot_hwasan() defined to pgprot_tagged() only if KASAN_HW_TAGS is enabled. -- Catalin