linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/14] sysctl: provide callback for write into ctl_table entry
@ 2012-04-29  6:45 Sasha Levin
  2012-04-29  6:45 ` [PATCH 02/14] sched debug,sysctl: remove proc input checks out of sysctl handlers Sasha Levin
                   ` (14 more replies)
  0 siblings, 15 replies; 23+ messages in thread
From: Sasha Levin @ 2012-04-29  6:45 UTC (permalink / raw)
  To: viro, rostedt, fweisbec, mingo, a.p.zijlstra, paulus, acme,
	james.l.morris, ebiederm, akpm, tglx
  Cc: linux-fsdevel, linux-kernel, linux-mm, linux-security-module,
	Sasha Levin

Provide a callback that will be called when writing to a ctl_table
entry after the user input has been validated.

This will simplify user input checks since now it will be possible to
remove them out of the proc_handler.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 fs/proc/proc_sysctl.c  |    4 ++++
 include/linux/sysctl.h |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 21d836f..190db28 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -507,6 +507,10 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
 	error = table->proc_handler(table, write, buf, &res, ppos);
 	if (!error)
 		error = res;
+
+	if (!error && write && table->callback)
+		error = table->callback();
+
 out:
 	sysctl_head_finish(head);
 
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index c34b4c8..27c14cf 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -1022,6 +1022,7 @@ struct ctl_table
 	struct ctl_table_poll *poll;
 	void *extra1;
 	void *extra2;
+	int (*callback)(void);		/* Called when entry is written to */
 };
 
 struct ctl_node {
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2012-04-30  2:48 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-29  6:45 [PATCH 01/14] sysctl: provide callback for write into ctl_table entry Sasha Levin
2012-04-29  6:45 ` [PATCH 02/14] sched debug,sysctl: remove proc input checks out of sysctl handlers Sasha Levin
2012-04-29  6:45 ` [PATCH 03/14] sched rt,sysctl: " Sasha Levin
2012-04-30  2:32   ` Eric Paris
2012-04-29  6:45 ` [PATCH 04/14] ftrace,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 05/14] sysrq,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 06/14] watchdog,sysctl: remove unused external Sasha Levin
2012-04-29  6:45 ` [PATCH 07/14] watchdog,sysctl: remove proc input checks out of sysctl handlers Sasha Levin
2012-04-29  6:45 ` [PATCH 08/14] hung task,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 09/14] perf,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 10/14] mm,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 11/14] hugetlb,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 12/14] mm compaction,sysctl: " Sasha Levin
2012-04-29  6:45 ` [PATCH 13/14] security,sysctl: " Sasha Levin
2012-04-30  2:28   ` Eric Paris
2012-04-29  6:45 ` [PATCH 14/14] fs,sysctl: " Sasha Levin
2012-04-29  8:22 ` [PATCH 01/14] sysctl: provide callback for write into ctl_table entry Eric W. Biederman
2012-04-29 12:07   ` Sasha Levin
2012-04-29 14:00     ` Steven Rostedt
2012-04-29 14:14       ` Sasha Levin
2012-04-29 19:57         ` Steven Rostedt
2012-04-30  2:52           ` Eric W. Biederman
2012-04-29 12:26 ` Sasha Levin

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).