From: Zev Weiss <zev@bewilderbeest.net>
To: Russell King <linux@armlinux.org.uk>,
linux-parisc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Helge Deller <deller@gmx.de>,
Florent Revest <revest@chromium.org>
Cc: Sam James <sam@gentoo.org>, Ondrej Mosnacek <omosnace@redhat.com>,
Kees Cook <keescook@chromium.org>,
Zev Weiss <zev@bewilderbeest.net>,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org,
Stefan Roesch <shr@devkernel.io>,
Yin Fengwei <fengwei.yin@intel.com>,
stable@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Borislav Petkov \(AMD\)" <bp@alien8.de>,
Yang Shi <yang@os.amperecomputing.com>,
Miguel Ojeda <ojeda@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
"Mike Rapoport \(IBM\)" <rppt@kernel.org>,
Josh Triplett <josh@joshtriplett.org>
Subject: [PATCH RESEND 1/2] prctl: Generalize PR_SET_MDWE support check to be per-arch
Date: Mon, 26 Feb 2024 17:35:41 -0800 [thread overview]
Message-ID: <20240227013546.15769-5-zev@bewilderbeest.net> (raw)
In-Reply-To: <20240227013546.15769-4-zev@bewilderbeest.net>
There exist systems other than PARISC where MDWE may not be feasible
to support; rather than cluttering up the generic code with additional
arch-specific logic let's add a generic function for checking MDWE
support and allow each arch to override it as needed.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Cc: <stable@vger.kernel.org> # v6.3+
---
arch/parisc/include/asm/mman.h | 14 ++++++++++++++
include/linux/mman.h | 8 ++++++++
kernel/sys.c | 7 +++++--
3 files changed, 27 insertions(+), 2 deletions(-)
create mode 100644 arch/parisc/include/asm/mman.h
diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/asm/mman.h
new file mode 100644
index 000000000000..47c5a1991d10
--- /dev/null
+++ b/arch/parisc/include/asm/mman.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_MMAN_H__
+#define __ASM_MMAN_H__
+
+#include <uapi/asm/mman.h>
+
+/* PARISC cannot allow mdwe as it needs writable stacks */
+static inline bool arch_memory_deny_write_exec_supported(void)
+{
+ return false;
+}
+#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
+
+#endif /* __ASM_MMAN_H__ */
diff --git a/include/linux/mman.h b/include/linux/mman.h
index dc7048824be8..bcb201ab7a41 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -162,6 +162,14 @@ calc_vm_flag_bits(unsigned long flags)
unsigned long vm_commit_limit(void);
+#ifndef arch_memory_deny_write_exec_supported
+static inline bool arch_memory_deny_write_exec_supported(void)
+{
+ return true;
+}
+#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
+#endif
+
/*
* Denies creating a writable executable mapping or gaining executable permissions.
*
diff --git a/kernel/sys.c b/kernel/sys.c
index f8e543f1e38a..8bb106a56b3a 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2408,8 +2408,11 @@ static inline int prctl_set_mdwe(unsigned long bits, unsigned long arg3,
if (bits & PR_MDWE_NO_INHERIT && !(bits & PR_MDWE_REFUSE_EXEC_GAIN))
return -EINVAL;
- /* PARISC cannot allow mdwe as it needs writable stacks */
- if (IS_ENABLED(CONFIG_PARISC))
+ /*
+ * EOPNOTSUPP might be more appropriate here in principle, but
+ * existing userspace depends on EINVAL specifically.
+ */
+ if (!arch_memory_deny_write_exec_supported())
return -EINVAL;
current_bits = get_current_mdwe();
--
2.43.2
next prev parent reply other threads:[~2024-02-27 1:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 1:35 [PATCH RESEND 0/2] ARM: prctl: Reject PR_SET_MDWE where not supported Zev Weiss
2024-02-27 1:35 ` Zev Weiss [this message]
2024-02-27 10:24 ` [PATCH RESEND 1/2] prctl: Generalize PR_SET_MDWE support check to be per-arch Russell King (Oracle)
2024-02-27 19:53 ` Helge Deller
2024-03-19 17:37 ` Zev Weiss
2024-02-27 1:35 ` [PATCH RESEND 2/2] ARM: prctl: Reject PR_SET_MDWE on pre-ARMv6 Zev Weiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240227013546.15769-5-zev@bewilderbeest.net \
--to=zev@bewilderbeest.net \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=david@redhat.com \
--cc=deller@gmx.de \
--cc=fengwei.yin@intel.com \
--cc=josh@joshtriplett.org \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=ojeda@kernel.org \
--cc=oleg@redhat.com \
--cc=omosnace@redhat.com \
--cc=openbmc@lists.ozlabs.org \
--cc=revest@chromium.org \
--cc=rick.p.edgecombe@intel.com \
--cc=rppt@kernel.org \
--cc=sam@gentoo.org \
--cc=shr@devkernel.io \
--cc=stable@vger.kernel.org \
--cc=yang@os.amperecomputing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).