]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
authorJoel Granados <joel.granados@kernel.org>
Tue, 29 Apr 2025 12:30:00 +0000 (14:30 +0200)
committerJoel Granados <joel.granados@kernel.org>
Wed, 23 Jul 2025 09:52:47 +0000 (11:52 +0200)
Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c
and into the modules subsystem. Make modules_disabled 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.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
include/linux/kmod.h
include/linux/module.h
kernel/module/internal.h
kernel/module/main.c
kernel/sysctl.c

index 68f69362d427caaaefc2565127a7a4158433e5f5..9a07c3215389781ba49e0c1b4bcf40f95dbef506 100644 (file)
 #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)
index 92e1420fccdffc9de9f49da9061546cc1e0c89d1..e93cdb92ad92e019c9b32b8ecefa143d3097e15b 100644 (file)
@@ -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);
index 8d74b0a21c82b5360977a29736eca78ee6b6be3e..51ddd8866ef30a2ebb0306f0a58aaf5587d8bb85 100644 (file)
@@ -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() */
index 413ac6ea37021bc8ae260f624ca2745ed85333fc..c11d9a125001257150de296836680526d13f76d0 100644 (file)
@@ -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);
 
index 9b4f0cff76eaddc823065ea587760156576a8686..473133d9651eac4ef44b8b63a44b77189818ac08 100644 (file)
@@ -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",