All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups
@ 2021-11-29 20:55 Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 1/9] fs: move inode sysctls to its own file Luis Chamberlain
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

This is the 4th set of kernel/sysctl.c cleanups. These are being
pushed out for review for the first time. This is trying to move all
filesystem sysctl knobs out from kernel/sysctl.c to where they are
actually being used.

This is slimming down the fs uses of kernel/sysctl.c to the point
that the next step is to just get rid of the fs base directory for it
and move that elsehwere, so that next patch series starts dealing with
that to demo how we can end up cleaning up a full base directory from
kernel/sysctl.c, one at a time.

Luis Chamberlain (9):
  fs: move inode sysctls to its own file
  fs: move fs stat sysctls to file_table.c
  fs: move dcache sysctls to its own file
  sysctl: move maxolduid as a sysctl specific const
  fs: move shared sysctls to fs/sysctls.c
  fs: move locking sysctls where they are used
  fs: move namei sysctls to its own file
  fs: move fs/exec.c sysctls into its own file
  fs: move pipe sysctls to is own file

 fs/Makefile               |   1 +
 fs/dcache.c               |  32 ++++-
 fs/exec.c                 |  90 ++++++++++++++
 fs/file_table.c           |  47 +++++--
 fs/inode.c                |  31 ++++-
 fs/locks.c                |  34 ++++-
 fs/namei.c                |  58 ++++++++-
 fs/pipe.c                 |  64 +++++++++-
 fs/proc/proc_sysctl.c     |   2 +-
 fs/sysctls.c              |  38 ++++++
 include/linux/dcache.h    |  10 --
 include/linux/fs.h        |  13 --
 include/linux/pipe_fs_i.h |   4 -
 include/linux/sysctl.h    |   9 ++
 kernel/sysctl.c           | 255 ++------------------------------------
 15 files changed, 390 insertions(+), 298 deletions(-)
 create mode 100644 fs/sysctls.c

-- 
2.33.0


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

* [PATCH 1/9] fs: move inode sysctls to its own file
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 2/9] fs: move fs stat sysctls to file_table.c Luis Chamberlain
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move the inode sysctls to its own file. Since we are no longer
using this outside of fs/ remove the extern declaration of
its respective proc helper.

We use early_initcall() as it is the earliest we can use.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/inode.c         | 31 ++++++++++++++++++++++++++++---
 include/linux/fs.h |  3 ---
 kernel/sysctl.c    | 14 --------------
 3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 980e7b7a5460..bef6ba9b8eb4 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -70,7 +70,7 @@ EXPORT_SYMBOL(empty_aops);
 /*
  * Statistics gathering..
  */
-struct inodes_stat_t inodes_stat;
+static struct inodes_stat_t inodes_stat;
 
 static DEFINE_PER_CPU(unsigned long, nr_inodes);
 static DEFINE_PER_CPU(unsigned long, nr_unused);
@@ -106,13 +106,38 @@ long get_nr_dirty_inodes(void)
  * Handle nr_inode sysctl
  */
 #ifdef CONFIG_SYSCTL
-int proc_nr_inodes(struct ctl_table *table, int write,
-		   void *buffer, size_t *lenp, loff_t *ppos)
+static int proc_nr_inodes(struct ctl_table *table, int write, void *buffer,
+			  size_t *lenp, loff_t *ppos)
 {
 	inodes_stat.nr_inodes = get_nr_inodes();
 	inodes_stat.nr_unused = get_nr_inodes_unused();
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
+
+static struct ctl_table inodes_sysctls[] = {
+	{
+		.procname	= "inode-nr",
+		.data		= &inodes_stat,
+		.maxlen		= 2*sizeof(long),
+		.mode		= 0444,
+		.proc_handler	= proc_nr_inodes,
+	},
+	{
+		.procname	= "inode-state",
+		.data		= &inodes_stat,
+		.maxlen		= 7*sizeof(long),
+		.mode		= 0444,
+		.proc_handler	= proc_nr_inodes,
+	},
+	{ }
+};
+
+static int __init init_fs_inode_sysctls(void)
+{
+	register_sysctl_init("fs", inodes_sysctls);
+	return 0;
+}
+early_initcall(init_fs_inode_sysctls);
 #endif
 
 static int no_open(struct inode *inode, struct file *file)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6d13424891dd..667c291b53c5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -81,7 +81,6 @@ extern void __init files_maxfiles_init(void);
 extern struct files_stat_struct files_stat;
 extern unsigned long get_max_files(void);
 extern unsigned int sysctl_nr_open;
-extern struct inodes_stat_t inodes_stat;
 extern int leases_enable, lease_break_time;
 extern int sysctl_protected_symlinks;
 extern int sysctl_protected_hardlinks;
@@ -3596,8 +3595,6 @@ int proc_nr_files(struct ctl_table *table, int write,
 		  void *buffer, size_t *lenp, loff_t *ppos);
 int proc_nr_dentry(struct ctl_table *table, int write,
 		  void *buffer, size_t *lenp, loff_t *ppos);
-int proc_nr_inodes(struct ctl_table *table, int write,
-		   void *buffer, size_t *lenp, loff_t *ppos);
 int __init list_bdev_fs_names(char *buf, size_t size);
 
 #define __FMODE_EXEC		((__force int) FMODE_EXEC)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8f9c275e0242..3eb71bf91b71 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2900,20 +2900,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "inode-nr",
-		.data		= &inodes_stat,
-		.maxlen		= 2*sizeof(long),
-		.mode		= 0444,
-		.proc_handler	= proc_nr_inodes,
-	},
-	{
-		.procname	= "inode-state",
-		.data		= &inodes_stat,
-		.maxlen		= 7*sizeof(long),
-		.mode		= 0444,
-		.proc_handler	= proc_nr_inodes,
-	},
 	{
 		.procname	= "file-nr",
 		.data		= &files_stat,
-- 
2.33.0


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

* [PATCH 2/9] fs: move fs stat sysctls to file_table.c
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 1/9] fs: move inode sysctls to its own file Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 3/9] fs: move dcache sysctls to its own file Luis Chamberlain
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

We can create the sysctl dynamically on early init for fs stat
to help with this clutter. This dusts off the fs stat syctls knobs
and puts them into where they are declared.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/file_table.c    | 47 ++++++++++++++++++++++++++++++++++++++--------
 include/linux/fs.h |  3 ---
 kernel/sysctl.c    | 25 ------------------------
 3 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/fs/file_table.c b/fs/file_table.c
