From: Michael McCracken <michael.mccracken@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: kernel-hardening@lists.openwall.com, serge@hallyn.com,
tycho@tycho.pizza,
Michael McCracken <michael.mccracken@gmail.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>,
Iurii Zaikin <yzaikin@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] sysctl: add config to make randomize_va_space RO
Date: Thu, 4 May 2023 14:30:02 -0700 [thread overview]
Message-ID: <20230504213002.56803-1-michael.mccracken@gmail.com> (raw)
Add config RO_RANDMAP_SYSCTL to set the mode of the randomize_va_space
sysctl to 0444 to disallow all runtime changes. This will prevent
accidental changing of this value by a root service.
The config is disabled by default to avoid surprises.
Signed-off-by: Michael McCracken <michael.mccracken@gmail.com>
---
kernel/sysctl.c | 4 ++++
mm/Kconfig | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bfe53e835524..c5aafb734abe 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1913,7 +1913,11 @@ static struct ctl_table kern_table[] = {
.procname = "randomize_va_space",
.data = &randomize_va_space,
.maxlen = sizeof(int),
+#if defined(CONFIG_RO_RANDMAP_SYSCTL)
+ .mode = 0444,
+#else
.mode = 0644,
+#endif
.proc_handler = proc_dointvec,
},
#endif
diff --git a/mm/Kconfig b/mm/Kconfig
index 7672a22647b4..91a4a86d70e0 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1206,6 +1206,13 @@ config PER_VMA_LOCK
This feature allows locking each virtual memory area separately when
handling page faults instead of taking mmap_lock.
+config RO_RANDMAP_SYSCTL
+ bool "Make randomize_va_space sysctl 0444"
+ depends on MMU
+ default n
+ help
+ Set file mode of /proc/sys/kernel/randomize_va_space to 0444 to disallow runtime changes in ASLR.
+
source "mm/damon/Kconfig"
endmenu
--
2.37.1 (Apple Git-137.1)
next reply other threads:[~2023-05-04 21:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 21:30 Michael McCracken [this message]
2023-05-05 7:35 ` [PATCH] sysctl: add config to make randomize_va_space RO David Hildenbrand
2023-05-05 7:46 ` Sam James
2023-05-05 15:15 ` David Hildenbrand
2023-05-05 15:16 ` David Hildenbrand
2023-05-05 15:23 ` Paul Moore
2023-05-06 7:04 ` Kaiwan N Billimoria
2023-05-07 19:53 ` Paul Moore
2023-05-15 21:43 ` Serge Hallyn
2023-05-16 20:17 ` Kees Cook
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=20230504213002.56803-1-michael.mccracken@gmail.com \
--to=michael.mccracken@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=serge@hallyn.com \
--cc=tycho@tycho.pizza \
--cc=yzaikin@google.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 NNTP newsgroup(s).