[PATCH RFC v3 11/13] sysctl: unrandomize struct ctl_table.procname
From: Mauricio Faria de Oliveira
Date: Wed Aug 19 2026 - 14:34:57 EST
The 'struct ctl_table.procname' field (sysctl filename) cannot be accessed
by scripts since it is defined in kernel headers (see "don't include kernel
headers into userspace" in file2alias.c) and its offset may be randomized.
Unrandomize '.procname' as the first field so its offset is always zero and
match the 'struct ctl_table' symbol address, which can be found by scripts.
Originally-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxxxxx>
Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxx>
---
include/linux/sysctl.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index b808fbc1d964f453db8e354825fd8800db1eecd3..ccc77bb918614b1de1e44fbef70471c85fb55c09 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -220,7 +220,14 @@ static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
/* A sysctl table is an array of struct ctl_table: */
struct ctl_table {
+
+ /* This must be the first field for module aliases (file2alias.c) */
const char *procname; /* Text ID for /proc/sys */
+
+#ifdef CONFIG_SYSCTL_MODULE_ALIASES
+ /* This begins the randomizable portion of the struct. */
+ randomized_struct_fields_start
+#endif
void *data;
int maxlen;
umode_t mode;
@@ -228,7 +235,14 @@ struct ctl_table {
struct ctl_table_poll *poll;
void *extra1;
void *extra2;
+#ifdef CONFIG_SYSCTL_MODULE_ALIASES
+ /* New fields go above here, so they are in the randomized portion. */
+ randomized_struct_fields_end
+};
+static_assert(offsetof(const struct ctl_table, procname) == 0);
+#else
} __randomize_layout;
+#endif
struct ctl_node {
struct rb_node node;
--
2.47.3