Thread (5 messages) 5 messages, 1 author, 2022-01-04
STALE1616d
Revisions (10)
  1. v10 [diff vs current]
  2. v11 [diff vs current]
  3. v11 [diff vs current]
  4. v12 [diff vs current]
  5. v13 [diff vs current]
  6. v14 [diff vs current]
  7. v15 [diff vs current]
  8. v16 [diff vs current]
  9. v17 [diff vs current]
  10. v18 current

[PATCH v18 1/4] printk: Move back proc_dointvec_minmax_sysadmin() to sysctl.c

From: Mickaël Salaün <mic@digikod.net>
Date: 2022-01-04 15:45:24
Also in: linux-api, linux-fsdevel, linux-integrity, lkml
Subsystem: printk, proc sysctl, the rest · Maintainers: Petr Mladek, Kees Cook, Joel Granados, Linus Torvalds

From: Mickaël Salaün <redacted>

The proc_dointvec_minmax_sysadmin() helper is useful for the
fs.trusted_for_policy sysctl brought by the next commit.

This partially revert commit 642fd23fb826 ("printk: move printk sysctl
to printk/sysctl.c") from Luis Chamberlain's 20211129-sysctl-cleanups
branch [1], to share the proc_dointvec_minmax_sysadmin() helper.  FYI,
this previous commit also got the buffer pointer an __user attribute.

Also remove the forgotten ten_thousand static variable (moved to
kernel/printk/sysctl.c).

Link: https://lkml.kernel.org/r/20211124231435.1445213-6-mcgrof@kernel.org [1]
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Xiaoming Ni <redacted>
Signed-off-by: Mickaël Salaün <redacted>
Link: https://lore.kernel.org/r/20220104155024.48023-2-mic@digikod.net (local)
---
 include/linux/sysctl.h | 2 ++
 kernel/printk/sysctl.c | 9 ---------
 kernel/sysctl.c        | 9 +++++++++
 3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 180adf7da785..cf1ba98aab50 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -69,6 +69,8 @@ int proc_dobool(struct ctl_table *table, int write, void *buffer,
 int proc_dointvec(struct ctl_table *, int, void *, size_t *, loff_t *);
 int proc_douintvec(struct ctl_table *, int, void *, size_t *, loff_t *);
 int proc_dointvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
+int proc_dointvec_minmax_sysadmin(struct ctl_table *, int, void *, size_t *,
+		loff_t *);
 int proc_douintvec_minmax(struct ctl_table *table, int write, void *buffer,
 		size_t *lenp, loff_t *ppos);
 int proc_dou8vec_minmax(struct ctl_table *table, int write, void *buffer,
diff --git a/kernel/printk/sysctl.c b/kernel/printk/sysctl.c
index 653ae04aab7f..c7129428ee9b 100644
--- a/kernel/printk/sysctl.c
+++ b/kernel/printk/sysctl.c
@@ -11,15 +11,6 @@
 
 static const int ten_thousand = 10000;
 
-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
-				void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-	if (write && !capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
-	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
-}
-
 static struct ctl_table printk_sysctls[] = {
 	{
 		.procname	= "printk",
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 5ae443b2882e..2e2027e323fd 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -888,6 +888,15 @@ static int proc_taint(struct ctl_table *table, int write,
 	return err;
 }
 
+int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
+				void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	if (write && !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+}
+
 /**
  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
  * @min: pointer to minimum allowable value
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help