From patchwork Thu Feb 8 01:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 13549214 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 67EC2C4828D for ; Thu, 8 Feb 2024 01:26:52 +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=eaEl9sIFrP/JxKXiAz5TGWdD141CI5EjSlYKl3wURzQ=; b=HJPAn59I/VbRZA 0r5Bzq34d0qts69v7qIY1sjDOIE2/KXDt3KLRarzwi7aLp+J2tnVjDLgoXNLNY67pt5Y/Vx0hs39w ZDUcQ5tp2AhsPViUdlSgGBH/TKVOF6NjNi9OQegKVKJEIiOSgteXHI6ej7DJHmi7GxTnPGoQRRQ7W c/9Lz+MNoOrIDR42kASf5UywmoYWe5R7qHpvmKsxDfqgSlDX+LUK191XyzjPJ8cFDqLcGWGiLKGmT VjfAMGDSmEHqrT+6gEWiiiTS1G5wPxUaCbQ4e3dP0nuy752P1+FYn8YiuxX7gggM19v5y4Q90Wtca LL1gupr8E/2PRnPD236w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXtBT-0000000CNsP-1eSp; Thu, 08 Feb 2024 01:26:35 +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 1rXtBR-0000000CNrW-0QpJ for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 01:26:34 +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 90C25DD9; Wed, 7 Feb 2024 17:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1707355589; bh=jCfZxrSPfJRHCvrnkx78xqXBFO8QXL5lwiLPbS+xTAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WE/8Lz4fbNW5hsXgLypZFn60E7qq3727+grkoIAgUAZO+kPRV+GimPEAfRtWnfs8N BHEObsnhOydmXdgmSyMAojdnhwMYrIFvSnPrwMl8MGW8gyVf330s4rIozE0T5/dEE9 47SLwGlLubpXFlRqB6hCTSQk3VHSnmIl2CW0Z4oQ= From: Zev Weiss To: Russell King , linux-arm-kernel@lists.infradead.org Cc: Zev Weiss , openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/2] ARM: prctl: Reject PR_SET_MDWE on pre-ARMv6 Date: Wed, 7 Feb 2024 17:26:20 -0800 Message-ID: <20240208012620.32604-6-zev@bewilderbeest.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208012620.32604-4-zev@bewilderbeest.net> References: <20240208012620.32604-4-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240207_172633_172879_48FF3E71 X-CRM114-Status: GOOD ( 10.82 ) 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__ */