index 45437f8e1003..57edef16dce4 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -33,7 +33,7 @@
 #include "internal.h"
 
 /* sysctl tunables... */
-struct files_stat_struct files_stat = {
+static struct files_stat_struct files_stat = {
 	.max_files = NR_FILE
 };
 
@@ -75,22 +75,53 @@ unsigned long get_max_files(void)
 }
 EXPORT_SYMBOL_GPL(get_max_files);
 
+#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
+
 /*
  * Handle nr_files sysctl
  */
-#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
-int proc_nr_files(struct ctl_table *table, int write,
-                     void *buffer, size_t *lenp, loff_t *ppos)
+static int proc_nr_files(struct ctl_table *table, int write, void *buffer,
+			 size_t *lenp, loff_t *ppos)
 {
 	files_stat.nr_files = get_nr_files();
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
-#else
-int proc_nr_files(struct ctl_table *table, int write,
-                     void *buffer, size_t *lenp, loff_t *ppos)
+
+static struct ctl_table fs_stat_sysctls[] = {
+	{
+		.procname	= "file-nr",
+		.data		= &files_stat,
+		.maxlen		= sizeof(files_stat),
+		.mode		= 0444,
+		.proc_handler	= proc_nr_files,
+	},
+	{
+		.procname	= "file-max",
+		.data		= &files_stat.max_files,
+		.maxlen		= sizeof(files_stat.max_files),
+		.mode		= 0644,
+		.proc_handler	= proc_doulongvec_minmax,
+		.extra1		= SYSCTL_LONG_ZERO,
+		.extra2		= SYSCTL_LONG_MAX,
+	},
+	{
+		.procname	= "nr_open",
+		.data		= &sysctl_nr_open,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &sysctl_nr_open_min,
+		.extra2		= &sysctl_nr_open_max,
+	},
+	{ }
+};
+
+static int __init init_fs_stat_sysctls(void)
 {
-	return -ENOSYS;
+	register_sysctl_init("fs", fs_stat_sysctls);
+	return 0;
 }
+fs_initcall(init_fs_stat_sysctls);
 #endif
 
 static struct file *__alloc_file(int flags, const struct cred *cred)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 667c291b53c5..adb74ecaf686 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -78,7 +78,6 @@ extern void __init inode_init_early(void);
 extern void __init files_init(void);
 extern void __init files_maxfiles_init(void);
 
-extern struct files_stat_struct files_stat;
 extern unsigned long get_max_files(void);
 extern unsigned int sysctl_nr_open;
 extern int leases_enable, lease_break_time;
@@ -3591,8 +3590,6 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 
 struct ctl_table;
-int proc_nr_files(struct ctl_table *table, int write,
-		  void *buffer, size_t *lenp, loff_t *ppos);
 int proc_nr_dentry(struct ctl_table *table, int write,
 		  void *buffer, size_t *lenp, loff_t *ppos);
 int __init list_bdev_fs_names(char *buf, size_t size);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 3eb71bf91b71..a94d24595fa3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2900,31 +2900,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "file-nr",
-		.data		= &files_stat,
-		.maxlen		= sizeof(files_stat),
-		.mode		= 0444,
-		.proc_handler	= proc_nr_files,
-	},
-	{
-		.procname	= "file-max",
-		.data		= &files_stat.max_files,
-		.maxlen		= sizeof(files_stat.max_files),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-		.extra1		= SYSCTL_LONG_ZERO,
-		.extra2		= SYSCTL_LONG_MAX,
-	},
-	{
-		.procname	= "nr_open",
-		.data		= &sysctl_nr_open,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= &sysctl_nr_open_min,
-		.extra2		= &sysctl_nr_open_max,
-	},
 	{
 		.procname	= "dentry-state",
 		.data		= &dentry_stat,
-- 
2.33.0


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

* [PATCH 3/9] fs: move dcache sysctls to its own file
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 1/9] fs: move inode sysctls to its own file Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 2/9] fs: move fs stat sysctls to file_table.c Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const Luis Chamberlain
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move the dcache sysctl clutter out of kernel/sysctl.c.
This is a small one-off entry, perhaps later we can simplify
this representation, but for now we use the helpers we have.
We won't know how we can simplify this further untl we're
fully done with the cleanup.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/dcache.c            | 32 +++++++++++++++++++++++++++++---
 include/linux/dcache.h | 10 ----------
 include/linux/fs.h     |  2 --
 kernel/sysctl.c        |  7 -------
 4 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index cf871a81f4fd..0eef1102f460 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -115,9 +115,17 @@ static inline struct hlist_bl_head *in_lookup_hash(const struct dentry *parent,
 	return in_lookup_hashtable + hash_32(hash, IN_LOOKUP_SHIFT);
 }
 
+struct dentry_stat_t {
+	long nr_dentry;
+	long nr_unused;
+	long age_limit;		/* age in seconds */
+	long want_pages;	/* pages requested by system */
+	long nr_negative;	/* # of unused negative dentries */
+	long dummy;		/* Reserved for future use */
+};
 
 /* Statistics gathering. */
-struct dentry_stat_t dentry_stat = {
+static struct dentry_stat_t dentry_stat = {
 	.age_limit = 45,
 };
 
@@ -167,14 +175,32 @@ static long get_nr_dentry_negative(void)
 	return sum < 0 ? 0 : sum;
 }
 
