linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joel Granados <joel.granados@kernel.org>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	 Sami Tolvanen <samitolvanen@google.com>,
	Daniel Gomez <da.gomez@samsung.com>, Kees Cook <kees@kernel.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	 Boqun Feng <boqun.feng@gmail.com>,
	Waiman Long <longman@redhat.com>,
	 "Paul E. McKenney" <paulmck@kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	 Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	Joel Fernandes <joel@joelfernandes.org>,
	 Josh Triplett <josh@joshtriplett.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang1211@gmail.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	 Helge Deller <deller@gmx.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>,
	linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-fsdevel@vger.kernel.org, rcu@vger.kernel.org,
	linux-mm@kvack.org,  linux-parisc@vger.kernel.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
Date: Mon, 19 May 2025 17:20:30 +0200	[thread overview]
Message-ID: <l7dgle5lhsvfrikd4rqvzuwrqwrseucf5ijgnbi6fxook6dnhj@sc7givb3qimb> (raw)
In-Reply-To: <f6058414-e04d-4b7f-b4e6-3ac3613edbc1@suse.com>

[-- 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 --]

  reply	other threads:[~2025-05-19 15:20 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=l7dgle5lhsvfrikd4rqvzuwrqwrseucf5ijgnbi6fxook6dnhj@sc7givb3qimb \
    --to=joel.granados@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=boqun.feng@gmail.com \
    --cc=da.gomez@samsung.com \
    --cc=deller@gmx.de \
    --cc=frederic@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiangshanlai@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcgrof@kernel.org \
    --cc=mingo@redhat.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=urezki@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox