[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231125-const-sysctl-v1-1-5e881b0e0290@weissschuh.net>
Date: Sat, 25 Nov 2023 13:52:50 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Kees Cook <keescook@...omium.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Luis Chamberlain <mcgrof@...nel.org>, Iurii Zaikin <yzaikin@...gle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Joel Granados <j.granados@...sung.com>
Cc: linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH RFC 1/7] sysctl: add helper sysctl_run_handler
A future patch will introduce a second handler function.
To make the code future-proof add the sysctl_run_handler function that
automatically can call the correct handler function.
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
fs/proc/proc_sysctl.c | 2 +-
include/linux/sysctl.h | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 8064ea76f80b..1bb0aa2ff501 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -597,7 +597,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter,
goto out_free_buf;
/* careful: calling conventions are nasty here */
- error = table->proc_handler(table, write, kbuf, &count, &iocb->ki_pos);
+ error = sysctl_run_handler(table, write, kbuf, &count, &iocb->ki_pos);
if (error)
goto out_free_buf;
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 61b40ea81f4d..604aaaa1fce2 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -298,4 +298,10 @@ static inline bool sysctl_is_alias(char *param)
int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
+static inline int sysctl_run_handler(struct ctl_table *ctl, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
+{
+ return ctl->proc_handler(ctl, write, buffer, lenp, ppos);
+}
+
#endif /* _LINUX_SYSCTL_H */
--
2.43.0
Powered by blists - more mailing lists