-int proc_nr_dentry(struct ctl_table *table, int write, void *buffer,
-		   size_t *lenp, loff_t *ppos)
+static int proc_nr_dentry(struct ctl_table *table, int write, void *buffer,
+			  size_t *lenp, loff_t *ppos)
 {
 	dentry_stat.nr_dentry = get_nr_dentry();
 	dentry_stat.nr_unused = get_nr_dentry_unused();
 	dentry_stat.nr_negative = get_nr_dentry_negative();
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
+
+static struct ctl_table fs_dcache_sysctls[] = {
+	{
+		.procname	= "dentry-state",
+		.data		= &dentry_stat,
+		.maxlen		= 6*sizeof(long),
+		.mode		= 0444,
+		.proc_handler	= proc_nr_dentry,
+	},
+	{ }
+};
+
+static int __init init_fs_dcache_sysctls(void)
+{
+	register_sysctl_init("fs", fs_dcache_sysctls);
+	return 0;
+}
+fs_initcall(init_fs_dcache_sysctls);
 #endif
 
 /*
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 9e23d33bb6f1..f5bba51480b2 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -61,16 +61,6 @@ extern const struct qstr empty_name;
 extern const struct qstr slash_name;
 extern const struct qstr dotdot_name;
 
-struct dentry_stat_t {
-	long nr_dentry;
-	long nr_unused;
-	long age_limit;		/* age in seconds */
-	long want_pages;	/* pages requested by system */
-	long nr_negative;	/* # of unused negative dentries */
-	long dummy;		/* Reserved for future use */
-};
-extern struct dentry_stat_t dentry_stat;
-
 /*
  * Try to keep struct dentry aligned on 64 byte cachelines (this will
  * give reasonable cacheline footprint with larger lines without the
diff --git a/include/linux/fs.h b/include/linux/fs.h
index adb74ecaf686..edec0692f943 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3590,8 +3590,6 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 
 struct ctl_table;
-int proc_nr_dentry(struct ctl_table *table, int write,
-		  void *buffer, size_t *lenp, loff_t *ppos);
 int __init list_bdev_fs_names(char *buf, size_t size);
 
 #define __FMODE_EXEC		((__force int) FMODE_EXEC)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index a94d24595fa3..dbd267d0f014 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2900,13 +2900,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "dentry-state",
-		.data		= &dentry_stat,
-		.maxlen		= 6*sizeof(long),
-		.mode		= 0444,
-		.proc_handler	= proc_nr_dentry,
-	},
 	{
 		.procname	= "overflowuid",
 		.data		= &fs_overflowuid,
-- 
2.33.0


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

* [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (2 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 3/9] fs: move dcache sysctls to its own file Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-12-17 16:15   ` Mickaël Salaün
  2021-11-29 20:55 ` [PATCH 5/9] fs: move shared sysctls to fs/sysctls.c Luis Chamberlain
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The maxolduid value is only shared for sysctl purposes for
use on a max range. Just stuff this into our shared const
array.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/proc/proc_sysctl.c  |  2 +-
 include/linux/sysctl.h |  3 +++
 kernel/sysctl.c        | 12 ++++--------
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 7dec3d5a9ed4..675b625fa898 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
 static const struct inode_operations proc_sys_dir_operations;
 
 /* shared constants to be used in various sysctls */
-const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
+const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
 EXPORT_SYMBOL(sysctl_vals);
 
 const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 2de6d20d191b..bb921eb8a02d 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -49,6 +49,9 @@ struct ctl_dir;
 #define SYSCTL_THREE_THOUSAND		((void *)&sysctl_vals[8])
 #define SYSCTL_INT_MAX			((void *)&sysctl_vals[9])
 
+/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
+#define SYSCTL_MAXOLDUID		((void *)&sysctl_vals[10])
+
 extern const int sysctl_vals[];
 
 #define SYSCTL_LONG_ZERO	((void *)&sysctl_long_vals[0])
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index dbd267d0f014..05d9dd85e17f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -109,10 +109,6 @@ static const int six_hundred_forty_kb = 640 * 1024;
 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
 
-/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
-static const int maxolduid = 65535;
-/* minolduid is SYSCTL_ZERO */
-
 static const int ngroups_max = NGROUPS_MAX;
 static const int cap_last_cap = CAP_LAST_CAP;
 
@@ -2126,7 +2122,7 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= (void *)&maxolduid,
+		.extra2		= SYSCTL_MAXOLDUID,
 	},
 	{
 		.procname	= "overflowgid",
@@ -2135,7 +2131,7 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= (void *)&maxolduid,
+		.extra2		= SYSCTL_MAXOLDUID,
 	},
 #ifdef CONFIG_S390
 	{
@@ -2907,7 +2903,7 @@ static struct ctl_table fs_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= (void *)&maxolduid,
+		.extra2		= SYSCTL_MAXOLDUID,
 	},
 	{
 		.procname	= "overflowgid",
@@ -2916,7 +2912,7 @@ static struct ctl_table fs_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
-		.extra2		= (void *)&maxolduid,
+		.extra2		= SYSCTL_MAXOLDUID,
 	},
 #ifdef CONFIG_FILE_LOCKING
 	{
-- 
2.33.0


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

* [PATCH 5/9] fs: move shared sysctls to fs/sysctls.c
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (3 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 6/9] fs: move locking sysctls where they are used Luis Chamberlain
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move sysctls which are shared between filesystems into a common
file outside of kernel/sysctl.c.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/Makefile     |  1 +
 fs/sysctls.c    | 38 ++++++++++++++++++++++++++++++++++++++
 kernel/sysctl.c | 18 ------------------
 3 files changed, 39 insertions(+), 18 deletions(-)
 create mode 100644 fs/sysctls.c

diff --git a/fs/Makefile b/fs/Makefile
index 84c5e4cdfee5..ea8770d124da 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -28,6 +28,7 @@ obj-y				+= notify/
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-y				+= anon_inodes.o
 obj-$(CONFIG_SIGNALFD)		+= signalfd.o
+obj-$(CONFIG_SYSCTL)		+= sysctls.o
 obj-$(CONFIG_TIMERFD)		+= timerfd.o
 obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_USERFAULTFD)	+= userfaultfd.o
diff --git a/fs/sysctls.c b/fs/sysctls.c
new file mode 100644
index 000000000000..54216cd1ecd7
--- /dev/null
+++ b/fs/sysctls.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * /proc/sys/fs shared sysctls
+ *
+ * These sysctls are shared between different filesystems.
+ */
+#include <linux/init.h>
+#include <linux/sysctl.h>
+
+static struct ctl_table fs_shared_sysctls[] = {
+	{
+		.procname	= "overflowuid",
+		.data		= &fs_overflowuid,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_MAXOLDUID,
+	},
+	{
+		.procname	= "overflowgid",
+		.data		= &fs_overflowgid,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_MAXOLDUID,
+	},
+	{ }
+};
+
+static int __init init_fs_shared_sysctls(void)
+{
+	register_sysctl_init("fs", fs_shared_sysctls);
+	return 0;
+}
+
+early_initcall(init_fs_shared_sysctls);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 05d9dd85e17f..865173cefcef 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2896,24 +2896,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "overflowuid",
-		.data		= &fs_overflowuid,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_MAXOLDUID,
-	},
-	{
-		.procname	= "overflowgid",
-		.data		= &fs_overflowgid,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_MAXOLDUID,
-	},
 #ifdef CONFIG_FILE_LOCKING
 	{
 		.procname	= "leases-enable",
-- 
2.33.0


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

* [PATCH 6/9] fs: move locking sysctls where they are used
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (4 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 5/9] fs: move shared sysctls to fs/sysctls.c Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 7/9] fs: move namei sysctls to its own file Luis Chamberlain
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

The locking fs sysctls are only used on fs/locks.c, so move
them there.
---
 fs/locks.c         | 34 ++++++++++++++++++++++++++++++++--
 include/linux/fs.h |  4 ----
 kernel/sysctl.c    | 20 --------------------
 3 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 0fca9d680978..8c6df10cd9ed 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -62,6 +62,7 @@
 #include <linux/pid_namespace.h>
 #include <linux/hashtable.h>
 #include <linux/percpu.h>
+#include <linux/sysctl.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/filelock.h>
@@ -88,8 +89,37 @@ static int target_leasetype(struct file_lock *fl)
 	return fl->fl_type;
 }
 
-int leases_enable = 1;
-int lease_break_time = 45;
+static int leases_enable = 1;
+static int lease_break_time = 45;
+
+#ifdef CONFIG_SYSCTL
+static struct ctl_table locks_sysctls[] = {
+	{
+		.procname	= "leases-enable",
+		.data		= &leases_enable,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+#ifdef CONFIG_MMU
+	{
+		.procname	= "lease-break-time",
+		.data		= &lease_break_time,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+#endif /* CONFIG_MMU */
+	{}
+};
+
+static int __init init_fs_locks_sysctls(void)
+{
+	register_sysctl_init("fs", locks_sysctls);
+	return 0;
+}
+early_initcall(init_fs_locks_sysctls);
+#endif /* CONFIG_SYSCTL */
 
 /*
  * The global file_lock_list is only used for displaying /proc/locks, so we
diff --git a/include/linux/fs.h b/include/linux/fs.h
index edec0692f943..9ff634184f58 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -81,10 +81,6 @@ extern void __init files_maxfiles_init(void);
 extern unsigned long get_max_files(void);
 extern unsigned int sysctl_nr_open;
 extern int leases_enable, lease_break_time;
-extern int sysctl_protected_symlinks;
-extern int sysctl_protected_hardlinks;
-extern int sysctl_protected_fifos;
-extern int sysctl_protected_regular;
 
 typedef __kernel_rwf_t rwf_t;
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 865173cefcef..52a86746ac9d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2896,26 +2896,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-#ifdef CONFIG_FILE_LOCKING
-	{
-		.procname	= "leases-enable",
-		.data		= &leases_enable,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
-#ifdef CONFIG_MMU
-#ifdef CONFIG_FILE_LOCKING
-	{
-		.procname	= "lease-break-time",
-		.data		= &lease_break_time,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
-#endif
 	{
 		.procname	= "protected_symlinks",
 		.data		= &sysctl_protected_symlinks,
-- 
2.33.0


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

* [PATCH 7/9] fs: move namei sysctls to its own file
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (5 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 6/9] fs: move locking sysctls where they are used Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 8/9] fs: move fs/exec.c sysctls into " Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 9/9] fs: move pipe sysctls to is " Luis Chamberlain
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move namei's own sysctl knobs to its own file.

Other than the move we also avoid initializing two static
variables to 0 as this is not needed:

  * sysctl_protected_symlinks
  * sysctl_protected_hardlinks

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/namei.c         | 58 ++++++++++++++++++++++++++++++++++++++++++----
 include/linux/fs.h |  1 -
 kernel/sysctl.c    | 36 ----------------------------
 3 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 1f9d2187c765..8d4f832f94aa 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1020,10 +1020,60 @@ static inline void put_link(struct nameidata *nd)
 		path_put(&last->link);
 }
 
-int sysctl_protected_symlinks __read_mostly = 0;
-int sysctl_protected_hardlinks __read_mostly = 0;
-int sysctl_protected_fifos __read_mostly;
-int sysctl_protected_regular __read_mostly;
+static int sysctl_protected_symlinks __read_mostly;
+static int sysctl_protected_hardlinks __read_mostly;
+static int sysctl_protected_fifos __read_mostly;
+static int sysctl_protected_regular __read_mostly;
+
+#ifdef CONFIG_SYSCTL
+static struct ctl_table namei_sysctls[] = {
+	{
+		.procname	= "protected_symlinks",
+		.data		= &sysctl_protected_symlinks,
+		.maxlen		= sizeof(int),
+		.mode		= 0600,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
+	},
+	{
+		.procname	= "protected_hardlinks",
+		.data		= &sysctl_protected_hardlinks,
+		.maxlen		= sizeof(int),
+		.mode		= 0600,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
+	},
+	{
+		.procname	= "protected_fifos",
+		.data		= &sysctl_protected_fifos,
+		.maxlen		= sizeof(int),
+		.mode		= 0600,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_TWO,
+	},
+	{
+		.procname	= "protected_regular",
+		.data		= &sysctl_protected_regular,
+		.maxlen		= sizeof(int),
+		.mode		= 0600,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_TWO,
+	},
+	{ }
+};
+
+static int __init init_fs_namei_sysctls(void)
+{
+	register_sysctl_init("fs", namei_sysctls);
+	return 0;
+}
+fs_initcall(init_fs_namei_sysctls);
+
+#endif /* CONFIG_SYSCTL */
 
 /**
  * may_follow_link - Check symlink following for unsafe situations
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9ff634184f58..233b5ab38fe0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -80,7 +80,6 @@ extern void __init files_maxfiles_init(void);
 
 extern unsigned long get_max_files(void);
 extern unsigned int sysctl_nr_open;
-extern int leases_enable, lease_break_time;
 
 typedef __kernel_rwf_t rwf_t;
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 52a86746ac9d..39ba8e09ce31 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2896,42 +2896,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "protected_symlinks",
-		.data		= &sysctl_protected_symlinks,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE,
-	},
-	{
-		.procname	= "protected_hardlinks",
-		.data		= &sysctl_protected_hardlinks,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE,
-	},
-	{
-		.procname	= "protected_fifos",
-		.data		= &sysctl_protected_fifos,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_TWO,
-	},
-	{
-		.procname	= "protected_regular",
-		.data		= &sysctl_protected_regular,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_TWO,
-	},
 	{
 		.procname	= "suid_dumpable",
 		.data		= &suid_dumpable,
-- 
2.33.0


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

* [PATCH 8/9] fs: move fs/exec.c sysctls into its own file
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (6 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 7/9] fs: move namei sysctls to its own file Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  2021-11-29 20:55 ` [PATCH 9/9] fs: move pipe sysctls to is " Luis Chamberlain
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move the fs/exec.c respective sysctls to its own file.

Since checkpatch complains about style issues with the old
code, this move also fixes a few of those minor style issues:

  * Use pr_warn() instead of prink(WARNING
  * New empty lines are wanted at the beginning of routines

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/exec.c       | 90 +++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sysctl.c | 66 ------------------------------------
 2 files changed, 90 insertions(+), 66 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index fa142638b191..3fd2866edec3 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -65,6 +65,7 @@
 #include <linux/vmalloc.h>
 #include <linux/io_uring.h>
 #include <linux/syscall_user_dispatch.h>
+#include <linux/coredump.h>
 
 #include <linux/uaccess.h>
 #include <asm/mmu_context.h>
@@ -2097,3 +2098,92 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
 				  argv, envp, flags);
 }
 #endif
+
+#ifdef CONFIG_SYSCTL
+
+static void validate_coredump_safety(void)
+{
+#ifdef CONFIG_COREDUMP
+	if (suid_dumpable == SUID_DUMP_ROOT &&
+	    core_pattern[0] != '/' && core_pattern[0] != '|') {
+		pr_warn(
+"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
+"Pipe handler or fully qualified core dump path required.\n"
+"Set kernel.core_pattern before fs.suid_dumpable.\n"
+		);
+	}
+#endif
+}
+
+static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
+		void *buffer, size_t *lenp, loff_t *ppos)
+{
+	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+
+	if (!error)
+		validate_coredump_safety();
+	return error;
+}
+
+static struct ctl_table fs_exec_sysctls[] = {
+	{
+		.procname	= "suid_dumpable",
+		.data		= &suid_dumpable,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax_coredump,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_TWO,
+	},
+	{ }
+};
+
+#ifdef CONFIG_COREDUMP
+
+static int proc_dostring_coredump(struct ctl_table *table, int write,
+		  void *buffer, size_t *lenp, loff_t *ppos)
+{
+	int error = proc_dostring(table, write, buffer, lenp, ppos);
+
+	if (!error)
+		validate_coredump_safety();
+	return error;
+}
+
+static struct ctl_table kernel_exec_sysctls[] = {
+	{
+		.procname	= "core_uses_pid",
+		.data		= &core_uses_pid,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "core_pattern",
+		.data		= core_pattern,
+		.maxlen		= CORENAME_MAX_SIZE,
+		.mode		= 0644,
+		.proc_handler	= proc_dostring_coredump,
+	},
+	{
+		.procname	= "core_pipe_limit",
+		.data		= &core_pipe_limit,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{ }
+};
+#endif
+
+static int __init init_fs_exec_sysctls(void)
+{
+	register_sysctl_init("fs", fs_exec_sysctls);
+#ifdef CONFIG_COREDUMP
+	register_sysctl_init("kernel", kernel_exec_sysctls);
+#endif
+	return 0;
+}
+
+fs_initcall(init_fs_exec_sysctls);
+#endif /* CONFIG_SYSCTL */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 39ba8e09ce31..0146fc549978 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1116,40 +1116,6 @@ static int proc_dopipe_max_size(struct ctl_table *table, int write,
 				 do_proc_dopipe_max_size_conv, NULL);
 }
 
-static void validate_coredump_safety(void)
-{
-#ifdef CONFIG_COREDUMP
-	if (suid_dumpable == SUID_DUMP_ROOT &&
-	    core_pattern[0] != '/' && core_pattern[0] != '|') {
-		printk(KERN_WARNING
-"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
-"Pipe handler or fully qualified core dump path required.\n"
-"Set kernel.core_pattern before fs.suid_dumpable.\n"
-		);
-	}
-#endif
-}
-
-static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos)
-{
-	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
-	if (!error)
-		validate_coredump_safety();
-	return error;
-}
-
-#ifdef CONFIG_COREDUMP
-static int proc_dostring_coredump(struct ctl_table *table, int write,
-		  void *buffer, size_t *lenp, loff_t *ppos)
-{
-	int error = proc_dostring(table, write, buffer, lenp, ppos);
-	if (!error)
-		validate_coredump_safety();
-	return error;
-}
-#endif
-
 #ifdef CONFIG_MAGIC_SYSRQ
 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
 				void *buffer, size_t *lenp, loff_t *ppos)
