Use the MODULE_NAME_LEN definition in module_exists() to obtain the maximum
size of a module name, instead of using MAX_PARAM_PREFIX_LEN. The values
are the same but MODULE_NAME_LEN is more appropriate in this context.
MAX_PARAM_PREFIX_LEN was added in commit 730b69d22525 ("module: check
kernel param length at compile time, not runtime") only to break a circular
dependency between module.h and moduleparam.h, and should mostly be limited
to use in moduleparam.h.
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
---
As a side note, I suspect the function module_exists() would be better
replaced with !!find_module() + RCU locking, but that is a separate issue.
kernel/trace/trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 95ae7c4e5835..b9da0c4661a0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -10373,7 +10373,7 @@ bool module_exists(const char *module)
{
/* All modules have the symbol __this_module */
static const char this_mod[] = "__this_module";
- char modname[MAX_PARAM_PREFIX_LEN + sizeof(this_mod) + 2];
+ char modname[MODULE_NAME_LEN + sizeof(this_mod) + 2];
unsigned long val;
int n;
--
2.49.0
On 30/06/2025 16.32, Petr Pavlu wrote: > Use the MODULE_NAME_LEN definition in module_exists() to obtain the maximum > size of a module name, instead of using MAX_PARAM_PREFIX_LEN. The values > are the same but MODULE_NAME_LEN is more appropriate in this context. > MAX_PARAM_PREFIX_LEN was added in commit 730b69d22525 ("module: check > kernel param length at compile time, not runtime") only to break a circular > dependency between module.h and moduleparam.h, and should mostly be limited > to use in moduleparam.h. > > Signed-off-by: Petr Pavlu <petr.pavlu@suse.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Masami Hiramatsu <mhiramat@kernel.org> Steven, Masami, I'm planning to merge these series into modules-next. I think and Ack/Review would be great from you. Otherwise, let me know if you'd rather take this patch through tracing instead (in case it looks good from your side). > --- > > As a side note, I suspect the function module_exists() would be better > replaced with !!find_module() + RCU locking, but that is a separate issue. > > kernel/trace/trace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 95ae7c4e5835..b9da0c4661a0 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -10373,7 +10373,7 @@ bool module_exists(const char *module) > { > /* All modules have the symbol __this_module */ > static const char this_mod[] = "__this_module"; > - char modname[MAX_PARAM_PREFIX_LEN + sizeof(this_mod) + 2]; > + char modname[MODULE_NAME_LEN + sizeof(this_mod) + 2]; > unsigned long val; > int n; > LGTM, Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
On Mon, 28 Jul 2025 08:48:01 +0200 Daniel Gomez <da.gomez@kernel.org> wrote: > On 30/06/2025 16.32, Petr Pavlu wrote: > > Use the MODULE_NAME_LEN definition in module_exists() to obtain the maximum > > size of a module name, instead of using MAX_PARAM_PREFIX_LEN. The values > > are the same but MODULE_NAME_LEN is more appropriate in this context. > > MAX_PARAM_PREFIX_LEN was added in commit 730b69d22525 ("module: check > > kernel param length at compile time, not runtime") only to break a circular > > dependency between module.h and moduleparam.h, and should mostly be limited > > to use in moduleparam.h. > > > > Signed-off-by: Petr Pavlu <petr.pavlu@suse.com> > > Cc: Steven Rostedt <rostedt@goodmis.org> > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > > Steven, Masami, > > I'm planning to merge these series into modules-next. I think and Ack/Review > would be great from you. Otherwise, let me know if you'd rather take this patch > through tracing instead (in case it looks good from your side). Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> > > > --- > > > > As a side note, I suspect the function module_exists() would be better > > replaced with !!find_module() + RCU locking, but that is a separate issue. Yeah, that is probably something that should be done too. Thanks, -- Steve
© 2016 - 2025 Red Hat, Inc.