From patchwork Tue Feb 27 01:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 13573090 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26DCAC48BF6 for ; Tue, 27 Feb 2024 01:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Yv+GSrJaJb4d8dgXZ4z60pcl4zc5yEHfUn+Pv46zKBQ=; b=44xXJCkjFG2Vs8 I5bt4b3ZsaLNgz9p+nCrRuvWRwwxzH+Uhh2GdsNORtZSL3Q6LgMDEGmttojv8GzL8w50S7NbaM7Cj ND3OCL/X0Z8Jdl8I9qA2twbS7v+5aWH3kuENHfHekC1/dGJtgmbrA8Ps5yLmlNxqPsyxx0+XVJsZu lfrbKI5TDgn7fXYofv1SEX8wUenr19ZyPh7rOuVJlegHQIJLvk3AuzBZyw2nbsASRuJwDLsgF29h1 UD754DQGzGDwRth9vvCWdf6072vw94M8+1CeS3yGfDHEBFRb3ScjddS15b+fW5QC1QsjBKA3Mlr8W qvLfF3e9NGydia7IU83Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1remO0-00000003JNl-2K2S; Tue, 27 Feb 2024 01:36:00 +0000 Received: from thorn.bewilderbeest.net ([2605:2700:0:5::4713:9cab]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1remNx-00000003JMc-2b5f for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 01:35:58 +0000 Received: from hatter.bewilderbeest.net (unknown [IPv6:2602:61:712b:6300::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 70FAB42C7; Mon, 26 Feb 2024 17:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1708997756; bh=BpkbZoKcb/ElcmyFvuLHFS6Mz0ozyOSKWVwGl1poh1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i8pi9UQDl+FTEkyoh7hOS5J5lRGjMIL8a3rV/L92/Ad3dZCdBxJOWKlDIP2Mxec0c LnnIgq4N20v+KoqvA71dCi7nzTaFMc4gZN0pNNwiND5AEDG/ShB0ouziEmHKwtYsxD cZIMb7RFbVGdMffzTaUtGY0JwePwtrzZORnDBQKc= From: Zev Weiss To: Russell King , linux-parisc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Helge Deller , Florent Revest Cc: Zev Weiss , "James E.J. Bottomley" , "Borislav Petkov (AMD)" , Yin Fengwei , "Mike Rapoport (IBM)" , Andrew Morton , Kees Cook , Yang Shi , Rick Edgecombe , Oleg Nesterov , David Hildenbrand , Stefan Roesch , Josh Triplett , Ondrej Mosnacek , Miguel Ojeda , linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Sam James , stable@vger.kernel.org Subject: [PATCH RESEND 2/2] ARM: prctl: Reject PR_SET_MDWE on pre-ARMv6 Date: Mon, 26 Feb 2024 17:35:42 -0800 Message-ID: <20240227013546.15769-6-zev@bewilderbeest.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240227013546.15769-4-zev@bewilderbeest.net> References: <20240227013546.15769-4-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_173557_688563_DE374E99 X-CRM114-Status: GOOD ( 11.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On v5 and lower CPUs we can't provide MDWE protection, so ensure we fail any attempt to enable it via prctl(PR_SET_MDWE). Previously such an attempt would misleadingly succeed, leading to any subsequent mmap(PROT_READ|PROT_WRITE) or execve() failing unconditionally (the latter somewhat violently via force_fatal_sig(SIGSEGV) due to READ_IMPLIES_EXEC). Signed-off-by: Zev Weiss Cc: # v6.3+ --- arch/arm/include/asm/mman.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 arch/arm/include/asm/mman.h diff --git a/arch/arm/include/asm/mman.h b/arch/arm/include/asm/mman.h new file mode 100644 index 000000000000..2189e507c8e0 --- /dev/null +++ b/arch/arm/include/asm/mman.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include +#include + +static inline bool arch_memory_deny_write_exec_supported(void) +{ + return cpu_architecture() >= CPU_ARCH_ARMv6; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */