lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230518160705.3888592-2-j.granados@samsung.com>
Date:   Thu, 18 May 2023 18:07:04 +0200
From:   Joel Granados <j.granados@...sung.com>
To:     <mcgrof@...nel.org>
CC:     Alexander Viro <viro@...iv.linux.org.uk>,
        <linux-kernel@...r.kernel.org>, Iurii Zaikin <yzaikin@...gle.com>,
        Sudip Mukherjee <sudipm.mukherjee@...il.com>,
        Christian Brauner <brauner@...nel.org>,
        <linux-fsdevel@...r.kernel.org>, Kees Cook <keescook@...omium.org>,
        "Joel Granados" <j.granados@...sung.com>
Subject: [PATCH 1/2] sysctl: Refactor base paths registrations

This is part of the general push to deprecate register_sysctl_paths and
register_sysctl_table. The old way of doing this through
register_sysctl_base and DECLARE_SYSCTL_BASE macro is replaced with a
call to register_sysctl. The 5 base paths affected are: "kernel", "vm",
"debug", "dev" and "fs".

We remove the register_sysctl_base function and the DECLARE_SYSCTL_BASE
macro since they are no longer needed.

In order to quickly acertain that the paths did not actually change I
executed `find /proc/sys/ | sha1sum` and made sure that the sha was the
same before and after the commit.

Signed-off-by: Joel Granados <j.granados@...sung.com>
---
 fs/sysctls.c           |  9 ++++++---
 include/linux/sysctl.h | 23 -----------------------
 kernel/sysctl.c        | 13 ++++---------
 3 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/fs/sysctls.c b/fs/sysctls.c
index c701273c9432..228420f5fe1b 100644
--- a/fs/sysctls.c
+++ b/fs/sysctls.c
@@ -29,11 +29,14 @@ static struct ctl_table fs_shared_sysctls[] = {
 	{ }
 };
 
-DECLARE_SYSCTL_BASE(fs, fs_shared_sysctls);
-
 static int __init init_fs_sysctls(void)
 {
-	return register_sysctl_base(fs);
+	/*
+	 * We do not check the return code for register_sysctl because the
+	 * original call to register_sysctl_base always returned 0.
+	 */
+	register_sysctl("fs", fs_shared_sysctls);
+	return 0;
 }
 
 early_initcall(init_fs_sysctls);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 218e56a26fb0..653b66c762b1 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -197,20 +197,6 @@ struct ctl_path {
 
 #ifdef CONFIG_SYSCTL
 
-#define DECLARE_SYSCTL_BASE(_name, _table)				\
-static struct ctl_table _name##_base_table[] = {			\
-	{								\
-		.procname	= #_name,				\
-		.mode		= 0555,					\
-		.child		= _table,				\
-	},								\
-	{ },								\
-}
-
-extern int __register_sysctl_base(struct ctl_table *base_table);
-
-#define register_sysctl_base(_name) __register_sysctl_base(_name##_base_table)
-
 void proc_sys_poll_notify(struct ctl_table_poll *poll);
 
 extern void setup_sysctl_set(struct ctl_table_set *p,
@@ -247,15 +233,6 @@ extern struct ctl_table sysctl_mount_point[];
 
 #else /* CONFIG_SYSCTL */
 
-#define DECLARE_SYSCTL_BASE(_name, _table)
-
-static inline int __register_sysctl_base(struct ctl_table *base_table)
-{
-	return 0;
-}
-
-#define register_sysctl_base(table) __register_sysctl_base(table)
-
 static inline void register_sysctl_init(const char *path, struct ctl_table *table)
 {
 }
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bfe53e835524..f784b0fe5689 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2348,17 +2348,12 @@ static struct ctl_table dev_table[] = {
 	{ }
 };
 
-DECLARE_SYSCTL_BASE(kernel, kern_table);
-DECLARE_SYSCTL_BASE(vm, vm_table);
-DECLARE_SYSCTL_BASE(debug, debug_table);
-DECLARE_SYSCTL_BASE(dev, dev_table);
-
 int __init sysctl_init_bases(void)
 {
-	register_sysctl_base(kernel);
-	register_sysctl_base(vm);
-	register_sysctl_base(debug);
-	register_sysctl_base(dev);
+	register_sysctl("kernel", kern_table);
+	register_sysctl("vm", vm_table);
+	register_sysctl("debug", debug_table);
+	register_sysctl("dev", dev_table);
 
 	return 0;
 }
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