sysctl: Remove last two ctl_tables from the kern_table array
Subsystems (5)
Joel Granados
maintainercover sysctl: Remove last two ctl_tables from the kern_table array
This is the last series to relocate sysctl tables from kernel/sysctl.c into their respective subsystems. After the move of two ctl_tables (uevent_helper & overflow{uid,gid}), five remain. They either handle variables defined within sysctl.c or serve as a common place for variables that are defined in different architectures. These five will not be moved. Note that this series includes two auxiliary changes:
Removal of an unused variable and Nix-based rework of sysctl.sh test script
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 prefer to merge this through a non-sysctl tree, please let me know so I can avoid conflicts in linux-next.
2. Apologies if you were copied by mistake—let me know if you'd like to be removed.
3. This series builds on [1], so please rebase accordingly for clean application.
4. Testing done by running sysctl selftests on x86_64 and 0-day.
Comments/Suggestions greatly appreciated
[1] https://lore.kernel.org/[email protected]
---
Joel Granados (5):
sysctl: Nixify sysctl.sh
sysctl: Removed unused variable
uevent: mv uevent_helper into kobject_uevent.c kernel/sys.c: Move overflow{uid,gid} sysctl into kernel/sys.c
sysctl: rename kern_table -> sysctl_subsys_table
include/linux/sysctl.h | 1 - kernel/sys.c | 29 +++++++++++++++++++ kernel/sysctl.c | 49 +++++++------------------------- lib/kobject_uevent.c | 20 +++++++++++++ tools/testing/selftests/sysctl/sysctl.sh | 2 +- 5 files changed, 61 insertions(+), 40 deletions(-)
---
base-commit: 501dd0fbc76bcae57902ea000d9c6ccd9d5f226e
change-id: 20250627-jag-sysctl-823adf5732be
Best regards,
Signature · 1 line
Joel Granados <[email protected]>
Joel Granados
maintainerPATCH 1/5 sysctl: Nixify sysctl.sh
Use "#!/usr/bin/env bash" instead of "#!/bin/bash". Needed for testing in nix environments as they only provide /usr/bin/env at the standard location.
--- tools/testing/selftests/sysctl/sysctl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sysctl/sysctl.sh +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-or-later OR copyleft-next-0.3.1 # Copyright (C) 2017 Luis R. Rodriguez <[email protected]>
Signature · 1 line
2.47.2
Joel Granados
maintainerPATCH 2/5 sysctl: Removed unused variable
In reply to Joel GranadosRemove unaligned_dump_stack from sysctl.h; it is no longer used or defined.
--- include/linux/sysctl.h | 1 - 1 file changed, 1 deletion(-)
include/linux/sysctl.h +0 -1
@@ -243,7 +243,6 @@ int do_proc_douintvec(const struct ctl_table *table, int write, void *data);extern int unaligned_enabled; -extern int unaligned_dump_stack;extern int no_unaligned_warning;#else /* CONFIG_SYSCTL */
Signature · 1 line
2.47.2
Joel Granados
maintainerPATCH 3/5 uevent: mv uevent_helper into kobject_uevent.c
In reply to Joel GranadosMove both uevent_helper table into lib/kobject_uevent.c. Place the registration early in the initcall order with postcore_initcall.
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.
--- kernel/sysctl.c | 9 --------- lib/kobject_uevent.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-)
kernel/sysctl.c +0 -9
@@ -1474,15 +1474,6 @@ static const struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, -#endif -#ifdef CONFIG_UEVENT_HELPER - { - .procname = "hotplug", - .data = &uevent_helper, - .maxlen = UEVENT_HELPER_PATH_LEN, - .mode = 0644, - .proc_handler = proc_dostring, - },#endif { .procname = "overflowuid",
lib/kobject_uevent.c +20 -0
@@ -826,3 +826,23 @@ static int __init kobject_uevent_init(void)postcore_initcall (kobject_uevent_init);#endif + +#ifdef CONFIG_UEVENT_HELPER +static const struct ctl_table uevent_helper_sysctl_table[] = { + { + .procname ="hotplug" , + .data = &uevent_helper, + .maxlen =UEVENT_HELPER_PATH_LEN , + .mode =0644 , + .proc_handler = proc_dostring, + }, +}; + +static int __init init_uevent_helper_sysctl (void ) +{ +register_sysctl_init ("kernel" , uevent_helper_sysctl_table); +return 0 ; +} + +postcore_initcall (init_uevent_helper_sysctl); +#endif
Signature · 1 line
2.47.2
Joel Granados
maintainerPATCH 4/5 kernel/sys.c: Move overflow{uid,gid} sysctl into kernel/sys.c
In reply to Joel GranadosMoved ctl_tables elements for overflowuid and overflowgid into in kernel/sys.c. Create a register function that keeps them under "kernel" and run it after core with postcore_initcall.
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.
--- kernel/sys.c | 30 ++++++++++++++++++++++++++++++ kernel/sysctl.c | 18 ------------------ 2 files changed, 30 insertions(+), 18 deletions(-)
kernel/sys.c +30 -0
@@ -181,6 +181,36 @@ int fs_overflowgid = DEFAULT_FS_OVERFLOWGID;EXPORT_SYMBOL (fs_overflowuid);EXPORT_SYMBOL (fs_overflowgid); +static const struct ctl_table overflow_sysctl_table[] = { + { + .procname ="overflowuid" , + .data = &overflowuid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_MAXOLDUID , + }, + { + .procname ="overflowgid" , + .data = &overflowgid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_MAXOLDUID , + }, +}; + +static int __init init_overflow_sysctl (void ) +{ +register_sysctl_init ("kernel" , overflow_sysctl_table); +return 0 ; +} + +postcore_initcall (init_overflow_sysctl); + +/* * Returns true if current's euid is same as p's uid or euid, * or has CAP_SYS_NICE to p's user_ns.
kernel/sysctl.c +0 -18
@@ -1475,24 +1475,6 @@ static const struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, },#endif - { - .procname = "overflowuid", - .data = &overflowuid, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_MAXOLDUID, - }, - { - .procname = "overflowgid", - .data = &overflowgid, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_MAXOLDUID, - }, { .procname = "ngroups_max", .data = (void *)&ngroups_max,
Signature · 1 line
2.47.2
Joel Granados
maintainerPATCH 5/5 sysctl: rename kern_table -> sysctl_subsys_table
In reply to Joel GranadosRenamed sysctl table from kern_table to sysctl_subsys_table and grouped the two arch specific ctls to the end of the array.
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.
--- kernel/sys.c | 1 - kernel/sysctl.c | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-)
kernel/sys.c +0 -1
@@ -210,7 +210,6 @@ static int __init init_overflow_sysctl(void)postcore_initcall (init_overflow_sysctl); -/* * Returns true if current's euid is same as p's uid or euid, * or has CAP_SYS_NICE to p's user_ns.
kernel/sysctl.c +11 -11
@@ -1454,7 +1454,7 @@ int proc_do_static_key(const struct ctl_table *table, int write,return ret; } -static const struct ctl_table kern_table[] = { +static const struct ctl_table sysctl_subsys_table[] = { #ifdef CONFIG_PROC_SYSCTL { .procname ="sysctl_writes_strict" ,
@@ -1465,15 +1465,6 @@ static const struct ctl_table kern_table[] = { .extra1 = SYSCTL_NEG_ONE, .extra2 = SYSCTL_ONE, }, -#endif -#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW - { - .procname = "unaligned-trap", - .data = &unaligned_enabled, - .maxlen = sizeof (int), - .mode = 0644, - .proc_handler = proc_dointvec, - },#endif { .procname = "ngroups_max",
@@ -1489,6 +1480,15 @@ static const struct ctl_table kern_table[] = { .mode = 0444, .proc_handler = proc_dointvec, }, +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW + { + .procname = "unaligned-trap", + .data = &unaligned_enabled, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN { .procname = "ignore-unaligned-usertrap",
@@ -1502,7 +1502,7 @@ static const struct ctl_table kern_table[] = {int __init sysctl_init_bases (void ) { -register_sysctl_init ("kernel" , kern_table); +register_sysctl_init ("kernel" , sysctl_subsys_table);return 0 ; }
Signature · 1 line
2.47.2