@@ -1873,29 +1839,6 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-#ifdef CONFIG_COREDUMP
-	{
-		.procname	= "core_uses_pid",
-		.data		= &core_uses_pid,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "core_pattern",
-		.data		= core_pattern,
-		.maxlen		= CORENAME_MAX_SIZE,
-		.mode		= 0644,
-		.proc_handler	= proc_dostring_coredump,
-	},
-	{
-		.procname	= "core_pipe_limit",
-		.data		= &core_pipe_limit,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #ifdef CONFIG_PROC_SYSCTL
 	{
 		.procname	= "tainted",
@@ -2896,15 +2839,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "suid_dumpable",
-		.data		= &suid_dumpable,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax_coredump,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_TWO,
-	},
 	{
 		.procname	= "pipe-max-size",
 		.data		= &pipe_max_size,
-- 
2.33.0


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

* [PATCH 9/9] fs: move pipe sysctls to is own file
  2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
                   ` (7 preceding siblings ...)
  2021-11-29 20:55 ` [PATCH 8/9] fs: move fs/exec.c sysctls into " Luis Chamberlain
@ 2021-11-29 20:55 ` Luis Chamberlain
  8 siblings, 0 replies; 14+ messages in thread
From: Luis Chamberlain @ 2021-11-29 20:55 UTC (permalink / raw)
  To: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	mcgrof, mcgrof, andriy.shevchenko, jlayton, bfields
  Cc: linux-fsdevel, linux-kernel

The kernel/sysctl.c is a kitchen sink where everyone leaves
their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to
places where they actually belong. The proc sysctl maintainers
do not want to know what sysctl knobs you wish to add for your own
piece of code, we just care about the core logic.

So move the pipe sysctls to its own file.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/pipe.c                 | 64 +++++++++++++++++++++++++++++++++++++--
 include/linux/pipe_fs_i.h |  4 ---
 include/linux/sysctl.h    |  6 ++++
 kernel/sysctl.c           | 61 ++++---------------------------------
 4 files changed, 73 insertions(+), 62 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index 6d4342bad9f1..cc28623a67b6 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -25,6 +25,7 @@
 #include <linux/fcntl.h>
 #include <linux/memcontrol.h>
 #include <linux/watch_queue.h>
+#include <linux/sysctl.h>
 
 #include <linux/uaccess.h>
 #include <asm/ioctls.h>
@@ -50,13 +51,13 @@
  * The max size that a non-root user is allowed to grow the pipe. Can
  * be set by root in /proc/sys/fs/pipe-max-size
  */
-unsigned int pipe_max_size = 1048576;
+static unsigned int pipe_max_size = 1048576;
 
 /* Maximum allocatable pages per user. Hard limit is unset by default, soft
  * matches default values.
  */
-unsigned long pipe_user_pages_hard;
-unsigned long pipe_user_pages_soft = PIPE_DEF_BUFFERS * INR_OPEN_CUR;
+static unsigned long pipe_user_pages_hard;
+static unsigned long pipe_user_pages_soft = PIPE_DEF_BUFFERS * INR_OPEN_CUR;
 
 /*
  * We use head and tail indices that aren't masked off, except at the point of
@@ -1428,6 +1429,60 @@ static struct file_system_type pipe_fs_type = {
 	.kill_sb	= kill_anon_super,
 };
 
+#ifdef CONFIG_SYSCTL
+static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
+					unsigned int *valp,
+					int write, void *data)
+{
+	if (write) {
+		unsigned int val;
+
+		val = round_pipe_size(*lvalp);
+		if (val == 0)
+			return -EINVAL;
+
+		*valp = val;
+	} else {
+		unsigned int val = *valp;
+		*lvalp = (unsigned long) val;
+	}
+
+	return 0;
+}
+
+static int proc_dopipe_max_size(struct ctl_table *table, int write,
+				void *buffer, size_t *lenp, loff_t *ppos)
+{
+	return do_proc_douintvec(table, write, buffer, lenp, ppos,
+				 do_proc_dopipe_max_size_conv, NULL);
+}
+
+static struct ctl_table fs_pipe_sysctls[] = {
+	{
+		.procname	= "pipe-max-size",
+		.data		= &pipe_max_size,
+		.maxlen		= sizeof(pipe_max_size),
+		.mode		= 0644,
+		.proc_handler	= proc_dopipe_max_size,
+	},
+	{
+		.procname	= "pipe-user-pages-hard",
+		.data		= &pipe_user_pages_hard,
+		.maxlen		= sizeof(pipe_user_pages_hard),
+		.mode		= 0644,
+		.proc_handler	= proc_doulongvec_minmax,
+	},
+	{
+		.procname	= "pipe-user-pages-soft",
+		.data		= &pipe_user_pages_soft,
+		.maxlen		= sizeof(pipe_user_pages_soft),
+		.mode		= 0644,
+		.proc_handler	= proc_doulongvec_minmax,
+	},
+	{ }
+};
+#endif
+
 static int __init init_pipe_fs(void)
 {
 	int err = register_filesystem(&pipe_fs_type);
@@ -1439,6 +1494,9 @@ static int __init init_pipe_fs(void)
 			unregister_filesystem(&pipe_fs_type);
 		}
 	}
+#ifdef CONFIG_SYSCTL
+	register_sysctl_init("fs", fs_pipe_sysctls);
+#endif
 	return err;
 }
 
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index fc5642431b92..c00c618ef290 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -238,10 +238,6 @@ void pipe_lock(struct pipe_inode_info *);
 void pipe_unlock(struct pipe_inode_info *);
 void pipe_double_lock(struct pipe_inode_info *, struct pipe_inode_info *);
 
-extern unsigned int pipe_max_size;
-extern unsigned long pipe_user_pages_hard;
-extern unsigned long pipe_user_pages_soft;
-
 /* Wait for a pipe to be readable/writable while dropping the pipe lock */
 void pipe_wait_readable(struct pipe_inode_info *);
 void pipe_wait_writable(struct pipe_inode_info *);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index bb921eb8a02d..4294e9668bd5 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -221,6 +221,12 @@ extern void __register_sysctl_init(const char *path, struct ctl_table *table,
 extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
 
 void do_sysctl_args(void);
+int do_proc_douintvec(struct ctl_table *table, int write,
+		      void *buffer, size_t *lenp, loff_t *ppos,
+		      int (*conv)(unsigned long *lvalp,
+				  unsigned int *valp,
+				  int write, void *data),
+		      void *data);
 
 extern int pwrsw_enabled;
 extern int unaligned_enabled;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 0146fc549978..a4cde441635d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -56,7 +56,6 @@
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
 #include <linux/kprobes.h>
-#include <linux/pipe_fs_i.h>
 #include <linux/oom.h>
 #include <linux/kmod.h>
 #include <linux/capability.h>
@@ -760,12 +759,12 @@ static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
 }
 
-static int do_proc_douintvec(struct ctl_table *table, int write,
-			     void *buffer, size_t *lenp, loff_t *ppos,
-			     int (*conv)(unsigned long *lvalp,
-					 unsigned int *valp,
-					 int write, void *data),
-			     void *data)
+int do_proc_douintvec(struct ctl_table *table, int write,
+		      void *buffer, size_t *lenp, loff_t *ppos,
+		      int (*conv)(unsigned long *lvalp,
+				  unsigned int *valp,
+				  int write, void *data),
+		      void *data)
 {
 	return __do_proc_douintvec(table->data, table, write,
 				   buffer, lenp, ppos, conv, data);
@@ -1089,33 +1088,6 @@ int proc_dou8vec_minmax(struct ctl_table *table, int write,
 }
 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
 
-static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
-					unsigned int *valp,
-					int write, void *data)
-{
-	if (write) {
-		unsigned int val;
-
-		val = round_pipe_size(*lvalp);
-		if (val == 0)
-			return -EINVAL;
-
-		*valp = val;
-	} else {
-		unsigned int val = *valp;
-		*lvalp = (unsigned long) val;
-	}
-
-	return 0;
-}
-
-static int proc_dopipe_max_size(struct ctl_table *table, int write,
-				void *buffer, size_t *lenp, loff_t *ppos)
-{
-	return do_proc_douintvec(table, write, buffer, lenp, ppos,
-				 do_proc_dopipe_max_size_conv, NULL);
-}
-
 #ifdef CONFIG_MAGIC_SYSRQ
 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
 				void *buffer, size_t *lenp, loff_t *ppos)
@@ -2839,27 +2811,6 @@ static struct ctl_table vm_table[] = {
 };
 
 static struct ctl_table fs_table[] = {
-	{
-		.procname	= "pipe-max-size",
-		.data		= &pipe_max_size,
-		.maxlen		= sizeof(pipe_max_size),
-		.mode		= 0644,
-		.proc_handler	= proc_dopipe_max_size,
-	},
-	{
-		.procname	= "pipe-user-pages-hard",
-		.data		= &pipe_user_pages_hard,
-		.maxlen		= sizeof(pipe_user_pages_hard),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-	{
-		.procname	= "pipe-user-pages-soft",
-		.data		= &pipe_user_pages_soft,
-		.maxlen		= sizeof(pipe_user_pages_soft),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
 	{
 		.procname	= "mount-max",
 		.data		= &sysctl_mount_max,
-- 
2.33.0


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

* Re: [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const
  2021-11-29 20:55 ` [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const Luis Chamberlain
@ 2021-12-17 16:15   ` Mickaël Salaün
  2021-12-20 19:25     ` Luis Chamberlain
  0 siblings, 1 reply; 14+ messages in thread
From: Mickaël Salaün @ 2021-12-17 16:15 UTC (permalink / raw)
  To: Luis Chamberlain, akpm, viro, keescook, yzaikin, nixiaoming,
	ebiederm, steve, mcgrof, andriy.shevchenko, jlayton, bfields,
	Stephen Rothwell
  Cc: linux-fsdevel, linux-kernel

This patch introduces a bug in -next:

On 29/11/2021 21:55, Luis Chamberlain wrote:
> The maxolduid value is only shared for sysctl purposes for
> use on a max range. Just stuff this into our shared const
> array.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>   fs/proc/proc_sysctl.c  |  2 +-
>   include/linux/sysctl.h |  3 +++
>   kernel/sysctl.c        | 12 ++++--------
>   3 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 7dec3d5a9ed4..675b625fa898 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
>   static const struct inode_operations proc_sys_dir_operations;
>   
>   /* shared constants to be used in various sysctls */
> -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
> +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };

The new SYSCTL_MAXOLDUID uses the index 10 of sysctl_vals[] but the same
commit replaces index 8 (SYSCTL_THREE_THOUSAND used by
vm.watermark_scale_factor) instead of adding a new entry.

It should be:
+const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, 
INT_MAX, 65535 };



>   EXPORT_SYMBOL(sysctl_vals);
>   
>   const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> index 2de6d20d191b..bb921eb8a02d 100644
> --- a/include/linux/sysctl.h
> +++ b/include/linux/sysctl.h
> @@ -49,6 +49,9 @@ struct ctl_dir;
>   #define SYSCTL_THREE_THOUSAND		((void *)&sysctl_vals[8])
>   #define SYSCTL_INT_MAX			((void *)&sysctl_vals[9])
>   
> +/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
> +#define SYSCTL_MAXOLDUID		((void *)&sysctl_vals[10])
> +
>   extern const int sysctl_vals[];
>   
>   #define SYSCTL_LONG_ZERO	((void *)&sysctl_long_vals[0])
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index dbd267d0f014..05d9dd85e17f 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -109,10 +109,6 @@ static const int six_hundred_forty_kb = 640 * 1024;
>   /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
>   static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
>   
> -/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
> -static const int maxolduid = 65535;
> -/* minolduid is SYSCTL_ZERO */
> -
>   static const int ngroups_max = NGROUPS_MAX;
>   static const int cap_last_cap = CAP_LAST_CAP;
>   
> @@ -2126,7 +2122,7 @@ static struct ctl_table kern_table[] = {
>   		.mode		= 0644,
>   		.proc_handler	= proc_dointvec_minmax,
>   		.extra1		= SYSCTL_ZERO,
> -		.extra2		= (void *)&maxolduid,
> +		.extra2		= SYSCTL_MAXOLDUID,
>   	},
>   	{
>   		.procname	= "overflowgid",
> @@ -2135,7 +2131,7 @@ static struct ctl_table kern_table[] = {
>   		.mode		= 0644,
>   		.proc_handler	= proc_dointvec_minmax,
>   		.extra1		= SYSCTL_ZERO,
> -		.extra2		= (void *)&maxolduid,
> +		.extra2		= SYSCTL_MAXOLDUID,
>   	},
>   #ifdef CONFIG_S390
>   	{
> @@ -2907,7 +2903,7 @@ static struct ctl_table fs_table[] = {
>   		.mode		= 0644,
>   		.proc_handler	= proc_dointvec_minmax,
>   		.extra1		= SYSCTL_ZERO,
> -		.extra2		= (void *)&maxolduid,
> +		.extra2		= SYSCTL_MAXOLDUID,
>   	},
>   	{
>   		.procname	= "overflowgid",
> @@ -2916,7 +2912,7 @@ static struct ctl_table fs_table[] = {
>   		.mode		= 0644,
>   		.proc_handler	= proc_dointvec_minmax,
>   		.extra1		= SYSCTL_ZERO,
> -		.extra2		= (void *)&maxolduid,
> +		.extra2		= SYSCTL_MAXOLDUID,
>   	},
>   #ifdef CONFIG_FILE_LOCKING
>   	{
> 

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

* Re: [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const
  2021-12-17 16:15   ` Mickaël Salaün
@ 2021-12-20 19:25     ` Luis Chamberlain
  2021-12-30  0:46       ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Luis Chamberlain @ 2021-12-20 19:25 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: akpm, viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	andriy.shevchenko, jlayton, bfields, Stephen Rothwell,
	linux-fsdevel, linux-kernel

On Fri, Dec 17, 2021 at 05:15:01PM +0100, Mickaël Salaün wrote:
> > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > index 7dec3d5a9ed4..675b625fa898 100644
> > --- a/fs/proc/proc_sysctl.c
> > +++ b/fs/proc/proc_sysctl.c
> > @@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
> >   static const struct inode_operations proc_sys_dir_operations;
> >   /* shared constants to be used in various sysctls */
> > -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
> > +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
> 
> The new SYSCTL_MAXOLDUID uses the index 10 of sysctl_vals[] but the same
> commit replaces index 8 (SYSCTL_THREE_THOUSAND used by
> vm.watermark_scale_factor) instead of adding a new entry.
> 
> It should be:
> +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX,
> 65535 };

Can you send a proper patch which properly fixes this and identifies
the commit name with a Fixes tag. Since thi sis on Andrew's tree no
commit ID is required given that they are ephemeral.

  Luis

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

* Re: [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const
  2021-12-20 19:25     ` Luis Chamberlain
@ 2021-12-30  0:46       ` Andrew Morton
  2021-12-30 11:24         ` Mickaël Salaün
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2021-12-30  0:46 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: Mickaël Salaün, viro, keescook, yzaikin, nixiaoming,
	ebiederm, steve, andriy.shevchenko, jlayton, bfields,
	Stephen Rothwell, linux-fsdevel, linux-kernel

On Mon, 20 Dec 2021 11:25:41 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:

> On Fri, Dec 17, 2021 at 05:15:01PM +0100, Mickaël Salaün wrote:
> > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > > index 7dec3d5a9ed4..675b625fa898 100644
> > > --- a/fs/proc/proc_sysctl.c
> > > +++ b/fs/proc/proc_sysctl.c
> > > @@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
> > >   static const struct inode_operations proc_sys_dir_operations;
> > >   /* shared constants to be used in various sysctls */
> > > -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
> > > +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
> > 
> > The new SYSCTL_MAXOLDUID uses the index 10 of sysctl_vals[] but the same
> > commit replaces index 8 (SYSCTL_THREE_THOUSAND used by
> > vm.watermark_scale_factor) instead of adding a new entry.
> > 
> > It should be:
> > +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX,
> > 65535 };
> 
> Can you send a proper patch which properly fixes this and identifies
> the commit name with a Fixes tag. Since thi sis on Andrew's tree no
> commit ID is required given that they are ephemeral.

I did this:

From: Andrew Morton <akpm@linux-foundation.org>
Subject: sysctl-move-maxolduid-as-a-sysctl-specific-const-fix

fix sysctl_vals[], per Mickaël.

Cc: Mickaël Salaün <mic@digikonet>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Lukas Middendorf <kernel@tuxforce.de>
Cc: Stephen Kitt <steve@sk2.org>
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/proc_sysctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/proc/proc_sysctl.c~sysctl-move-maxolduid-as-a-sysctl-specific-const-fix
+++ a/fs/proc/proc_sysctl.c
@@ -26,7 +26,7 @@ static const struct file_operations proc
 static const struct inode_operations proc_sys_dir_operations;
 
 /* shared constants to be used in various sysctls */
-const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
+const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX, 65535 };
 EXPORT_SYMBOL(sysctl_vals);
 
 const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
_


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

* Re: [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const
  2021-12-30  0:46       ` Andrew Morton
@ 2021-12-30 11:24         ` Mickaël Salaün
  0 siblings, 0 replies; 14+ messages in thread
From: Mickaël Salaün @ 2021-12-30 11:24 UTC (permalink / raw)
  To: Andrew Morton, Luis Chamberlain
  Cc: viro, keescook, yzaikin, nixiaoming, ebiederm, steve,
	andriy.shevchenko, jlayton, bfields, Stephen Rothwell,
	linux-fsdevel, linux-kernel



On 30/12/2021 01:46, Andrew Morton wrote:
> On Mon, 20 Dec 2021 11:25:41 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:
> 
>> On Fri, Dec 17, 2021 at 05:15:01PM +0100, Mickaël Salaün wrote:
>>>> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
>>>> index 7dec3d5a9ed4..675b625fa898 100644
>>>> --- a/fs/proc/proc_sysctl.c
>>>> +++ b/fs/proc/proc_sysctl.c
>>>> @@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
>>>>    static const struct inode_operations proc_sys_dir_operations;
>>>>    /* shared constants to be used in various sysctls */
>>>> -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
>>>> +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
>>>
>>> The new SYSCTL_MAXOLDUID uses the index 10 of sysctl_vals[] but the same
>>> commit replaces index 8 (SYSCTL_THREE_THOUSAND used by
>>> vm.watermark_scale_factor) instead of adding a new entry.
>>>
>>> It should be:
>>> +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX,
>>> 65535 };
>>
>> Can you send a proper patch which properly fixes this and identifies
>> the commit name with a Fixes tag. Since thi sis on Andrew's tree no
>> commit ID is required given that they are ephemeral.
> 
> I did this:
> 
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: sysctl-move-maxolduid-as-a-sysctl-specific-const-fix
> 
> fix sysctl_vals[], per Mickaël.
> 
> Cc: Mickaël Salaün <mic@digikonet>

Except a typo in my email

Signed-off-by: Mickaël Salaün <mic@digikod.net>

Thanks!

> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Antti Palosaari <crope@iki.fi>
> Cc: Eric Biederman <ebiederm@xmission.com>
> Cc: Iurii Zaikin <yzaikin@google.com>
> Cc: "J. Bruce Fields" <bfields@fieldses.org>
> Cc: Jeff Layton <jlayton@kernel.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Lukas Middendorf <kernel@tuxforce.de>
> Cc: Stephen Kitt <steve@sk2.org>
> Cc: Xiaoming Ni <nixiaoming@huawei.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>   fs/proc/proc_sysctl.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/fs/proc/proc_sysctl.c~sysctl-move-maxolduid-as-a-sysctl-specific-const-fix
> +++ a/fs/proc/proc_sysctl.c
> @@ -26,7 +26,7 @@ static const struct file_operations proc
>   static const struct inode_operations proc_sys_dir_operations;
>   
>   /* shared constants to be used in various sysctls */
> -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 65535, INT_MAX };
> +const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX, 65535 };
>   EXPORT_SYMBOL(sysctl_vals);
>   
>   const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
> _
> 

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

end of thread, other threads:[~2021-12-30 11:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 20:55 [PATCH 0/9] sysctl: 4th set of kernel/sysctl cleanups Luis Chamberlain
2021-11-29 20:55 ` [PATCH 1/9] fs: move inode sysctls to its own file Luis Chamberlain
2021-11-29 20:55 ` [PATCH 2/9] fs: move fs stat sysctls to file_table.c Luis Chamberlain
2021-11-29 20:55 ` [PATCH 3/9] fs: move dcache sysctls to its own file Luis Chamberlain
2021-11-29 20:55 ` [PATCH 4/9] sysctl: move maxolduid as a sysctl specific const Luis Chamberlain
2021-12-17 16:15   ` Mickaël Salaün
2021-12-20 19:25     ` Luis Chamberlain
2021-12-30  0:46       ` Andrew Morton
2021-12-30 11:24         ` Mickaël Salaün
2021-11-29 20:55 ` [PATCH 5/9] fs: move shared sysctls to fs/sysctls.c Luis Chamberlain
2021-11-29 20:55 ` [PATCH 6/9] fs: move locking sysctls where they are used Luis Chamberlain
2021-11-29 20:55 ` [PATCH 7/9] fs: move namei sysctls to its own file Luis Chamberlain
2021-11-29 20:55 ` [PATCH 8/9] fs: move fs/exec.c sysctls into " Luis Chamberlain
2021-11-29 20:55 ` [PATCH 9/9] fs: move pipe sysctls to is " Luis Chamberlain

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.