From patchwork Tue Jan 30 10:34:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13537193 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 5A675C46CD2 for ; Tue, 30 Jan 2024 10:36:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9DF56B007D; Tue, 30 Jan 2024 05:36:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E77546B0085; Tue, 30 Jan 2024 05:36:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D164E6B0087; Tue, 30 Jan 2024 05:36:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BF51B6B007D for ; Tue, 30 Jan 2024 05:36:45 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 692EC80915 for ; Tue, 30 Jan 2024 10:36:45 +0000 (UTC) X-FDA: 81735623970.16.D4CADA1 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf22.hostedemail.com (Postfix) with ESMTP id 406BCC0014 for ; Tue, 30 Jan 2024 10:36:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf22.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706611003; 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; bh=v8SibOCTOtScQ43TjQplY567Dri0/m0MUEJcdXjhse0=; b=j7a2hqfIlm5l4HivoaemII3UAeus94xkEUGBvmxukNAC/WLHcWJuDNt8e5j94509BkKpx0 t0gmLS2kmnIt+Ogwt5tRc0qI580vV8jnFSV0my7LX0PFSjvKmAQEfXCNiZKHAxPFwo4Vjz jJoGZs+svenjJgKrcK6GgPY+jFuK9lQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf22.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706611003; a=rsa-sha256; cv=none; b=JdCcvO5oDGAMDaJb7ni+yuDyNXyOsVmcq4OKYfFFzJmfflqfURjwqKLAp1Y1uXm3ckYBDk xqIYRvJ401EGPLgbZX/z/W2xG6lML7xMeD4a8kogg/ca9jThmRbubxbTyvpDw1kPgyKJHF x1+KsxJW02WSC0L78uwyvd1F0/CSXcE= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4TPM681h4bz9scH; Tue, 30 Jan 2024 11:36:32 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cZwUjiuwfEk7; Tue, 30 Jan 2024 11:36:32 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4TPM4X1FsXz9v9N; Tue, 30 Jan 2024 11:35:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2229B8B76D; Tue, 30 Jan 2024 11:35:08 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id PHLQbxrVfhNu; Tue, 30 Jan 2024 11:35:08 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.134]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9C7538B76C; Tue, 30 Jan 2024 11:35:06 +0100 (CET) From: Christophe Leroy To: Andrew Morton , Kees Cook Cc: Christophe Leroy , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, steven.price@arm.com, Phong Tran , mark.rutland@arm.com, Greg KH Subject: [PATCH v2 3/5] powerpc,s390: ptdump: Define ptdump_check_wx() regardless of CONFIG_DEBUG_WX Date: Tue, 30 Jan 2024 11:34:34 +0100 Message-ID: <07bfb04c7fec58e84413e91d2533581be357a696.1706610398.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706610876; l=3171; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=bb3S88Yvg8QpRseQmACLuXZiVFZjaEpDowsFLtdjjAQ=; b=x0gpc6EGu0yH2XscctlYCktpakujE8CZJRZncJQIF0g06b7Y7Hq6Mvhcu1/d2nAOLeJFqfmh6 BTlFYvDjZnaBzRZ7joo/Zb7ANesjnwXYbuz1WBppoGr+Zl+SP+ywNIp X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Queue-Id: 406BCC0014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9aqjkcuhx1hwbcsruiogwi9ce1h55ri3 X-HE-Tag: 1706611002-588423 X-HE-Meta: U2FsdGVkX19vc9Bjjn9ALkE+il4JIfh/FTjAWZNy0KzpulGKUgXVGIEBodnsLRqEOA4ZA839ZFaxDtLVgltzTUSZYT+GtPkfQSD0EZOJvkiutVpT3LF7YpSpkSdl12DKM9M0tyWt07/uRg4HggvaDHYZJLFRxfPvobpXcM3GRPQTaeljUcCOz4fJU+/3IOoNSWBz8sLmpb/KbOFRZCA4Ct5HD7yk8f4r7cf4RZrxxgf0KP/Q755HaYuUVJ2/TM0A01ArvFSx5MUe4JgBHkSmdlNodx1LqbGvAp7FARDqZnymC6j2kyC1J5rgdcUtpt+EefPDZDsnMmPP0pQmdYfZH3xybMjL2mCTgPEejNG64sMuKfgPUl3C5i8y2HJY94mRKf1Y0SYxVKYZDid6hFAe+tkDk5KUv6/IuAxLO4XVXcAcB5qvAihHbgeYDSzgyPJOO+93M3Cu+R3nVHFztUO1KlyMTqXQJoWtCwkA9nCOIVKz3Vf1YdrklHYR6Bx73/uwZh/Z3nj6QrOEMWptXEnneaYyjRYqh34jnMUwd+grWzzMXXZa0Yfe3/4eRDjN9zX0HO3jcHWRnJeKtLD5EcGk5o9g9zBrxN2aBV4JarkzFNK8PR9iZu/dba7IvA4LdNl2uvYuZA3S73NQEHe5EXy8DA0qRVgNb/E8/meoOHSmExCOwPJlL71GT13TML2S6UBSiVWpFMaiwngIj92PCp4Br/DvA/j2OF9MWcAmXiOmxp4PHsX+BKF9b5hsLD9aQQeL9N5zsbmoUl0jy/lgQ9lLUgsMAutqIJzrcLKuZgQB3lGw9ATy0IVAwyRRP2OC8izSoZSUOz/xhtbJtk4D8sZLuq6tqGiaJsAUHWfNFrvah3fdsLGqcRpJixOU2/BmfWUkkYS/1XebyYabd6hT4P+M6ccWw4R0xpcg4/IGMniRkRhGgejmPv3brNnhNQS89qbgloh4qpK89rx6L9/oFbv FP+5JbFN iAMN+0IvnLLXGucPtx5o05lxUX3Y0CYtZ9Vp1f0CIcYY5yp2ufBJyiaUQuvbnuND1M4OGb7M+PuvUMnM3kF7ax5BVMQlnqdD9hiX9hE6J1X3dDuWvtsmmuP4dNlnaeV1P2m+FsAaXBusXLY6KsSGq7xWefto1MaOtczVYGG1v9TsNLvI= 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: Following patch will use ptdump_check_wx() regardless of CONFIG_DEBUG_WX, so define it at all times on powerpc and s390 just like other architectures. Though keep the WARN_ON_ONCE() only when CONFIG_DEBUG_WX is set. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/ptdump/ptdump.c | 7 +++---- arch/s390/mm/dump_pagetables.c | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c index 620d4917ebe8..b835c80371cd 100644 --- a/arch/powerpc/mm/ptdump/ptdump.c +++ b/arch/powerpc/mm/ptdump/ptdump.c @@ -184,13 +184,14 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) { pte_t pte = __pte(st->current_flags); - if (!IS_ENABLED(CONFIG_DEBUG_WX) || !st->check_wx) + if (!st->check_wx) return; if (!pte_write(pte) || !pte_exec(pte)) return; - WARN_ONCE(1, "powerpc/mm: Found insecure W+X mapping at address %p/%pS\n", + WARN_ONCE(IS_ENABLED(CONFIG_DEBUG_WX), + "powerpc/mm: Found insecure W+X mapping at address %p/%pS\n", (void *)st->start_address, (void *)st->start_address); st->wx_pages += (addr - st->start_address) / PAGE_SIZE; @@ -326,7 +327,6 @@ static void __init build_pgtable_complete_mask(void) pg_level[i].mask |= pg_level[i].flag[j].mask; } -#ifdef CONFIG_DEBUG_WX void ptdump_check_wx(void) { struct pg_state st = { @@ -354,7 +354,6 @@ void ptdump_check_wx(void) else pr_info("Checked W+X mappings: passed, no W+X pages found\n"); } -#endif static int __init ptdump_init(void) { diff --git a/arch/s390/mm/dump_pagetables.c b/arch/s390/mm/dump_pagetables.c index 8dcb4e0c71bd..99da5a5602a8 100644 --- a/arch/s390/mm/dump_pagetables.c +++ b/arch/s390/mm/dump_pagetables.c @@ -121,7 +121,6 @@ static void print_prot(struct seq_file *m, unsigned int pr, int level) static void note_prot_wx(struct pg_state *st, unsigned long addr) { -#ifdef CONFIG_DEBUG_WX if (!st->check_wx) return; if (st->current_prot & _PAGE_INVALID) @@ -138,10 +137,10 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) */ if (addr == PAGE_SIZE && (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear))) return; - WARN_ONCE(1, "s390/mm: Found insecure W+X mapping at address %pS\n", + WARN_ONCE(IS_ENABLED(CONFIG_DEBUG_WX), + "s390/mm: Found insecure W+X mapping at address %pS\n", (void *)st->start_address); st->wx_pages += (addr - st->start_address) / PAGE_SIZE; -#endif /* CONFIG_DEBUG_WX */ } static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) @@ -193,7 +192,6 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, } } -#ifdef CONFIG_DEBUG_WX void ptdump_check_wx(void) { struct pg_state st = { @@ -226,7 +224,6 @@ void ptdump_check_wx(void) (nospec_uses_trampoline() || !static_key_enabled(&cpu_has_bear)) ? "unexpected " : ""); } -#endif /* CONFIG_DEBUG_WX */ #ifdef CONFIG_PTDUMP_DEBUGFS static int ptdump_show(struct seq_file *m, void *v)