All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Iurii Zaikin <yzaikin@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joel Granados <j.granados@samsung.com>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH RFC 1/7] sysctl: add helper sysctl_run_handler
Date: Sat, 25 Nov 2023 13:52:50 +0100	[thread overview]
Message-ID: <20231125-const-sysctl-v1-1-5e881b0e0290@weissschuh.net> (raw)
In-Reply-To: <20231125-const-sysctl-v1-0-5e881b0e0290@weissschuh.net>

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@weissschuh.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


  reply	other threads:[~2023-11-25 12:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20231125125305eucas1p2ebdf870dd8ef46ea9d346f727b832439@eucas1p2.samsung.com>
2023-11-25 12:52 ` [PATCH RFC 0/7] sysctl: constify sysctl ctl_tables Thomas Weißschuh
2023-11-25 12:52   ` Thomas Weißschuh [this message]
2023-11-25 12:52   ` [PATCH RFC 2/7] bpf: cgroup: call proc handler through helper Thomas Weißschuh
2023-11-25 12:52   ` [PATCH RFC 3/7] sysctl: add proc_handler_new to struct ctl_table Thomas Weißschuh
2023-11-25 12:52   ` [PATCH RFC 4/7] net: sysctl: add new sysctl table handler to debug message Thomas Weißschuh
2023-11-25 12:52   ` [PATCH RFC 5/7] treewide: sysctl: migrate proc_dostring to proc_handler_new Thomas Weißschuh
2023-11-25 15:17     ` kernel test robot
2023-11-25 16:48     ` kernel test robot
2023-11-25 12:52   ` [PATCH RFC 6/7] treewide: sysctl: migrate proc_dobool " Thomas Weißschuh
2023-11-25 12:52   ` [PATCH RFC 7/7] treewide: sysctl: migrate proc_dointvec " Thomas Weißschuh
2023-11-25 16:48     ` kernel test robot
2023-11-27 10:13   ` [PATCH RFC 0/7] sysctl: constify sysctl ctl_tables Joel Granados
2023-11-28  8:18     ` Thomas Weißschuh
2023-12-01 16:31       ` Joel Granados
2023-12-03 15:37         ` Thomas Weißschuh
2023-12-04  8:43           ` Joel Granados

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=20231125-const-sysctl-v1-1-5e881b0e0290@weissschuh.net \
    --to=linux@weissschuh.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=j.granados@samsung.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.