* [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch)
@ 2025-05-09 12:54 Joel Granados
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
` (11 more replies)
0 siblings, 12 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
This series relocates sysctl tables from kern_table to their respective
subsystems. It is mostly moves to core kernel subsystems but also
includes mm/memory.c and 2 drivers (parisc and tty). With this series we
are left with 8 ctl_tables out of the original 50 that existed within
the kern_table array. With all this activity in kernel/sysctl.c, I took
the liberty of removing unneeded include headers as well as outdated
changelog comments.
By decentralizing sysctl registrations, subsystem maintainers regain
control over their sysctl interfaces, improving maintainability and
reducing the likelihood of merge conflicts. All this is made possible by
the work done to reduce the ctl_table memory footprint in commit
d7a76ec87195 ("sysctl: Remove check for sentinel element in ctl_table
arrays").
A few comments on the process:
1. If you see that the change is good and want to push it through a tree
different than sysctl, please tell me so I can remove it from this
series and try to avoid conflicts in linux-next.
2. Apologies if you have received this in error. Please tell me if you
want to be removed from recipient list and note that it is difficult
to actually know who is interested in these "treewide" changes.
Testing done by running sysctl selftests on x86_64 and 0-day.
You can find the first batch here [1], if you are curious.
Comments are greatly appreciated
[1] https://lore.kernel.org/20250313-jag-mv_ctltables-v3-0-91f3bb434d27@kernel.org
To: Luis Chamberlain <mcgrof@kernel.org>
To: Petr Pavlu <petr.pavlu@suse.com>
To: Sami Tolvanen <samitolvanen@google.com>
To: Daniel Gomez <da.gomez@samsung.com>
To: Kees Cook <kees@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@redhat.com>
To: Will Deacon <will@kernel.org>
To: Boqun Feng <boqun.feng@gmail.com>
To: Waiman Long <longman@redhat.com>
To: Paul E. McKenney <paulmck@kernel.org>
To: Frederic Weisbecker <frederic@kernel.org>
To: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
To: Joel Fernandes <joel@joelfernandes.org>
To: Josh Triplett <josh@joshtriplett.org>
To: Uladzislau Rezki <urezki@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Lai Jiangshan <jiangshanlai@gmail.com>
To: Zqiang <qiang.zhang1211@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
To: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
To: Helge Deller <deller@gmx.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: linux-modules@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: rcu@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-serial@vger.kernel.org
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
Joel Granados (12):
module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
locking/rtmutex: Move max_lock_depth into rtmutex.c
rcu: Move rcu_stall related sysctls into rcu/tree_stall.h
mm: move randomize_va_space into memory.c
parisc/power: Move soft-power into power.c
fork: mv threads-max into kernel/fork.c
Input: sysrq: mv sysrq into drivers/tty/sysrq.c
sysctl: Move tainted ctl_table into kernel/panic.c
sysctl: move cad_pid into kernel/pid.c
sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c
sysctl: Remove (very) old file changelog
sysctl: Remove superfluous includes from kernel/sysctl.c
drivers/parisc/power.c | 20 +++-
drivers/tty/sysrq.c | 38 +++++++
include/linux/kmod.h | 1 -
include/linux/panic.h | 2 -
include/linux/rtmutex.h | 2 -
include/linux/sysctl.h | 4 -
kernel/fork.c | 20 +++-
kernel/locking/rtmutex.c | 23 +++++
kernel/locking/rtmutex_api.c | 5 -
kernel/module/kmod.c | 32 +++++-
kernel/panic.c | 60 +++++++++++
kernel/pid.c | 32 ++++++
kernel/rcu/tree_stall.h | 33 +++++-
kernel/sysctl.c | 233 -------------------------------------------
mm/memory.c | 18 ++++
15 files changed, 271 insertions(+), 252 deletions(-)
---
base-commit: 7a94ff386a4a0d9322c56c0e998dd20468d869b1
change-id: 20250509-jag-mv_ctltables_iter2-9a176a322c9d
Best regards,
--
Joel Granados <joel.granados@kernel.org>
^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:09 ` Luis Chamberlain
2025-05-15 8:04 ` Petr Pavlu
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
` (10 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
and into the modules subsystem. Make the modprobe_path variable static
as it no longer needs to be exported. Remove module.h from the includes
in sysctl as it no longer uses any module exported variables.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
include/linux/kmod.h | 1 -
kernel/module/kmod.c | 32 +++++++++++++++++++++++++++++++-
kernel/sysctl.c | 20 --------------------
3 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 68f69362d427caaaefc2565127a7a4158433e5f5..cc32e56dae44896f74a9faf0e97f432f133869b9 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -17,7 +17,6 @@
#define KMOD_PATH_LEN 256
#ifdef CONFIG_MODULES
-extern char modprobe_path[]; /* for sysctl */
/* modprobe exit status on success, -ve on error. Return value
* usually useless though. */
extern __printf(2, 3)
diff --git a/kernel/module/kmod.c b/kernel/module/kmod.c
index 25f25381251281a390b273cd8a734c92b960113a..5701629adc27b4bb5080db75f0e69f9f55e9d2ad 100644
--- a/kernel/module/kmod.c
+++ b/kernel/module/kmod.c
@@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
/*
modprobe_path is set via /proc/sys.
*/
-char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
+static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
static void free_modprobe_argv(struct subprocess_info *info)
{
@@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
return ret;
}
EXPORT_SYMBOL(__request_module);
+
+#ifdef CONFIG_MODULES
+static const struct ctl_table kmod_sysctl_table[] = {
+ {
+ .procname = "modprobe",
+ .data = &modprobe_path,
+ .maxlen = KMOD_PATH_LEN,
+ .mode = 0644,
+ .proc_handler = proc_dostring,
+ },
+ {
+ .procname = "modules_disabled",
+ .data = &modules_disabled,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ /* only handle a transition from default "0" to "1" */
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_ONE,
+ },
+};
+
+static int __init init_kmod_sysctl(void)
+{
+ register_sysctl_init("kernel", kmod_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_kmod_sysctl);
+#endif
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9b4f0cff76eaddc823065ea587760156576a8686..473133d9651eac4ef44b8b63a44b77189818ac08 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -19,7 +19,6 @@
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
*/
-#include <linux/module.h>
#include <linux/sysctl.h>
#include <linux/bitmap.h>
#include <linux/printk.h>
@@ -1616,25 +1615,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#ifdef CONFIG_MODULES
- {
- .procname = "modprobe",
- .data = &modprobe_path,
- .maxlen = KMOD_PATH_LEN,
- .mode = 0644,
- .proc_handler = proc_dostring,
- },
- {
- .procname = "modules_disabled",
- .data = &modules_disabled,
- .maxlen = sizeof(int),
- .mode = 0644,
- /* only handle a transition from default "0" to "1" */
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ONE,
- .extra2 = SYSCTL_ONE,
- },
-#endif
#ifdef CONFIG_UEVENT_HELPER
{
.procname = "hotplug",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 15:49 ` Waiman Long
2025-05-09 18:56 ` Kees Cook
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
` (9 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move the max_lock_depth sysctl table element and variable into
rtmutex.c. Make the variable static as it no longer needs to be
exported. Removed the rtmutex.h include from sysctl.c.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
include/linux/rtmutex.h | 2 --
kernel/locking/rtmutex.c | 23 +++++++++++++++++++++++
kernel/locking/rtmutex_api.c | 5 -----
kernel/sysctl.c | 12 ------------
4 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 7d049883a08ace049384d70b4c97e3f4fb0e46f8..dc9a51cda97cdb6ac8e12be5209071744101b703 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -18,8 +18,6 @@
#include <linux/rbtree_types.h>
#include <linux/spinlock_types_raw.h>
-extern int max_lock_depth; /* for sysctl */
-
struct rt_mutex_base {
raw_spinlock_t wait_lock;
struct rb_root_cached waiters;
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index c80902eacd797c669dedcf10966a8cff38524b50..705a0e0fd72ab8da051e4227a5b89cb3d1539524 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -29,6 +29,29 @@
#include "rtmutex_common.h"
#include "lock_events.h"
+/*
+ * Max number of times we'll walk the boosting chain:
+ */
+static int max_lock_depth = 1024;
+
+static const struct ctl_table rtmutex_sysctl_table[] = {
+ {
+ .procname = "max_lock_depth",
+ .data = &max_lock_depth,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+};
+
+static int __init init_rtmutex_sysctl(void)
+{
+ register_sysctl_init("kernel", rtmutex_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_rtmutex_sysctl);
+
#ifndef WW_RT
# define build_ww_mutex() (false)
# define ww_container_of(rtm) NULL
diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c
index 191e4720e546627aed0d7ec715673b1b8753b130..2b5da8af206da6ee72df1234a4db94f5c4f6f882 100644
--- a/kernel/locking/rtmutex_api.c
+++ b/kernel/locking/rtmutex_api.c
@@ -8,11 +8,6 @@
#define RT_MUTEX_BUILD_MUTEX
#include "rtmutex.c"
-/*
- * Max number of times we'll walk the boosting chain:
- */
-int max_lock_depth = 1024;
-
/*
* Debug aware fast / slowpath lock,trylock,unlock
*
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 473133d9651eac4ef44b8b63a44b77189818ac08..a22f35013da0d838ef421fc5d192f00d1e70fb0f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -59,9 +59,6 @@
#include <asm/nmi.h>
#include <asm/io.h>
#endif
-#ifdef CONFIG_RT_MUTEXES
-#include <linux/rtmutex.h>
-#endif
/* shared constants to be used in various sysctls */
const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
@@ -1709,15 +1706,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#ifdef CONFIG_RT_MUTEXES
- {
- .procname = "max_lock_depth",
- .data = &max_lock_depth,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- },
-#endif
#ifdef CONFIG_TREE_RCU
{
.procname = "panic_on_rcu_stall",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 13:14 ` Joel Fernandes
` (2 more replies)
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
` (8 subsequent siblings)
11 siblings, 3 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move sysctl_panic_on_rcu_stall and sysctl_max_rcu_stall_to_panic into
the kernel/rcu subdirectory. Make these static in tree_stall.h and
removed them as extern from panic.h as their scope is now confined into
one file.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
include/linux/panic.h | 2 --
kernel/rcu/tree_stall.h | 33 +++++++++++++++++++++++++++++++--
kernel/sysctl.c | 20 --------------------
3 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 2494d51707ef422dfe191e484c0676e428a2de09..33ecead16b7c1af46aac07fb10b88beed5074b18 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -27,8 +27,6 @@ extern int panic_on_warn;
extern unsigned long panic_on_taint;
extern bool panic_on_taint_nousertaint;
-extern int sysctl_panic_on_rcu_stall;
-extern int sysctl_max_rcu_stall_to_panic;
extern int sysctl_panic_on_stackoverflow;
extern bool crash_kexec_post_notifiers;
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 925fcdad5dea22cfc8b0648546b78870cee485a6..5a0009b7e30b5a057856a3544f841712625699ce 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -17,8 +17,37 @@
// Controlling CPU stall warnings, including delay calculation.
/* panic() on RCU Stall sysctl. */
-int sysctl_panic_on_rcu_stall __read_mostly;
-int sysctl_max_rcu_stall_to_panic __read_mostly;
+static int sysctl_panic_on_rcu_stall __read_mostly;
+static int sysctl_max_rcu_stall_to_panic __read_mostly;
+
+static const struct ctl_table rcu_stall_sysctl_table[] = {
+ {
+ .procname = "panic_on_rcu_stall",
+ .data = &sysctl_panic_on_rcu_stall,
+ .maxlen = sizeof(sysctl_panic_on_rcu_stall),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+ {
+ .procname = "max_rcu_stall_to_panic",
+ .data = &sysctl_max_rcu_stall_to_panic,
+ .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_INT_MAX,
+ },
+};
+
+static int __init init_rcu_stall_sysctl(void)
+{
+ register_sysctl_init("kernel", rcu_stall_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_rcu_stall_sysctl);
#ifdef CONFIG_PROVE_RCU
#define RCU_STALL_DELAY_DELTA (5 * HZ)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index a22f35013da0d838ef421fc5d192f00d1e70fb0f..fd76f0e1d490940a67d72403d72d204ff13d888a 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1706,26 +1706,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#ifdef CONFIG_TREE_RCU
- {
- .procname = "panic_on_rcu_stall",
- .data = &sysctl_panic_on_rcu_stall,
- .maxlen = sizeof(sysctl_panic_on_rcu_stall),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
- {
- .procname = "max_rcu_stall_to_panic",
- .data = &sysctl_max_rcu_stall_to_panic,
- .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ONE,
- .extra2 = SYSCTL_INT_MAX,
- },
-#endif
};
int __init sysctl_init_bases(void)
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 04/12] mm: move randomize_va_space into memory.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (2 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:16 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
` (7 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move the randomize_va_space variable together with all its sysctl table
elements into memory.c. Register it to the "kernel" directory by
adding it to the subsys initialization calls
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/sysctl.c | 9 ---------
mm/memory.c | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index fd76f0e1d490940a67d72403d72d204ff13d888a..adc2d3ea127841d87b7073ed81d6121c9a60e59a 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1688,15 +1688,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#if defined(CONFIG_MMU)
- {
- .procname = "randomize_va_space",
- .data = &randomize_va_space,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- },
-#endif
#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
{
.procname = "ignore-unaligned-usertrap",
diff --git a/mm/memory.c b/mm/memory.c
index ba3ea0a82f7f770b6cacba4526ba9c8c4929ddad..0a9e325fe3d7631e619ab58d79785cc92fd60c29 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -125,6 +125,24 @@ int randomize_va_space __read_mostly =
2;
#endif
+static const struct ctl_table mmu_sysctl_table[] = {
+ {
+ .procname = "randomize_va_space",
+ .data = &randomize_va_space,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+};
+
+static int __init init_mm_sysctl(void)
+{
+ register_sysctl_init("kernel", mmu_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_mm_sysctl);
+
#ifndef arch_wants_old_prefaulted_pte
static inline bool arch_wants_old_prefaulted_pte(void)
{
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 05/12] parisc/power: Move soft-power into power.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (3 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:15 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
` (6 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move the soft-power ctl table into parisc/power.c. As a consequence the
pwrsw_enabled var is made static.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
drivers/parisc/power.c | 20 +++++++++++++++++++-
include/linux/sysctl.h | 1 -
kernel/sysctl.c | 9 ---------
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/parisc/power.c b/drivers/parisc/power.c
index 7a6a3e7f2825be5191e024e6c7af1cd688219b75..9d6c7bf72e2958348e263a7e82025038694ebfbc 100644
--- a/drivers/parisc/power.c
+++ b/drivers/parisc/power.c
@@ -83,7 +83,25 @@ static struct task_struct *power_task;
#define SYSCTL_FILENAME "sys/kernel/power"
/* soft power switch enabled/disabled */
-int pwrsw_enabled __read_mostly = 1;
+static int pwrsw_enabled __read_mostly = 1;
+
+static const struct ctl_table power_sysctl_table[] = {
+ {
+ .procname = "soft-power",
+ .data = &pwrsw_enabled,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+};
+
+static int __init init_power_sysctl(void)
+{
+ register_sysctl_init("kernel", power_sysctl_table);
+ return 0;
+}
+
+arch_initcall(init_power_sysctl);
/* main kernel thread worker. It polls the button state */
static int kpowerswd(void *param)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 40a6ac6c9713f3504c4dfcb4fcc77dff7dce8ca6..ae762eabb7c9715e973356cadafbaaea3f20c7e9 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -242,7 +242,6 @@ int do_proc_douintvec(const struct ctl_table *table, int write,
int write, void *data),
void *data);
-extern int pwrsw_enabled;
extern int unaligned_enabled;
extern int unaligned_dump_stack;
extern int no_unaligned_warning;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index adc2d3ea127841d87b7073ed81d6121c9a60e59a..718140251972b797f5aa5a056de40e8856805eed 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1594,15 +1594,6 @@ static const struct ctl_table kern_table[] = {
.extra2 = SYSCTL_ONE,
},
#endif
-#ifdef CONFIG_PARISC
- {
- .procname = "soft-power",
- .data = &pwrsw_enabled,
- .maxlen = sizeof (int),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- },
-#endif
#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
{
.procname = "unaligned-trap",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 06/12] fork: mv threads-max into kernel/fork.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (4 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:14 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
` (5 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
make sysctl_max_threads static as it no longer needs to be exported into
sysctl.c.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
include/linux/sysctl.h | 3 ---
kernel/fork.c | 20 +++++++++++++++++++-
kernel/sysctl.c | 7 -------
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index ae762eabb7c9715e973356cadafbaaea3f20c7e9..30bcbc59d12d2f4cec7545e7ee3f5ea5f0eefbd7 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -284,7 +284,4 @@ static inline bool sysctl_is_alias(char *param)
}
#endif /* CONFIG_SYSCTL */
-int sysctl_max_threads(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos);
-
#endif /* _LINUX_SYSCTL_H */
diff --git a/kernel/fork.c b/kernel/fork.c
index c4b26cd8998b8e7b2b516e0bb0b1d4676ff644dc..ed39064b86c25849c4b21cf99ac68dded05038b3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -3470,7 +3470,7 @@ int unshare_files(void)
return 0;
}
-int sysctl_max_threads(const struct ctl_table *table, int write,
+static int sysctl_max_threads(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table t;
@@ -3492,3 +3492,21 @@ int sysctl_max_threads(const struct ctl_table *table, int write,
return 0;
}
+
+static const struct ctl_table fork_sysctl_table[] = {
+ {
+ .procname = "threads-max",
+ .data = NULL,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysctl_max_threads,
+ },
+};
+
+static int __init init_fork_sysctl(void)
+{
+ register_sysctl_init("kernel", fork_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_fork_sysctl);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 718140251972b797f5aa5a056de40e8856805eed..febf328054aa5a7b2462a256598f86f5ded87c90 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1630,13 +1630,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_do_cad_pid,
},
#endif
- {
- .procname = "threads-max",
- .data = NULL,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = sysctl_max_threads,
- },
{
.procname = "overflowuid",
.data = &overflowuid,
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (5 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 14:47 ` Greg Kroah-Hartman
2025-05-09 17:10 ` Kees Cook
2025-05-09 12:54 ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Joel Granados
` (4 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
helper function with do_proc_dointvec as the former is local to
kernel/sysctl.c.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
drivers/tty/sysrq.c | 38 ++++++++++++++++++++++++++++++++++++++
kernel/sysctl.c | 30 ------------------------------
2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 6853c4660e7c2586487fea83c12f0b7780db1ee1..8a304189749f3e33af48141a1aba5e456616c7de 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -1119,6 +1119,44 @@ int sysrq_toggle_support(int enable_mask)
}
EXPORT_SYMBOL_GPL(sysrq_toggle_support);
+static int sysrq_sysctl_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
+{
+ int tmp, ret;
+ struct ctl_table t = *table;
+
+ tmp = sysrq_mask();
+ t.data = &tmp;
+
+ ret = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
+
+ if (ret || !write)
+ return ret;
+
+ if (write)
+ sysrq_toggle_support(tmp);
+
+ return 0;
+}
+
+static const struct ctl_table sysrq_sysctl_table[] = {
+ {
+ .procname = "sysrq",
+ .data = NULL,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysrq_sysctl_handler,
+ },
+};
+
+static int __init init_sysrq_sysctl(void)
+{
+ register_sysctl_init("kernel", sysrq_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_sysrq_sysctl);
+
static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p,
const struct sysrq_key_op *remove_op_p)
{
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index febf328054aa5a7b2462a256598f86f5ded87c90..ebcc7d75acd9fecbf3c10f31480c3cb6960cb53e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -31,7 +31,6 @@
#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/net.h>
-#include <linux/sysrq.h>
#include <linux/highuid.h>
#include <linux/writeback.h>
#include <linux/ratelimit.h>
@@ -964,26 +963,6 @@ int proc_dou8vec_minmax(const struct ctl_table *table, int write,
}
EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
-#ifdef CONFIG_MAGIC_SYSRQ
-static int sysrq_sysctl_handler(const struct ctl_table *table, int write,
- void *buffer, size_t *lenp, loff_t *ppos)
-{
- int tmp, ret;
-
- tmp = sysrq_mask();
-
- ret = __do_proc_dointvec(&tmp, table, write, buffer,
- lenp, ppos, NULL, NULL);
- if (ret || !write)
- return ret;
-
- if (write)
- sysrq_toggle_support(tmp);
-
- return 0;
-}
-#endif
-
static int __do_proc_doulongvec_minmax(void *data,
const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos,
@@ -1612,15 +1591,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dostring,
},
#endif
-#ifdef CONFIG_MAGIC_SYSRQ
- {
- .procname = "sysrq",
- .data = NULL,
- .maxlen = sizeof (int),
- .mode = 0644,
- .proc_handler = sysrq_sysctl_handler,
- },
-#endif
#ifdef CONFIG_PROC_SYSCTL
{
.procname = "cad_pid",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (6 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 19:00 ` Kees Cook
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
` (3 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move the ctl_table with the "tainted" proc_name into kernel/panic.c.
With it moves the proc_tainted helper function.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/panic.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
kernel/sysctl.c | 49 -------------------------------------------------
2 files changed, 50 insertions(+), 49 deletions(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index 047ea3215312c439950c6ec4674a91572146234d..213c6c9d6a750ff3d17f3cf530b37c619cd816f4 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -84,6 +84,50 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
EXPORT_SYMBOL(panic_notifier_list);
#ifdef CONFIG_SYSCTL
+
+/*
+ * Taint values can only be increased
+ * This means we can safely use a temporary.
+ */
+static int proc_taint(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table t;
+ unsigned long tmptaint = get_taint();
+ int err;
+
+ if (write && !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ t = *table;
+ t.data = &tmptaint;
+ err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
+ if (err < 0)
+ return err;
+
+ if (write) {
+ int i;
+
+ /*
+ * If we are relying on panic_on_taint not producing
+ * false positives due to userspace input, bail out
+ * before setting the requested taint flags.
+ */
+ if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
+ return -EINVAL;
+
+ /*
+ * Poor man's atomic or. Not worth adding a primitive
+ * to everyone's atomic.h for this
+ */
+ for (i = 0; i < TAINT_FLAGS_COUNT; i++)
+ if ((1UL << i) & tmptaint)
+ add_taint(i, LOCKDEP_STILL_OK);
+ }
+
+ return err;
+}
+
static const struct ctl_table kern_panic_table[] = {
#ifdef CONFIG_SMP
{
@@ -96,6 +140,12 @@ static const struct ctl_table kern_panic_table[] = {
.extra2 = SYSCTL_ONE,
},
#endif
+ {
+ .procname = "tainted",
+ .maxlen = sizeof(long),
+ .mode = 0644,
+ .proc_handler = proc_taint,
+ },
{
.procname = "panic",
.data = &panic_timeout,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ebcc7d75acd9fecbf3c10f31480c3cb6960cb53e..9d8db9cef11122993d850ab5c753e3da1cbfb5cc 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -731,49 +731,6 @@ int proc_douintvec(const struct ctl_table *table, int write, void *buffer,
do_proc_douintvec_conv, NULL);
}
-/*
- * Taint values can only be increased
- * This means we can safely use a temporary.
- */
-static int proc_taint(const struct ctl_table *table, int write,
- void *buffer, size_t *lenp, loff_t *ppos)
-{
- struct ctl_table t;
- unsigned long tmptaint = get_taint();
- int err;
-
- if (write && !capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- t = *table;
- t.data = &tmptaint;
- err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
- if (err < 0)
- return err;
-
- if (write) {
- int i;
-
- /*
- * If we are relying on panic_on_taint not producing
- * false positives due to userspace input, bail out
- * before setting the requested taint flags.
- */
- if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
- return -EINVAL;
-
- /*
- * Poor man's atomic or. Not worth adding a primitive
- * to everyone's atomic.h for this
- */
- for (i = 0; i < TAINT_FLAGS_COUNT; i++)
- if ((1UL << i) & tmptaint)
- add_taint(i, LOCKDEP_STILL_OK);
- }
-
- return err;
-}
-
/**
* struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
* @min: pointer to minimum allowable value
@@ -1557,12 +1514,6 @@ int proc_do_static_key(const struct ctl_table *table, int write,
static const struct ctl_table kern_table[] = {
#ifdef CONFIG_PROC_SYSCTL
- {
- .procname = "tainted",
- .maxlen = sizeof(long),
- .mode = 0644,
- .proc_handler = proc_taint,
- },
{
.procname = "sysctl_writes_strict",
.data = &sysctl_writes_strict,
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (7 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:13 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
2025-05-09 12:54 ` [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c Joel Granados
` (2 subsequent siblings)
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Move cad_pid as well as supporting function proc_do_cad_pid into
kernel/pic.c. Replaced call to __do_proc_dointvec with proc_dointvec
inside proc_do_cad_pid which requires the copy of the ctl_table to
handle the temp value.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/pid.c | 32 ++++++++++++++++++++++++++++++++
kernel/sysctl.c | 31 -------------------------------
2 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index 4ac2ce46817fdefff8888681bb5ca3f2676e8add..bc87ba08ae8b7c67f3457b31309b56b5d90f8c52 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -717,6 +717,29 @@ static struct ctl_table_root pid_table_root = {
.set_ownership = pid_table_root_set_ownership,
};
+static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ struct pid *new_pid;
+ pid_t tmp_pid;
+ int r;
+ struct ctl_table tmp_table = *table;
+
+ tmp_pid = pid_vnr(cad_pid);
+ tmp_table.data = &tmp_pid;
+
+ r = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
+ if (r || !write)
+ return r;
+
+ new_pid = find_get_pid(tmp_pid);
+ if (!new_pid)
+ return -ESRCH;
+
+ put_pid(xchg(&cad_pid, new_pid));
+ return 0;
+}
+
static const struct ctl_table pid_table[] = {
{
.procname = "pid_max",
@@ -727,6 +750,15 @@ static const struct ctl_table pid_table[] = {
.extra1 = &pid_max_min,
.extra2 = &pid_max_max,
},
+#ifdef CONFIG_PROC_SYSCTL
+ {
+ .procname = "cad_pid",
+ .data = NULL,
+ .maxlen = sizeof(int),
+ .mode = 0600,
+ .proc_handler = proc_do_cad_pid,
+ },
+#endif
};
#endif
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9d8db9cef11122993d850ab5c753e3da1cbfb5cc..d5bebdd02cd4f1def7d9dd2b85454a9022b600b7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1224,28 +1224,6 @@ int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write, void *buf
do_proc_dointvec_ms_jiffies_conv, NULL);
}
-static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
-{
- struct pid *new_pid;
- pid_t tmp;
- int r;
-
- tmp = pid_vnr(cad_pid);
-
- r = __do_proc_dointvec(&tmp, table, write, buffer,
- lenp, ppos, NULL, NULL);
- if (r || !write)
- return r;
-
- new_pid = find_get_pid(tmp);
- if (!new_pid)
- return -ESRCH;
-
- put_pid(xchg(&cad_pid, new_pid));
- return 0;
-}
-
/**
* proc_do_large_bitmap - read/write from/to a large bitmap
* @table: the sysctl table
@@ -1541,15 +1519,6 @@ static const struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = proc_dostring,
},
-#endif
-#ifdef CONFIG_PROC_SYSCTL
- {
- .procname = "cad_pid",
- .data = NULL,
- .maxlen = sizeof (int),
- .mode = 0600,
- .proc_handler = proc_do_cad_pid,
- },
#endif
{
.procname = "overflowuid",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (8 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 17:04 ` Kees Cook
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
11 siblings, 1 reply; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/panic.c | 10 ++++++++++
kernel/sysctl.c | 10 ----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index 213c6c9d6a750ff3d17f3cf530b37c619cd816f4..401f0997f654797acc3351040bbbda1845ce00c1 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -183,6 +183,16 @@ static const struct ctl_table kern_panic_table[] = {
.mode = 0644,
.proc_handler = proc_douintvec,
},
+#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
+ defined(CONFIG_DEBUG_STACKOVERFLOW)
+ {
+ .procname = "panic_on_stackoverflow",
+ .data = &sysctl_panic_on_stackoverflow,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+#endif
};
static __init int kernel_panic_sysctls_init(void)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d5bebdd02cd4f1def7d9dd2b85454a9022b600b7..446d77ec44f57a4929389b64fc23d3b180f550b4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1552,16 +1552,6 @@ static const struct ctl_table kern_table[] = {
.mode = 0444,
.proc_handler = proc_dointvec,
},
-#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
- defined(CONFIG_DEBUG_STACKOVERFLOW)
- {
- .procname = "panic_on_stackoverflow",
- .data = &sysctl_panic_on_stackoverflow,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- },
-#endif
#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
{
.procname = "ignore-unaligned-usertrap",
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 11/12] sysctl: Remove (very) old file changelog
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (9 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:11 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
These comments are older than 2003 and therefore do not bare any
relevance on the current state of the sysctl.c file. Remove them as they
confuse more than clarify.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/sysctl.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 446d77ec44f57a4929389b64fc23d3b180f550b4..dee9a818a9bbc8b1ecd17b8ac1ae533ce15c2029 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1,22 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* sysctl.c: General linux system control interface
- *
- * Begun 24 March 1995, Stephen Tweedie
- * Added /proc support, Dec 1995
- * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
- * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
- * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
- * Dynamic registration fixes, Stephen Tweedie.
- * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
- * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
- * Horn.
- * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
- * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
- * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
- * Wendling.
- * The list_for_each() macro wasn't appropriate for the sysctl loop.
- * Removed it and replaced it with older style, 03/23/00, Bill Wendling
*/
#include <linux/sysctl.h>
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
` (10 preceding siblings ...)
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
@ 2025-05-09 12:54 ` Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
11 siblings, 2 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-09 12:54 UTC (permalink / raw)
To: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial, Joel Granados
Remove the following headers from the include list in sysctl.c.
* These are removed as the related variables are no longer there.
=================== ====================
Include Related Var
=================== ====================
linux/kmod.h usermodehelper
asm/nmi.h nmi_watchdoc_enabled
asm/io.h io_delay_type
linux/pid.h pid_max_{,min,max}
linux/sched/sysctl.h sysctl_{sched_*,numa_*,timer_*}
linux/mount.h sysctl_mount_max
linux/reboot.h poweroff_cmd
linux/ratelimit.h {,printk_}ratelimit_state
linux/printk.h kptr_restrict
linux/security.h CONFIG_SECURITY_CAPABILITIES
linux/net.h net_table
linux/key.h key_sysctls
linux/nvs_fs.h acpi_video_flags
linux/acpi.h acpi_video_flags
linux/fs.h proc_nr_files
* These are no longer needed as intermediate includes
==============
Include
==============
linux/filter.h
linux/binfmts.h
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/sysctl.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index dee9a818a9bbc8b1ecd17b8ac1ae533ce15c2029..0716c7df7243dc38f0a49c7cae78651c3f75f5a3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -5,44 +5,24 @@
#include <linux/sysctl.h>
#include <linux/bitmap.h>
-#include <linux/printk.h>
#include <linux/proc_fs.h>
-#include <linux/security.h>
#include <linux/ctype.h>
-#include <linux/filter.h>
-#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kobject.h>
-#include <linux/net.h>
#include <linux/highuid.h>
#include <linux/writeback.h>
-#include <linux/ratelimit.h>
#include <linux/initrd.h>
-#include <linux/key.h>
#include <linux/times.h>
#include <linux/limits.h>
#include <linux/syscalls.h>
-#include <linux/nfs_fs.h>
-#include <linux/acpi.h>
-#include <linux/reboot.h>
-#include <linux/kmod.h>
#include <linux/capability.h>
-#include <linux/binfmts.h>
-#include <linux/sched/sysctl.h>
-#include <linux/mount.h>
-#include <linux/pid.h>
#include "../lib/kstrtox.h"
#include <linux/uaccess.h>
#include <asm/processor.h>
-#ifdef CONFIG_X86
-#include <asm/nmi.h>
-#include <asm/io.h>
-#endif
-
/* shared constants to be used in various sysctls */
const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
EXPORT_SYMBOL(sysctl_vals);
--
2.47.2
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
@ 2025-05-09 13:14 ` Joel Fernandes
2025-05-09 16:17 ` Luis Chamberlain
2025-05-09 19:03 ` Kees Cook
2 siblings, 0 replies; 43+ messages in thread
From: Joel Fernandes @ 2025-05-09 13:14 UTC (permalink / raw)
To: Joel Granados, Luis Chamberlain, Petr Pavlu, Sami Tolvanen,
Daniel Gomez, Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon,
Boqun Feng, Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial
On 5/9/2025 8:54 AM, Joel Granados wrote:
> Move sysctl_panic_on_rcu_stall and sysctl_max_rcu_stall_to_panic into
> the kernel/rcu subdirectory. Make these static in tree_stall.h and
> removed them as extern from panic.h as their scope is now confined into
> one file.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
For RCU:
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
thanks,
- Joel
> ---
> include/linux/panic.h | 2 --
> kernel/rcu/tree_stall.h | 33 +++++++++++++++++++++++++++++++--
> kernel/sysctl.c | 20 --------------------
> 3 files changed, 31 insertions(+), 24 deletions(-)
>
> diff --git a/include/linux/panic.h b/include/linux/panic.h
> index 2494d51707ef422dfe191e484c0676e428a2de09..33ecead16b7c1af46aac07fb10b88beed5074b18 100644
> --- a/include/linux/panic.h
> +++ b/include/linux/panic.h
> @@ -27,8 +27,6 @@ extern int panic_on_warn;
> extern unsigned long panic_on_taint;
> extern bool panic_on_taint_nousertaint;
>
> -extern int sysctl_panic_on_rcu_stall;
> -extern int sysctl_max_rcu_stall_to_panic;
> extern int sysctl_panic_on_stackoverflow;
>
> extern bool crash_kexec_post_notifiers;
> diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
> index 925fcdad5dea22cfc8b0648546b78870cee485a6..5a0009b7e30b5a057856a3544f841712625699ce 100644
> --- a/kernel/rcu/tree_stall.h
> +++ b/kernel/rcu/tree_stall.h
> @@ -17,8 +17,37 @@
> // Controlling CPU stall warnings, including delay calculation.
>
> /* panic() on RCU Stall sysctl. */
> -int sysctl_panic_on_rcu_stall __read_mostly;
> -int sysctl_max_rcu_stall_to_panic __read_mostly;
> +static int sysctl_panic_on_rcu_stall __read_mostly;
> +static int sysctl_max_rcu_stall_to_panic __read_mostly;
> +
> +static const struct ctl_table rcu_stall_sysctl_table[] = {
> + {
> + .procname = "panic_on_rcu_stall",
> + .data = &sysctl_panic_on_rcu_stall,
> + .maxlen = sizeof(sysctl_panic_on_rcu_stall),
> + .mode = 0644,
> + .proc_handler = proc_dointvec_minmax,
> + .extra1 = SYSCTL_ZERO,
> + .extra2 = SYSCTL_ONE,
> + },
> + {
> + .procname = "max_rcu_stall_to_panic",
> + .data = &sysctl_max_rcu_stall_to_panic,
> + .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
> + .mode = 0644,
> + .proc_handler = proc_dointvec_minmax,
> + .extra1 = SYSCTL_ONE,
> + .extra2 = SYSCTL_INT_MAX,
> + },
> +};
> +
> +static int __init init_rcu_stall_sysctl(void)
> +{
> + register_sysctl_init("kernel", rcu_stall_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_rcu_stall_sysctl);
>
> #ifdef CONFIG_PROVE_RCU
> #define RCU_STALL_DELAY_DELTA (5 * HZ)
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index a22f35013da0d838ef421fc5d192f00d1e70fb0f..fd76f0e1d490940a67d72403d72d204ff13d888a 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1706,26 +1706,6 @@ static const struct ctl_table kern_table[] = {
> .proc_handler = proc_dointvec,
> },
> #endif
> -#ifdef CONFIG_TREE_RCU
> - {
> - .procname = "panic_on_rcu_stall",
> - .data = &sysctl_panic_on_rcu_stall,
> - .maxlen = sizeof(sysctl_panic_on_rcu_stall),
> - .mode = 0644,
> - .proc_handler = proc_dointvec_minmax,
> - .extra1 = SYSCTL_ZERO,
> - .extra2 = SYSCTL_ONE,
> - },
> - {
> - .procname = "max_rcu_stall_to_panic",
> - .data = &sysctl_max_rcu_stall_to_panic,
> - .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
> - .mode = 0644,
> - .proc_handler = proc_dointvec_minmax,
> - .extra1 = SYSCTL_ONE,
> - .extra2 = SYSCTL_INT_MAX,
> - },
> -#endif
> };
>
> int __init sysctl_init_bases(void)
>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
@ 2025-05-09 14:47 ` Greg Kroah-Hartman
2025-05-09 17:10 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-09 14:47 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
Waiman Long, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller, Jiri Slaby,
linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:11PM +0200, Joel Granados wrote:
> Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
> function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
> helper function with do_proc_dointvec as the former is local to
> kernel/sysctl.c.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> ---
> drivers/tty/sysrq.c | 38 ++++++++++++++++++++++++++++++++++++++
> kernel/sysctl.c | 30 ------------------------------
> 2 files changed, 38 insertions(+), 30 deletions(-)
>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
@ 2025-05-09 15:49 ` Waiman Long
2025-05-09 18:56 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Waiman Long @ 2025-05-09 15:49 UTC (permalink / raw)
To: Joel Granados, Luis Chamberlain, Petr Pavlu, Sami Tolvanen,
Daniel Gomez, Kees Cook, Peter Zijlstra, Ingo Molnar, Will Deacon,
Boqun Feng, Paul E. McKenney, Frederic Weisbecker,
Neeraj Upadhyay, Joel Fernandes, Josh Triplett, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Andrew Morton, James E.J. Bottomley, Helge Deller,
Greg Kroah-Hartman, Jiri Slaby
Cc: linux-modules, linux-kernel, linux-fsdevel, rcu, linux-mm,
linux-parisc, linux-serial
On 5/9/25 8:54 AM, Joel Granados wrote:
> Move the max_lock_depth sysctl table element and variable into
> rtmutex.c. Make the variable static as it no longer needs to be
> exported. Removed the rtmutex.h include from sysctl.c.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> ---
> include/linux/rtmutex.h | 2 --
> kernel/locking/rtmutex.c | 23 +++++++++++++++++++++++
> kernel/locking/rtmutex_api.c | 5 -----
> kernel/sysctl.c | 12 ------------
> 4 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
> index 7d049883a08ace049384d70b4c97e3f4fb0e46f8..dc9a51cda97cdb6ac8e12be5209071744101b703 100644
> --- a/include/linux/rtmutex.h
> +++ b/include/linux/rtmutex.h
> @@ -18,8 +18,6 @@
> #include <linux/rbtree_types.h>
> #include <linux/spinlock_types_raw.h>
>
> -extern int max_lock_depth; /* for sysctl */
> -
> struct rt_mutex_base {
> raw_spinlock_t wait_lock;
> struct rb_root_cached waiters;
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index c80902eacd797c669dedcf10966a8cff38524b50..705a0e0fd72ab8da051e4227a5b89cb3d1539524 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -29,6 +29,29 @@
> #include "rtmutex_common.h"
> #include "lock_events.h"
>
> +/*
> + * Max number of times we'll walk the boosting chain:
> + */
> +static int max_lock_depth = 1024;
> +
> +static const struct ctl_table rtmutex_sysctl_table[] = {
> + {
> + .procname = "max_lock_depth",
> + .data = &max_lock_depth,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = proc_dointvec,
> + },
> +};
> +
> +static int __init init_rtmutex_sysctl(void)
> +{
> + register_sysctl_init("kernel", rtmutex_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_rtmutex_sysctl);
> +
> #ifndef WW_RT
> # define build_ww_mutex() (false)
> # define ww_container_of(rtm) NULL
> diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c
> index 191e4720e546627aed0d7ec715673b1b8753b130..2b5da8af206da6ee72df1234a4db94f5c4f6f882 100644
> --- a/kernel/locking/rtmutex_api.c
> +++ b/kernel/locking/rtmutex_api.c
> @@ -8,11 +8,6 @@
> #define RT_MUTEX_BUILD_MUTEX
> #include "rtmutex.c"
>
> -/*
> - * Max number of times we'll walk the boosting chain:
> - */
> -int max_lock_depth = 1024;
> -
> /*
> * Debug aware fast / slowpath lock,trylock,unlock
> *
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 473133d9651eac4ef44b8b63a44b77189818ac08..a22f35013da0d838ef421fc5d192f00d1e70fb0f 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -59,9 +59,6 @@
> #include <asm/nmi.h>
> #include <asm/io.h>
> #endif
> -#ifdef CONFIG_RT_MUTEXES
> -#include <linux/rtmutex.h>
> -#endif
>
> /* shared constants to be used in various sysctls */
> const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
> @@ -1709,15 +1706,6 @@ static const struct ctl_table kern_table[] = {
> .proc_handler = proc_dointvec,
> },
> #endif
> -#ifdef CONFIG_RT_MUTEXES
> - {
> - .procname = "max_lock_depth",
> - .data = &max_lock_depth,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - .proc_handler = proc_dointvec,
> - },
> -#endif
> #ifdef CONFIG_TREE_RCU
> {
> .procname = "panic_on_rcu_stall",
>
Acked-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
@ 2025-05-09 16:09 ` Luis Chamberlain
2025-05-13 7:37 ` Joel Granados
2025-05-15 8:04 ` Petr Pavlu
1 sibling, 1 reply; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:09 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:05PM +0200, Joel Granados wrote:
> diff --git a/kernel/module/kmod.c b/kernel/module/kmod.c
> index 25f25381251281a390b273cd8a734c92b960113a..5701629adc27b4bb5080db75f0e69f9f55e9d2ad 100644
> --- a/kernel/module/kmod.c
> +++ b/kernel/module/kmod.c
> @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
> /*
> modprobe_path is set via /proc/sys.
> */
> -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
>
> static void free_modprobe_argv(struct subprocess_info *info)
> {
> @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
> return ret;
> }
> EXPORT_SYMBOL(__request_module);
> +
> +#ifdef CONFIG_MODULES
kernel/Makefile:
obj-$(CONFIG_MODULES) += module/
And so you can drop this ifdef.
Other than that:
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 11/12] sysctl: Remove (very) old file changelog
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
@ 2025-05-09 16:11 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:11 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:15PM +0200, Joel Granados wrote:
> These comments are older than 2003 and therefore do not bare any
> relevance on the current state of the sysctl.c file. Remove them as they
> confuse more than clarify.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
@ 2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:12 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:16PM +0200, Joel Granados wrote:
> Remove the following headers from the include list in sysctl.c.
>
> * These are removed as the related variables are no longer there.
> =================== ====================
> Include Related Var
> =================== ====================
> linux/kmod.h usermodehelper
> asm/nmi.h nmi_watchdoc_enabled
> asm/io.h io_delay_type
> linux/pid.h pid_max_{,min,max}
> linux/sched/sysctl.h sysctl_{sched_*,numa_*,timer_*}
> linux/mount.h sysctl_mount_max
> linux/reboot.h poweroff_cmd
> linux/ratelimit.h {,printk_}ratelimit_state
> linux/printk.h kptr_restrict
> linux/security.h CONFIG_SECURITY_CAPABILITIES
> linux/net.h net_table
> linux/key.h key_sysctls
> linux/nvs_fs.h acpi_video_flags
> linux/acpi.h acpi_video_flags
> linux/fs.h proc_nr_files
>
> * These are no longer needed as intermediate includes
> ==============
> Include
> ==============
> linux/filter.h
> linux/binfmts.h
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c
2025-05-09 12:54 ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Joel Granados
@ 2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 19:00 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:12 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:12PM +0200, Joel Granados wrote:
> Move the ctl_table with the "tainted" proc_name into kernel/panic.c.
> With it moves the proc_tainted helper function.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
@ 2025-05-09 16:13 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:13 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:13PM +0200, Joel Granados wrote:
> Move cad_pid as well as supporting function proc_do_cad_pid into
> kernel/pic.c. Replaced call to __do_proc_dointvec with proc_dointvec
> inside proc_do_cad_pid which requires the copy of the ctl_table to
> handle the temp value.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 06/12] fork: mv threads-max into kernel/fork.c
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
@ 2025-05-09 16:14 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:14 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:10PM +0200, Joel Granados wrote:
> make sysctl_max_threads static as it no longer needs to be exported into
> sysctl.c.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 05/12] parisc/power: Move soft-power into power.c
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
@ 2025-05-09 16:15 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:15 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:09PM +0200, Joel Granados wrote:
> Move the soft-power ctl table into parisc/power.c. As a consequence the
> pwrsw_enabled var is made static.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 04/12] mm: move randomize_va_space into memory.c
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
@ 2025-05-09 16:16 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:16 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:08PM +0200, Joel Granados wrote:
> Move the randomize_va_space variable together with all its sysctl table
> elements into memory.c. Register it to the "kernel" directory by
> adding it to the subsys initialization calls
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
2025-05-09 13:14 ` Joel Fernandes
@ 2025-05-09 16:17 ` Luis Chamberlain
2025-05-09 19:03 ` Kees Cook
2 siblings, 0 replies; 43+ messages in thread
From: Luis Chamberlain @ 2025-05-09 16:17 UTC (permalink / raw)
To: Joel Granados
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:07PM +0200, Joel Granados wrote:
> Move sysctl_panic_on_rcu_stall and sysctl_max_rcu_stall_to_panic into
> the kernel/rcu subdirectory. Make these static in tree_stall.h and
> removed them as extern from panic.h as their scope is now confined into
> one file.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c
2025-05-09 12:54 ` [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c Joel Granados
@ 2025-05-09 17:04 ` Kees Cook
0 siblings, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 17:04 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:14PM +0200, Joel Granados wrote:
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Another undocumented sysctl. ;) This one should be called
"panic_on_stack_exhaustion", but so be it. :)
Reviewed-by: Kees Cook <kees@kernel.org>
> ---
> kernel/panic.c | 10 ++++++++++
> kernel/sysctl.c | 10 ----------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 213c6c9d6a750ff3d17f3cf530b37c619cd816f4..401f0997f654797acc3351040bbbda1845ce00c1 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -183,6 +183,16 @@ static const struct ctl_table kern_panic_table[] = {
> .mode = 0644,
> .proc_handler = proc_douintvec,
> },
> +#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
> + defined(CONFIG_DEBUG_STACKOVERFLOW)
> + {
> + .procname = "panic_on_stackoverflow",
> + .data = &sysctl_panic_on_stackoverflow,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = proc_dointvec,
> + },
> +#endif
> };
>
> static __init int kernel_panic_sysctls_init(void)
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index d5bebdd02cd4f1def7d9dd2b85454a9022b600b7..446d77ec44f57a4929389b64fc23d3b180f550b4 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1552,16 +1552,6 @@ static const struct ctl_table kern_table[] = {
> .mode = 0444,
> .proc_handler = proc_dointvec,
> },
> -#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
> - defined(CONFIG_DEBUG_STACKOVERFLOW)
> - {
> - .procname = "panic_on_stackoverflow",
> - .data = &sysctl_panic_on_stackoverflow,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - .proc_handler = proc_dointvec,
> - },
> -#endif
> #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
> {
> .procname = "ignore-unaligned-usertrap",
>
> --
> 2.47.2
>
>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
2025-05-09 14:47 ` Greg Kroah-Hartman
@ 2025-05-09 17:10 ` Kees Cook
2025-05-13 7:49 ` Joel Granados
1 sibling, 1 reply; 43+ messages in thread
From: Kees Cook @ 2025-05-09 17:10 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:11PM +0200, Joel Granados wrote:
> Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
> function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
> helper function with do_proc_dointvec as the former is local to
> kernel/sysctl.c.
nit: do_proc_dointvec_minmax
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
But yes, this looks correct.
Reviewed-by: Kees Cook <kees@kernel.org>
-Kees
> ---
> drivers/tty/sysrq.c | 38 ++++++++++++++++++++++++++++++++++++++
> kernel/sysctl.c | 30 ------------------------------
> 2 files changed, 38 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index 6853c4660e7c2586487fea83c12f0b7780db1ee1..8a304189749f3e33af48141a1aba5e456616c7de 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -1119,6 +1119,44 @@ int sysrq_toggle_support(int enable_mask)
> }
> EXPORT_SYMBOL_GPL(sysrq_toggle_support);
>
> +static int sysrq_sysctl_handler(const struct ctl_table *table, int write,
> + void *buffer, size_t *lenp, loff_t *ppos)
> +{
> + int tmp, ret;
> + struct ctl_table t = *table;
> +
> + tmp = sysrq_mask();
> + t.data = &tmp;
> +
> + ret = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
> +
> + if (ret || !write)
> + return ret;
> +
> + if (write)
> + sysrq_toggle_support(tmp);
> +
> + return 0;
> +}
> +
> +static const struct ctl_table sysrq_sysctl_table[] = {
> + {
> + .procname = "sysrq",
> + .data = NULL,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = sysrq_sysctl_handler,
> + },
> +};
> +
> +static int __init init_sysrq_sysctl(void)
> +{
> + register_sysctl_init("kernel", sysrq_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_sysrq_sysctl);
> +
> static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p,
> const struct sysrq_key_op *remove_op_p)
> {
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index febf328054aa5a7b2462a256598f86f5ded87c90..ebcc7d75acd9fecbf3c10f31480c3cb6960cb53e 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -31,7 +31,6 @@
> #include <linux/kernel.h>
> #include <linux/kobject.h>
> #include <linux/net.h>
> -#include <linux/sysrq.h>
> #include <linux/highuid.h>
> #include <linux/writeback.h>
> #include <linux/ratelimit.h>
> @@ -964,26 +963,6 @@ int proc_dou8vec_minmax(const struct ctl_table *table, int write,
> }
> EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
>
> -#ifdef CONFIG_MAGIC_SYSRQ
> -static int sysrq_sysctl_handler(const struct ctl_table *table, int write,
> - void *buffer, size_t *lenp, loff_t *ppos)
> -{
> - int tmp, ret;
> -
> - tmp = sysrq_mask();
> -
> - ret = __do_proc_dointvec(&tmp, table, write, buffer,
> - lenp, ppos, NULL, NULL);
> - if (ret || !write)
> - return ret;
> -
> - if (write)
> - sysrq_toggle_support(tmp);
> -
> - return 0;
> -}
> -#endif
> -
> static int __do_proc_doulongvec_minmax(void *data,
> const struct ctl_table *table, int write,
> void *buffer, size_t *lenp, loff_t *ppos,
> @@ -1612,15 +1591,6 @@ static const struct ctl_table kern_table[] = {
> .proc_handler = proc_dostring,
> },
> #endif
> -#ifdef CONFIG_MAGIC_SYSRQ
> - {
> - .procname = "sysrq",
> - .data = NULL,
> - .maxlen = sizeof (int),
> - .mode = 0644,
> - .proc_handler = sysrq_sysctl_handler,
> - },
> -#endif
> #ifdef CONFIG_PROC_SYSCTL
> {
> .procname = "cad_pid",
>
> --
> 2.47.2
>
>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
2025-05-09 15:49 ` Waiman Long
@ 2025-05-09 18:56 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 18:56 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:06PM +0200, Joel Granados wrote:
> Move the max_lock_depth sysctl table element and variable into
> rtmutex.c. Make the variable static as it no longer needs to be
> exported. Removed the rtmutex.h include from sysctl.c.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Yup, all looks good, including the variable relocation.
Reviewed-by: Kees Cook <kees@kernel.org>
> ---
> include/linux/rtmutex.h | 2 --
> kernel/locking/rtmutex.c | 23 +++++++++++++++++++++++
> kernel/locking/rtmutex_api.c | 5 -----
> kernel/sysctl.c | 12 ------------
> 4 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
> index 7d049883a08ace049384d70b4c97e3f4fb0e46f8..dc9a51cda97cdb6ac8e12be5209071744101b703 100644
> --- a/include/linux/rtmutex.h
> +++ b/include/linux/rtmutex.h
> @@ -18,8 +18,6 @@
> #include <linux/rbtree_types.h>
> #include <linux/spinlock_types_raw.h>
>
> -extern int max_lock_depth; /* for sysctl */
> -
> struct rt_mutex_base {
> raw_spinlock_t wait_lock;
> struct rb_root_cached waiters;
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index c80902eacd797c669dedcf10966a8cff38524b50..705a0e0fd72ab8da051e4227a5b89cb3d1539524 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -29,6 +29,29 @@
> #include "rtmutex_common.h"
> #include "lock_events.h"
>
> +/*
> + * Max number of times we'll walk the boosting chain:
> + */
> +static int max_lock_depth = 1024;
> +
> +static const struct ctl_table rtmutex_sysctl_table[] = {
> + {
> + .procname = "max_lock_depth",
> + .data = &max_lock_depth,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = proc_dointvec,
> + },
> +};
> +
> +static int __init init_rtmutex_sysctl(void)
> +{
> + register_sysctl_init("kernel", rtmutex_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_rtmutex_sysctl);
> +
> #ifndef WW_RT
> # define build_ww_mutex() (false)
> # define ww_container_of(rtm) NULL
> diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c
> index 191e4720e546627aed0d7ec715673b1b8753b130..2b5da8af206da6ee72df1234a4db94f5c4f6f882 100644
> --- a/kernel/locking/rtmutex_api.c
> +++ b/kernel/locking/rtmutex_api.c
> @@ -8,11 +8,6 @@
> #define RT_MUTEX_BUILD_MUTEX
> #include "rtmutex.c"
>
> -/*
> - * Max number of times we'll walk the boosting chain:
> - */
> -int max_lock_depth = 1024;
> -
> /*
> * Debug aware fast / slowpath lock,trylock,unlock
> *
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 473133d9651eac4ef44b8b63a44b77189818ac08..a22f35013da0d838ef421fc5d192f00d1e70fb0f 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -59,9 +59,6 @@
> #include <asm/nmi.h>
> #include <asm/io.h>
> #endif
> -#ifdef CONFIG_RT_MUTEXES
> -#include <linux/rtmutex.h>
> -#endif
>
> /* shared constants to be used in various sysctls */
> const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
> @@ -1709,15 +1706,6 @@ static const struct ctl_table kern_table[] = {
> .proc_handler = proc_dointvec,
> },
> #endif
> -#ifdef CONFIG_RT_MUTEXES
> - {
> - .procname = "max_lock_depth",
> - .data = &max_lock_depth,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - .proc_handler = proc_dointvec,
> - },
> -#endif
> #ifdef CONFIG_TREE_RCU
> {
> .procname = "panic_on_rcu_stall",
>
> --
> 2.47.2
>
>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 11/12] sysctl: Remove (very) old file changelog
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
2025-05-09 16:11 ` Luis Chamberlain
@ 2025-05-09 18:57 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 18:57 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:15PM +0200, Joel Granados wrote:
> These comments are older than 2003 and therefore do not bare any
> relevance on the current state of the sysctl.c file. Remove them as they
> confuse more than clarify.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
@ 2025-05-09 18:57 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 18:57 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:16PM +0200, Joel Granados wrote:
> Remove the following headers from the include list in sysctl.c.
>
> * These are removed as the related variables are no longer there.
> =================== ====================
> Include Related Var
> =================== ====================
> linux/kmod.h usermodehelper
> asm/nmi.h nmi_watchdoc_enabled
> asm/io.h io_delay_type
> linux/pid.h pid_max_{,min,max}
> linux/sched/sysctl.h sysctl_{sched_*,numa_*,timer_*}
> linux/mount.h sysctl_mount_max
> linux/reboot.h poweroff_cmd
> linux/ratelimit.h {,printk_}ratelimit_state
> linux/printk.h kptr_restrict
> linux/security.h CONFIG_SECURITY_CAPABILITIES
> linux/net.h net_table
> linux/key.h key_sysctls
> linux/nvs_fs.h acpi_video_flags
> linux/acpi.h acpi_video_flags
> linux/fs.h proc_nr_files
>
> * These are no longer needed as intermediate includes
> ==============
> Include
> ==============
> linux/filter.h
> linux/binfmts.h
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
This is very nice! :)
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c
2025-05-09 12:54 ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
@ 2025-05-09 19:00 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:00 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:12PM +0200, Joel Granados wrote:
> Move the ctl_table with the "tainted" proc_name into kernel/panic.c.
> With it moves the proc_tainted helper function.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
2025-05-09 16:13 ` Luis Chamberlain
@ 2025-05-09 19:01 ` Kees Cook
2025-05-13 7:33 ` Joel Granados
1 sibling, 1 reply; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:01 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:13PM +0200, Joel Granados wrote:
> Move cad_pid as well as supporting function proc_do_cad_pid into
> kernel/pic.c. Replaced call to __do_proc_dointvec with proc_dointvec
> inside proc_do_cad_pid which requires the copy of the ctl_table to
> handle the temp value.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> ---
> kernel/pid.c | 32 ++++++++++++++++++++++++++++++++
> kernel/sysctl.c | 31 -------------------------------
> 2 files changed, 32 insertions(+), 31 deletions(-)
>
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 4ac2ce46817fdefff8888681bb5ca3f2676e8add..bc87ba08ae8b7c67f3457b31309b56b5d90f8c52 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -717,6 +717,29 @@ static struct ctl_table_root pid_table_root = {
> .set_ownership = pid_table_root_set_ownership,
> };
>
> +static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
> + size_t *lenp, loff_t *ppos)
> +{
> + struct pid *new_pid;
> + pid_t tmp_pid;
> + int r;
> + struct ctl_table tmp_table = *table;
> +
> + tmp_pid = pid_vnr(cad_pid);
> + tmp_table.data = &tmp_pid;
> +
> + r = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
> + if (r || !write)
> + return r;
> +
> + new_pid = find_get_pid(tmp_pid);
> + if (!new_pid)
> + return -ESRCH;
> +
> + put_pid(xchg(&cad_pid, new_pid));
> + return 0;
> +}
> +
> static const struct ctl_table pid_table[] = {
> {
> .procname = "pid_max",
> @@ -727,6 +750,15 @@ static const struct ctl_table pid_table[] = {
> .extra1 = &pid_max_min,
> .extra2 = &pid_max_max,
> },
> +#ifdef CONFIG_PROC_SYSCTL
> + {
> + .procname = "cad_pid",
> + .data = NULL,
nit: this is redundant, any unspecified member will be zero-initialized.
Regardless:
Reviewed-by: Kees Cook <kees@kernel.org>
> + .maxlen = sizeof(int),
> + .mode = 0600,
> + .proc_handler = proc_do_cad_pid,
> + },
> +#endif
> };
> #endif
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 9d8db9cef11122993d850ab5c753e3da1cbfb5cc..d5bebdd02cd4f1def7d9dd2b85454a9022b600b7 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1224,28 +1224,6 @@ int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write, void *buf
> do_proc_dointvec_ms_jiffies_conv, NULL);
> }
>
> -static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
> - size_t *lenp, loff_t *ppos)
> -{
> - struct pid *new_pid;
> - pid_t tmp;
> - int r;
> -
> - tmp = pid_vnr(cad_pid);
> -
> - r = __do_proc_dointvec(&tmp, table, write, buffer,
> - lenp, ppos, NULL, NULL);
> - if (r || !write)
> - return r;
> -
> - new_pid = find_get_pid(tmp);
> - if (!new_pid)
> - return -ESRCH;
> -
> - put_pid(xchg(&cad_pid, new_pid));
> - return 0;
> -}
> -
> /**
> * proc_do_large_bitmap - read/write from/to a large bitmap
> * @table: the sysctl table
> @@ -1541,15 +1519,6 @@ static const struct ctl_table kern_table[] = {
> .mode = 0644,
> .proc_handler = proc_dostring,
> },
> -#endif
> -#ifdef CONFIG_PROC_SYSCTL
> - {
> - .procname = "cad_pid",
> - .data = NULL,
> - .maxlen = sizeof (int),
> - .mode = 0600,
> - .proc_handler = proc_do_cad_pid,
> - },
> #endif
> {
> .procname = "overflowuid",
>
> --
> 2.47.2
>
>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 06/12] fork: mv threads-max into kernel/fork.c
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
2025-05-09 16:14 ` Luis Chamberlain
@ 2025-05-09 19:01 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:01 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:10PM +0200, Joel Granados wrote:
> make sysctl_max_threads static as it no longer needs to be exported into
> sysctl.c.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 05/12] parisc/power: Move soft-power into power.c
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
2025-05-09 16:15 ` Luis Chamberlain
@ 2025-05-09 19:02 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:02 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:09PM +0200, Joel Granados wrote:
> Move the soft-power ctl table into parisc/power.c. As a consequence the
> pwrsw_enabled var is made static.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 04/12] mm: move randomize_va_space into memory.c
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
2025-05-09 16:16 ` Luis Chamberlain
@ 2025-05-09 19:02 ` Kees Cook
1 sibling, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:02 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:08PM +0200, Joel Granados wrote:
> Move the randomize_va_space variable together with all its sysctl table
> elements into memory.c. Register it to the "kernel" directory by
> adding it to the subsys initialization calls
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
2025-05-09 13:14 ` Joel Fernandes
2025-05-09 16:17 ` Luis Chamberlain
@ 2025-05-09 19:03 ` Kees Cook
2 siblings, 0 replies; 43+ messages in thread
From: Kees Cook @ 2025-05-09 19:03 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On Fri, May 09, 2025 at 02:54:07PM +0200, Joel Granados wrote:
> Move sysctl_panic_on_rcu_stall and sysctl_max_rcu_stall_to_panic into
> the kernel/rcu subdirectory. Make these static in tree_stall.h and
> removed them as extern from panic.h as their scope is now confined into
> one file.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c
2025-05-09 19:01 ` Kees Cook
@ 2025-05-13 7:33 ` Joel Granados
0 siblings, 0 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-13 7:33 UTC (permalink / raw)
To: Kees Cook
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
[-- Attachment #1: Type: text/plain, Size: 2550 bytes --]
On Fri, May 09, 2025 at 12:01:24PM -0700, Kees Cook wrote:
> On Fri, May 09, 2025 at 02:54:13PM +0200, Joel Granados wrote:
> > Move cad_pid as well as supporting function proc_do_cad_pid into
> > kernel/pic.c. Replaced call to __do_proc_dointvec with proc_dointvec
> > inside proc_do_cad_pid which requires the copy of the ctl_table to
> > handle the temp value.
> >
> > This is part of a greater effort to move ctl tables into their
> > respective subsystems which will reduce the merge conflicts in
> > kernel/sysctl.c.
> >
> > Signed-off-by: Joel Granados <joel.granados@kernel.org>
> > ---
> > kernel/pid.c | 32 ++++++++++++++++++++++++++++++++
> > kernel/sysctl.c | 31 -------------------------------
> > 2 files changed, 32 insertions(+), 31 deletions(-)
> >
> > diff --git a/kernel/pid.c b/kernel/pid.c
> > index 4ac2ce46817fdefff8888681bb5ca3f2676e8add..bc87ba08ae8b7c67f3457b31309b56b5d90f8c52 100644
> > --- a/kernel/pid.c
> > +++ b/kernel/pid.c
> > @@ -717,6 +717,29 @@ static struct ctl_table_root pid_table_root = {
> > .set_ownership = pid_table_root_set_ownership,
> > };
> >
> > +static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
> > + size_t *lenp, loff_t *ppos)
> > +{
> > + struct pid *new_pid;
> > + pid_t tmp_pid;
> > + int r;
> > + struct ctl_table tmp_table = *table;
> > +
> > + tmp_pid = pid_vnr(cad_pid);
> > + tmp_table.data = &tmp_pid;
> > +
> > + r = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
> > + if (r || !write)
> > + return r;
> > +
> > + new_pid = find_get_pid(tmp_pid);
> > + if (!new_pid)
> > + return -ESRCH;
> > +
> > + put_pid(xchg(&cad_pid, new_pid));
> > + return 0;
> > +}
> > +
> > static const struct ctl_table pid_table[] = {
> > {
> > .procname = "pid_max",
> > @@ -727,6 +750,15 @@ static const struct ctl_table pid_table[] = {
> > .extra1 = &pid_max_min,
> > .extra2 = &pid_max_max,
> > },
> > +#ifdef CONFIG_PROC_SYSCTL
> > + {
> > + .procname = "cad_pid",
> > + .data = NULL,
>
> nit: this is redundant, any unspecified member will be zero-initialized.
Thx. Changed it locally, but will not resend for this.
>
> Regardless:
>
> Reviewed-by: Kees Cook <kees@kernel.org>
...
> > - .data = NULL,
> > - .maxlen = sizeof (int),
> > - .mode = 0600,
> > - .proc_handler = proc_do_cad_pid,
> > - },
> > #endif
> > {
> > .procname = "overflowuid",
> >
> > --
> > 2.47.2
> >
> >
>
> --
> Kees Cook
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-09 16:09 ` Luis Chamberlain
@ 2025-05-13 7:37 ` Joel Granados
0 siblings, 0 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-13 7:37 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Petr Pavlu, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]
On Fri, May 09, 2025 at 09:09:44AM -0700, Luis Chamberlain wrote:
> On Fri, May 09, 2025 at 02:54:05PM +0200, Joel Granados wrote:
> > diff --git a/kernel/module/kmod.c b/kernel/module/kmod.c
> > index 25f25381251281a390b273cd8a734c92b960113a..5701629adc27b4bb5080db75f0e69f9f55e9d2ad 100644
> > --- a/kernel/module/kmod.c
> > +++ b/kernel/module/kmod.c
> > @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
> > /*
> > modprobe_path is set via /proc/sys.
> > */
> > -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> > +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> >
> > static void free_modprobe_argv(struct subprocess_info *info)
> > {
> > @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
> > return ret;
> > }
> > EXPORT_SYMBOL(__request_module);
> > +
> > +#ifdef CONFIG_MODULES
>
> kernel/Makefile:
>
> obj-$(CONFIG_MODULES) += module/
>
> And so you can drop this ifdef.
Done. Modified in my version, but will not bother to send a V2 for this.
>
> Other than that:
>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
>
> Luis
>
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c
2025-05-09 17:10 ` Kees Cook
@ 2025-05-13 7:49 ` Joel Granados
0 siblings, 0 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-13 7:49 UTC (permalink / raw)
To: Kees Cook
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Daniel Gomez,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]
On Fri, May 09, 2025 at 10:10:28AM -0700, Kees Cook wrote:
> On Fri, May 09, 2025 at 02:54:11PM +0200, Joel Granados wrote:
> > Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
> > function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
> > helper function with do_proc_dointvec as the former is local to
> > kernel/sysctl.c.
>
> nit: do_proc_dointvec_minmax
Thx. I even added a small comment to the commit message to clarify:
```
Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
helper function with do_proc_dointvec_minmax as the former is local to
kernel/sysctl.c. Here we use the minmax version of do_proc_dointvec
because do_proc_dointvec is static and calling do_proc_dointvec_minmax
with a NULL min and max is the same as calling do_proc_dointvec.
```
I'll also put a comment in the code to make sure that a min max is not
added by mistake.
Best
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
2025-05-09 16:09 ` Luis Chamberlain
@ 2025-05-15 8:04 ` Petr Pavlu
2025-05-15 10:04 ` Joel Granados
1 sibling, 1 reply; 43+ messages in thread
From: Petr Pavlu @ 2025-05-15 8:04 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On 5/9/25 14:54, Joel Granados wrote:
> Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
> and into the modules subsystem. Make the modprobe_path variable static
> as it no longer needs to be exported. Remove module.h from the includes
> in sysctl as it no longer uses any module exported variables.
>
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> [...]
> --- a/kernel/module/kmod.c
> +++ b/kernel/module/kmod.c
> @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
> /*
> modprobe_path is set via /proc/sys.
> */
> -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
>
> static void free_modprobe_argv(struct subprocess_info *info)
> {
> @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
> return ret;
> }
> EXPORT_SYMBOL(__request_module);
> +
> +#ifdef CONFIG_MODULES
> +static const struct ctl_table kmod_sysctl_table[] = {
> + {
> + .procname = "modprobe",
> + .data = &modprobe_path,
> + .maxlen = KMOD_PATH_LEN,
> + .mode = 0644,
> + .proc_handler = proc_dostring,
> + },
> + {
> + .procname = "modules_disabled",
> + .data = &modules_disabled,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + /* only handle a transition from default "0" to "1" */
> + .proc_handler = proc_dointvec_minmax,
> + .extra1 = SYSCTL_ONE,
> + .extra2 = SYSCTL_ONE,
> + },
This is minor.. but the file kernel/module/kmod.c contains the logic to
request direct modprobe invocation by the kernel. Registering the
modprobe_path sysctl here is appropriate. However, the modules_disabled
setting affects the entire module loader so I don't think it's best to
register it here.
I suggest keeping a single table for the module sysctl values but moving
it to kernel/module/main.c. This means the variable modprobe_path must
retain external linkage, on the other hand, modules_disabled can be made
static.
--
Thanks,
Petr
> +};
> +
> +static int __init init_kmod_sysctl(void)
> +{
> + register_sysctl_init("kernel", kmod_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_kmod_sysctl);
> +#endif
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-15 8:04 ` Petr Pavlu
@ 2025-05-15 10:04 ` Joel Granados
2025-05-15 12:45 ` Petr Pavlu
0 siblings, 1 reply; 43+ messages in thread
From: Joel Granados @ 2025-05-15 10:04 UTC (permalink / raw)
To: Petr Pavlu
Cc: Luis Chamberlain, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
[-- Attachment #1: Type: text/plain, Size: 5204 bytes --]
On Thu, May 15, 2025 at 10:04:53AM +0200, Petr Pavlu wrote:
> On 5/9/25 14:54, Joel Granados wrote:
> > Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
> > and into the modules subsystem. Make the modprobe_path variable static
> > as it no longer needs to be exported. Remove module.h from the includes
> > in sysctl as it no longer uses any module exported variables.
> >
> > This is part of a greater effort to move ctl tables into their
> > respective subsystems which will reduce the merge conflicts in
> > kernel/sysctl.c.
> >
> > Signed-off-by: Joel Granados <joel.granados@kernel.org>
> > [...]
> > --- a/kernel/module/kmod.c
> > +++ b/kernel/module/kmod.c
> > @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
> > /*
> > modprobe_path is set via /proc/sys.
> > */
> > -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> > +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
> >
> > static void free_modprobe_argv(struct subprocess_info *info)
> > {
> > @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
> > return ret;
> > }
> > EXPORT_SYMBOL(__request_module);
> > +
> > +#ifdef CONFIG_MODULES
> > +static const struct ctl_table kmod_sysctl_table[] = {
> > + {
> > + .procname = "modprobe",
> > + .data = &modprobe_path,
> > + .maxlen = KMOD_PATH_LEN,
> > + .mode = 0644,
> > + .proc_handler = proc_dostring,
> > + },
> > + {
> > + .procname = "modules_disabled",
> > + .data = &modules_disabled,
> > + .maxlen = sizeof(int),
> > + .mode = 0644,
> > + /* only handle a transition from default "0" to "1" */
> > + .proc_handler = proc_dointvec_minmax,
> > + .extra1 = SYSCTL_ONE,
> > + .extra2 = SYSCTL_ONE,
> > + },
>
> This is minor.. but the file kernel/module/kmod.c contains the logic to
> request direct modprobe invocation by the kernel. Registering the
> modprobe_path sysctl here is appropriate. However, the modules_disabled
> setting affects the entire module loader so I don't think it's best to
> register it here.
>
> I suggest keeping a single table for the module sysctl values but moving
> it to kernel/module/main.c. This means the variable modprobe_path must
> retain external linkage, on the other hand, modules_disabled can be made
> static.
Like this?:
---
include/linux/module.h | 1 -
kernel/module/main.c | 30 +++++++++++++++++++++++++++++-
kernel/sysctl.c | 20 --------------------
3 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index d94b196d5a34..25476168e012 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -302,7 +302,6 @@ struct notifier_block;
#ifdef CONFIG_MODULES
-extern int modules_disabled; /* for sysctl */
/* Get/put a kernel symbol (calls must be symmetric) */
void *__symbol_get(const char *symbol);
void *__symbol_get_gpl(const char *symbol);
diff --git a/kernel/module/main.c b/kernel/module/main.c
index a2859dc3eea6..13055ef65f15 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -126,9 +126,37 @@ static void mod_update_bounds(struct module *mod)
}
/* Block module loading/unloading? */
-int modules_disabled;
+static int modules_disabled;
core_param(nomodule, modules_disabled, bint, 0);
+static const struct ctl_table kmod_sysctl_table[] = {
+ {
+ .procname = "modprobe",
+ .data = &modprobe_path,
+ .maxlen = KMOD_PATH_LEN,
+ .mode = 0644,
+ .proc_handler = proc_dostring,
+ },
+ {
+ .procname = "modules_disabled",
+ .data = &modules_disabled,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ /* only handle a transition from default "0" to "1" */
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_ONE,
+ },
+};
+
+static int __init init_kmod_sysctl(void)
+{
+ register_sysctl_init("kernel", kmod_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_kmod_sysctl);
+
/* Waiting for a module to finish initializing? */
static DECLARE_WAIT_QUEUE_HEAD(module_wq);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9b4f0cff76ea..473133d9651e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -19,7 +19,6 @@
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
*/
-#include <linux/module.h>
#include <linux/sysctl.h>
#include <linux/bitmap.h>
#include <linux/printk.h>
@@ -1616,25 +1615,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#ifdef CONFIG_MODULES
- {
- .procname = "modprobe",
- .data = &modprobe_path,
- .maxlen = KMOD_PATH_LEN,
- .mode = 0644,
- .proc_handler = proc_dostring,
- },
- {
- .procname = "modules_disabled",
- .data = &modules_disabled,
- .maxlen = sizeof(int),
- .mode = 0644,
- /* only handle a transition from default "0" to "1" */
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ONE,
- .extra2 = SYSCTL_ONE,
- },
-#endif
#ifdef CONFIG_UEVENT_HELPER
{
.procname = "hotplug",
--
2.47.2
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-15 10:04 ` Joel Granados
@ 2025-05-15 12:45 ` Petr Pavlu
2025-05-19 15:20 ` Joel Granados
0 siblings, 1 reply; 43+ messages in thread
From: Petr Pavlu @ 2025-05-15 12:45 UTC (permalink / raw)
To: Joel Granados
Cc: Luis Chamberlain, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
On 5/15/25 12:04, Joel Granados wrote:
> On Thu, May 15, 2025 at 10:04:53AM +0200, Petr Pavlu wrote:
>> On 5/9/25 14:54, Joel Granados wrote:
>>> Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
>>> and into the modules subsystem. Make the modprobe_path variable static
>>> as it no longer needs to be exported. Remove module.h from the includes
>>> in sysctl as it no longer uses any module exported variables.
>>>
>>> This is part of a greater effort to move ctl tables into their
>>> respective subsystems which will reduce the merge conflicts in
>>> kernel/sysctl.c.
>>>
>>> Signed-off-by: Joel Granados <joel.granados@kernel.org>
>>> [...]
>>> --- a/kernel/module/kmod.c
>>> +++ b/kernel/module/kmod.c
>>> @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT);
>>> /*
>>> modprobe_path is set via /proc/sys.
>>> */
>>> -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
>>> +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
>>>
>>> static void free_modprobe_argv(struct subprocess_info *info)
>>> {
>>> @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...)
>>> return ret;
>>> }
>>> EXPORT_SYMBOL(__request_module);
>>> +
>>> +#ifdef CONFIG_MODULES
>>> +static const struct ctl_table kmod_sysctl_table[] = {
>>> + {
>>> + .procname = "modprobe",
>>> + .data = &modprobe_path,
>>> + .maxlen = KMOD_PATH_LEN,
>>> + .mode = 0644,
>>> + .proc_handler = proc_dostring,
>>> + },
>>> + {
>>> + .procname = "modules_disabled",
>>> + .data = &modules_disabled,
>>> + .maxlen = sizeof(int),
>>> + .mode = 0644,
>>> + /* only handle a transition from default "0" to "1" */
>>> + .proc_handler = proc_dointvec_minmax,
>>> + .extra1 = SYSCTL_ONE,
>>> + .extra2 = SYSCTL_ONE,
>>> + },
>>
>> This is minor.. but the file kernel/module/kmod.c contains the logic to
>> request direct modprobe invocation by the kernel. Registering the
>> modprobe_path sysctl here is appropriate. However, the modules_disabled
>> setting affects the entire module loader so I don't think it's best to
>> register it here.
>>
>> I suggest keeping a single table for the module sysctl values but moving
>> it to kernel/module/main.c. This means the variable modprobe_path must
>> retain external linkage, on the other hand, modules_disabled can be made
>> static.
>
> Like this?:
> [...]
Let's also move the KMOD_PATH_LEN definition and the modprobe_path
declaration from include/linux/kmod.h to kernel/module/internal.h, as
they are now fully internal to the module loader, and use "module"
instead of "kmod" in the sysctl registration to avoid confusion with the
modprobe logic.
The adjusted patch is below.
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
--
Thanks,
Petr
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 68f69362d427..9a07c3215389 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -14,10 +14,7 @@
#include <linux/workqueue.h>
#include <linux/sysctl.h>
-#define KMOD_PATH_LEN 256
-
#ifdef CONFIG_MODULES
-extern char modprobe_path[]; /* for sysctl */
/* modprobe exit status on success, -ve on error. Return value
* usually useless though. */
extern __printf(2, 3)
diff --git a/include/linux/module.h b/include/linux/module.h
index 8050f77c3b64..f4ab8d90c475 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -304,7 +304,6 @@ struct notifier_block;
#ifdef CONFIG_MODULES
-extern int modules_disabled; /* for sysctl */
/* Get/put a kernel symbol (calls must be symmetric) */
void *__symbol_get(const char *symbol);
void *__symbol_get_gpl(const char *symbol);
diff --git a/kernel/module/internal.h b/kernel/module/internal.h
index 626cf8668a7e..0954c8de00c2 100644
--- a/kernel/module/internal.h
+++ b/kernel/module/internal.h
@@ -58,6 +58,9 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[];
extern const u32 __start___kcrctab[];
extern const u32 __start___kcrctab_gpl[];
+#define KMOD_PATH_LEN 256
+extern char modprobe_path[];
+
struct load_info {
const char *name;
/* pointer to module in temporary copy, freed at end of load_module() */
diff --git a/kernel/module/main.c b/kernel/module/main.c
index a2859dc3eea6..a336b7b3fb23 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -126,9 +126,37 @@ static void mod_update_bounds(struct module *mod)
}
/* Block module loading/unloading? */
-int modules_disabled;
+static int modules_disabled;
core_param(nomodule, modules_disabled, bint, 0);
+static const struct ctl_table module_sysctl_table[] = {
+ {
+ .procname = "modprobe",
+ .data = &modprobe_path,
+ .maxlen = KMOD_PATH_LEN,
+ .mode = 0644,
+ .proc_handler = proc_dostring,
+ },
+ {
+ .procname = "modules_disabled",
+ .data = &modules_disabled,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ /* only handle a transition from default "0" to "1" */
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_ONE,
+ },
+};
+
+static int __init init_module_sysctl(void)
+{
+ register_sysctl_init("kernel", module_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_module_sysctl);
+
/* Waiting for a module to finish initializing? */
static DECLARE_WAIT_QUEUE_HEAD(module_wq);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9b4f0cff76ea..473133d9651e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -19,7 +19,6 @@
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
*/
-#include <linux/module.h>
#include <linux/sysctl.h>
#include <linux/bitmap.h>
#include <linux/printk.h>
@@ -1616,25 +1615,6 @@ static const struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
-#ifdef CONFIG_MODULES
- {
- .procname = "modprobe",
- .data = &modprobe_path,
- .maxlen = KMOD_PATH_LEN,
- .mode = 0644,
- .proc_handler = proc_dostring,
- },
- {
- .procname = "modules_disabled",
- .data = &modules_disabled,
- .maxlen = sizeof(int),
- .mode = 0644,
- /* only handle a transition from default "0" to "1" */
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ONE,
- .extra2 = SYSCTL_ONE,
- },
-#endif
#ifdef CONFIG_UEVENT_HELPER
{
.procname = "hotplug",
^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
2025-05-15 12:45 ` Petr Pavlu
@ 2025-05-19 15:20 ` Joel Granados
0 siblings, 0 replies; 43+ messages in thread
From: Joel Granados @ 2025-05-19 15:20 UTC (permalink / raw)
To: Petr Pavlu
Cc: Luis Chamberlain, Sami Tolvanen, Daniel Gomez, Kees Cook,
Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Uladzislau Rezki, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Zqiang, Andrew Morton,
James E.J. Bottomley, Helge Deller, Greg Kroah-Hartman,
Jiri Slaby, linux-modules, linux-kernel, linux-fsdevel, rcu,
linux-mm, linux-parisc, linux-serial
[-- Attachment #1: Type: text/plain, Size: 5008 bytes --]
On Thu, May 15, 2025 at 02:45:22PM +0200, Petr Pavlu wrote:
> On 5/15/25 12:04, Joel Granados wrote:
> > On Thu, May 15, 2025 at 10:04:53AM +0200, Petr Pavlu wrote:
> >> On 5/9/25 14:54, Joel Granados wrote:
> >>> Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
> >>> and into the modules subsystem. Make the modprobe_path variable static
> >>> as it no longer needs to be exported. Remove module.h from the includes
> >>> in sysctl as it no longer uses any module exported variables.
...
> > Like this?:
> > [...]
>
> Let's also move the KMOD_PATH_LEN definition and the modprobe_path
> declaration from include/linux/kmod.h to kernel/module/internal.h, as
> they are now fully internal to the module loader, and use "module"
> instead of "kmod" in the sysctl registration to avoid confusion with the
> modprobe logic.
>
> The adjusted patch is below.
>
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Thx for review and patch. Have applied it to my current V2 branch [1]
Best
[1] https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/log/?h=jag/mv_ctltables_iter2
>
> --
> Thanks,
> Petr
>
>
> diff --git a/include/linux/kmod.h b/include/linux/kmod.h
> index 68f69362d427..9a07c3215389 100644
> --- a/include/linux/kmod.h
> +++ b/include/linux/kmod.h
> @@ -14,10 +14,7 @@
> #include <linux/workqueue.h>
> #include <linux/sysctl.h>
>
> -#define KMOD_PATH_LEN 256
> -
> #ifdef CONFIG_MODULES
> -extern char modprobe_path[]; /* for sysctl */
> /* modprobe exit status on success, -ve on error. Return value
> * usually useless though. */
> extern __printf(2, 3)
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 8050f77c3b64..f4ab8d90c475 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -304,7 +304,6 @@ struct notifier_block;
>
> #ifdef CONFIG_MODULES
>
> -extern int modules_disabled; /* for sysctl */
> /* Get/put a kernel symbol (calls must be symmetric) */
> void *__symbol_get(const char *symbol);
> void *__symbol_get_gpl(const char *symbol);
> diff --git a/kernel/module/internal.h b/kernel/module/internal.h
> index 626cf8668a7e..0954c8de00c2 100644
> --- a/kernel/module/internal.h
> +++ b/kernel/module/internal.h
> @@ -58,6 +58,9 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[];
> extern const u32 __start___kcrctab[];
> extern const u32 __start___kcrctab_gpl[];
>
> +#define KMOD_PATH_LEN 256
> +extern char modprobe_path[];
> +
> struct load_info {
> const char *name;
> /* pointer to module in temporary copy, freed at end of load_module() */
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index a2859dc3eea6..a336b7b3fb23 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -126,9 +126,37 @@ static void mod_update_bounds(struct module *mod)
> }
>
> /* Block module loading/unloading? */
> -int modules_disabled;
> +static int modules_disabled;
> core_param(nomodule, modules_disabled, bint, 0);
>
> +static const struct ctl_table module_sysctl_table[] = {
> + {
> + .procname = "modprobe",
> + .data = &modprobe_path,
> + .maxlen = KMOD_PATH_LEN,
> + .mode = 0644,
> + .proc_handler = proc_dostring,
> + },
> + {
> + .procname = "modules_disabled",
> + .data = &modules_disabled,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + /* only handle a transition from default "0" to "1" */
> + .proc_handler = proc_dointvec_minmax,
> + .extra1 = SYSCTL_ONE,
> + .extra2 = SYSCTL_ONE,
> + },
> +};
> +
> +static int __init init_module_sysctl(void)
> +{
> + register_sysctl_init("kernel", module_sysctl_table);
> + return 0;
> +}
> +
> +subsys_initcall(init_module_sysctl);
> +
> /* Waiting for a module to finish initializing? */
> static DECLARE_WAIT_QUEUE_HEAD(module_wq);
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 9b4f0cff76ea..473133d9651e 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -19,7 +19,6 @@
> * Removed it and replaced it with older style, 03/23/00, Bill Wendling
> */
>
> -#include <linux/module.h>
> #include <linux/sysctl.h>
> #include <linux/bitmap.h>
> #include <linux/printk.h>
> @@ -1616,25 +1615,6 @@ static const struct ctl_table kern_table[] = {
> .proc_handler = proc_dointvec,
> },
> #endif
> -#ifdef CONFIG_MODULES
> - {
> - .procname = "modprobe",
> - .data = &modprobe_path,
> - .maxlen = KMOD_PATH_LEN,
> - .mode = 0644,
> - .proc_handler = proc_dostring,
> - },
> - {
> - .procname = "modules_disabled",
> - .data = &modules_disabled,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - /* only handle a transition from default "0" to "1" */
> - .proc_handler = proc_dointvec_minmax,
> - .extra1 = SYSCTL_ONE,
> - .extra2 = SYSCTL_ONE,
> - },
> -#endif
> #ifdef CONFIG_UEVENT_HELPER
> {
> .procname = "hotplug",
>
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2025-05-19 15:20 UTC | newest]
Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 12:54 [PATCH 00/12] sysctl: Move sysctls to their respective subsystems (second batch) Joel Granados
2025-05-09 12:54 ` [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys Joel Granados
2025-05-09 16:09 ` Luis Chamberlain
2025-05-13 7:37 ` Joel Granados
2025-05-15 8:04 ` Petr Pavlu
2025-05-15 10:04 ` Joel Granados
2025-05-15 12:45 ` Petr Pavlu
2025-05-19 15:20 ` Joel Granados
2025-05-09 12:54 ` [PATCH 02/12] locking/rtmutex: Move max_lock_depth into rtmutex.c Joel Granados
2025-05-09 15:49 ` Waiman Long
2025-05-09 18:56 ` Kees Cook
2025-05-09 12:54 ` [PATCH 03/12] rcu: Move rcu_stall related sysctls into rcu/tree_stall.h Joel Granados
2025-05-09 13:14 ` Joel Fernandes
2025-05-09 16:17 ` Luis Chamberlain
2025-05-09 19:03 ` Kees Cook
2025-05-09 12:54 ` [PATCH 04/12] mm: move randomize_va_space into memory.c Joel Granados
2025-05-09 16:16 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
2025-05-09 12:54 ` [PATCH 05/12] parisc/power: Move soft-power into power.c Joel Granados
2025-05-09 16:15 ` Luis Chamberlain
2025-05-09 19:02 ` Kees Cook
2025-05-09 12:54 ` [PATCH 06/12] fork: mv threads-max into kernel/fork.c Joel Granados
2025-05-09 16:14 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
2025-05-09 12:54 ` [PATCH 07/12] Input: sysrq: mv sysrq into drivers/tty/sysrq.c Joel Granados
2025-05-09 14:47 ` Greg Kroah-Hartman
2025-05-09 17:10 ` Kees Cook
2025-05-13 7:49 ` Joel Granados
2025-05-09 12:54 ` [PATCH 08/12] sysctl: Move tainted ctl_table into kernel/panic.c Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 19:00 ` Kees Cook
2025-05-09 12:54 ` [PATCH 09/12] sysctl: move cad_pid into kernel/pid.c Joel Granados
2025-05-09 16:13 ` Luis Chamberlain
2025-05-09 19:01 ` Kees Cook
2025-05-13 7:33 ` Joel Granados
2025-05-09 12:54 ` [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c Joel Granados
2025-05-09 17:04 ` Kees Cook
2025-05-09 12:54 ` [PATCH 11/12] sysctl: Remove (very) old file changelog Joel Granados
2025-05-09 16:11 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
2025-05-09 12:54 ` [PATCH 12/12] sysctl: Remove superfluous includes from kernel/sysctl.c Joel Granados
2025-05-09 16:12 ` Luis Chamberlain
2025-05-09 18:57 ` Kees Cook
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).