Skip to content

Commit 05e8063

Browse files
committed
kallsyms: clean up modname and modbuildid initialization in kallsyms_lookup_buildid()
jira KERNEL-629 bugfix Fix sched_ext:select_cpu_dispatch_dbl_dsp selftest crash commit-author Petr Mladek <pmladek@suse.com> commit fda024f The @modname and @modbuildid optional return parameters are set only when the symbol is in a module. Always initialize them so that they do not need to be cleared when the module is not in a module. It simplifies the logic and makes the code even slightly more safe. Note that bpf_address_lookup() function will get updated in a separate patch. Link: https://lkml.kernel.org/r/20251128135920.217303-3-pmladek@suse.com Signed-off-by: Petr Mladek <pmladek@suse.com> Cc: Aaron Tomlin <atomlin@atomlin.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkman <daniel@iogearbox.net> Cc: Daniel Gomez <da.gomez@samsung.com> Cc: John Fastabend <john.fastabend@gmail.com> Cc: Kees Cook <kees@kernel.org> Cc: Luis Chamberalin <mcgrof@kernel.org> Cc: Marc Rutland <mark.rutland@arm.com> Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org> Cc: Petr Pavlu <petr.pavlu@suse.com> Cc: Sami Tolvanen <samitolvanen@google.com> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit fda024f) Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent 264637b commit 05e8063

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

kernel/kallsyms.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ static int kallsyms_lookup_buildid(unsigned long addr,
357357

358358
namebuf[KSYM_NAME_LEN - 1] = 0;
359359
namebuf[0] = 0;
360+
/*
361+
* Initialize the module-related return values. They are not set
362+
* when the symbol is in vmlinux or it is a bpf address.
363+
*/
364+
if (modname)
365+
*modname = NULL;
366+
if (modbuildid)
367+
*modbuildid = NULL;
360368

361369
if (is_ksym_addr(addr)) {
362370
unsigned long pos;
@@ -365,10 +373,6 @@ static int kallsyms_lookup_buildid(unsigned long addr,
365373
/* Grab name */
366374
kallsyms_expand_symbol(get_symbol_offset(pos),
367375
namebuf, KSYM_NAME_LEN);
368-
if (modname)
369-
*modname = NULL;
370-
if (modbuildid)
371-
*modbuildid = NULL;
372376

373377
return strlen(namebuf);
374378
}

0 commit comments

Comments
 (0)