Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1652425rbb; Mon, 26 Feb 2024 17:36:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVPAiKHaciUAMdwKgd/RACpdumroh2FtREFzMZgBIlcTSX2AYrGpTdGIZfnC0XNjcy4A8/fapWOJZEmw8Bcm0P4OikQnzz6tBwFmm7ndw== X-Google-Smtp-Source: AGHT+IFzdzMvtbwx8MEZ6Y7tZ56iD9kJgaTUB6SMSl6+1dNQ/zTPKewv0Gz8yIxOxXG0Au6vSkNf X-Received: by 2002:a92:c842:0:b0:365:27e7:4b60 with SMTP id b2-20020a92c842000000b0036527e74b60mr9255804ilq.21.1708997764647; Mon, 26 Feb 2024 17:36:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708997764; cv=pass; d=google.com; s=arc-20160816; b=ENN0G/ECnEvyEceKcex1GZBzMoResInMQeMtUuYQvVvALatVWxaF6gKwf+Oe8CykHA 9ZDMpsoGinzhZ8Vqxu3F8cKHLAb7U7YZI8FQG5KKmxodZti61w+LaNONTtzcIBevHPqm x53S6sXuynDQ5gQ7v2Fi+zBY97saFuRFnCeHibaJZcvIOJ1JiZ2MKFUzew6qJ0RQU1jH CTrvHDcMNZz8ZLvpGRNNaHz65mAJuuAkcDWQol1RAYx18mC4h8URk4cZe3AkptoDF894 NJjQW8gNgRFG/a8WDs49BqUuwbgjZrSEUnN5kq49IgnfcSxHbg6iViSozXknnPG2KPwl e/Hw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=2LGMoG5lzw93A3enN/2kw2d60L6ZTNDD2AvAsIcBPUA=; fh=Q7vCzlRPJqbijdGCMcfQJMqFdj4BSllMtbPRSmFCmYI=; b=kSAAYLKAh2R5aGMy2Y4xooZhkhbbXN0/I3fkyHkkDtvF8s3r8QicRgD59gDM49GVvQ ikfpocxcyWNaD9lXSFZRp470Vw9WPLxUOuwW+odz1KT+1kZ4bazYolnRhDHIoAnJLXkc rA2Et/XNL7H21am/wAmRK40BWqKrqFIMYhTTKt4SVqMqDWeMvyf78KCcFXhDQR2NP/an gQT8M/oSVEVFkEJO9zt4kBi+y2SlaNVXL1dJOxFGtkRos+YLeEgocUCT3vwyjD/A/dDh tGxccbMkrKb6a1JJw9KyYbGEGV9ukB/zBJUvfLG9u7eoRZ/Wp7otUWdGbrB5095zlZDL X68g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=FJ6YLI7s; arc=pass (i=1 spf=pass spfdomain=bewilderbeest.net dkim=pass dkdomain=bewilderbeest.net dmarc=pass fromdomain=bewilderbeest.net); spf=pass (google.com: domain of linux-kernel+bounces-82537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82537-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x21-20020a63b215000000b005cd90b47495si4535336pge.264.2024.02.26.17.36.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 17:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=FJ6YLI7s; arc=pass (i=1 spf=pass spfdomain=bewilderbeest.net dkim=pass dkdomain=bewilderbeest.net dmarc=pass fromdomain=bewilderbeest.net); spf=pass (google.com: domain of linux-kernel+bounces-82537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82537-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5685C282EC7 for ; Tue, 27 Feb 2024 01:36:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C759E6AB8; Tue, 27 Feb 2024 01:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.b="FJ6YLI7s" Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [71.19.156.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 756D7525D; Tue, 27 Feb 2024 01:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.156.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708997757; cv=none; b=V3dMERc7m1J2bAjxSDuHgpZG5Zf7EPy6vuZhT4r8q2/y7Qhd8o2j25jHy3UEgLFAbNZV3L0QuOvrybMiIQwr+DzgNouAOwKn8LfS91zn9y+Sq7w2VzwTAHW4Ky/pDqALGjQonxS5pt7UoOs+iENw3eqg/S8CzgbUbQAcmgo3aRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708997757; c=relaxed/simple; bh=5prQOo/5DUmjL9n6Mn2+etl4F9JkZ9RfZ2EqTaQr7jY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=f7swM/Vaxlg8YZn100pzzsLZ96OTQocgbs6a0Wz8qNG47jDbu37L6+vGRblHejBoSU8qQeWpEyUoyE7h3wSLLZbAOkxPYg2JeFcxROk6H/mD5CiMWilcQBss8j7S8c1WDDRl0ePHtPpcbLh0i90M6OwYXhMKuPC/e5wppb33II0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bewilderbeest.net; spf=pass smtp.mailfrom=bewilderbeest.net; dkim=pass (1024-bit key) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.b=FJ6YLI7s; arc=none smtp.client-ip=71.19.156.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bewilderbeest.net 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 0D6F48A; Mon, 26 Feb 2024 17:35:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1708997754; bh=2LGMoG5lzw93A3enN/2kw2d60L6ZTNDD2AvAsIcBPUA=; h=From:To:Cc:Subject:Date:From; b=FJ6YLI7sYbcpLH87YNKyDBadQUCtbuQwg4rTyYqz82ieGu866VqzLPH9zFr/wftHg /ZlGqrj5BMlSWjMcPcAhBIqAlS2fWO4rWhGjUgjSiz2mBSatUs9hQR4xht8Fud0WPh QJSVNGF2oJ0NU7A7ElTtq0x2ZjoxEH3TSSWL9hdU= 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 0/2] ARM: prctl: Reject PR_SET_MDWE where not supported Date: Mon, 26 Feb 2024 17:35:40 -0800 Message-ID: <20240227013546.15769-4-zev@bewilderbeest.net> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [Resending as per Russell's request...] Hello, I noticed after a recent kernel update that my ARM926 system started segfaulting on any execve() after calling prctl(PR_SET_MDWE). After some investigation it appears that ARMv5 is incapable of providing the appropriate protections for MDWE, since any readable memory is also implicitly executable. (Note that I'm not an expert in either ARM arch details or the mm subsystem, so please bear with me if I've botched something in the above analysis.) The prctl_set_mdwe() function already had some special-case logic added disabling it on PARISC (commit 793838138c15, "prctl: Disable prctl(PR_SET_MDWE) on parisc"); this patch series (1) generalizes that check to use an arch_*() function, and (2) adds a corresponding override for ARM to disable MDWE on pre-ARMv6 CPUs. With the series applied, prctl(PR_SET_MDWE) is rejected on ARMv5 and subsequent execve() calls (as well as mmap(PROT_READ|PROT_WRITE)) can succeed instead of unconditionally failing; on ARMv6 the prctl works as it did previously. Thanks, Zev [0] https://lore.kernel.org/all/2023112456-linked-nape-bf19@gregkh/ Zev Weiss (2): prctl: Generalize PR_SET_MDWE support check to be per-arch ARM: prctl: Reject PR_SET_MDWE on pre-ARMv6 arch/arm/include/asm/mman.h | 14 ++++++++++++++ arch/parisc/include/asm/mman.h | 14 ++++++++++++++ include/linux/mman.h | 8 ++++++++ kernel/sys.c | 7 +++++-- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 arch/arm/include/asm/mman.h create mode 100644 arch/parisc/include/asm/mman.h -- 2.43.2