Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kallsyms/ftrace: set module buildid in ftrace_mod_address_lookup()

__sprint_symbol() might access an invalid pointer when
kallsyms_lookup_buildid() returns a symbol found by
ftrace_mod_address_lookup().

The ftrace lookup function must set both @modname and @modbuildid the same
way as module_address_lookup().

Link: https://lkml.kernel.org/r/20251128135920.217303-7-pmladek@suse.com
Fixes: 9294523e3768 ("module: add printk formats to add module build ID to stacktraces")
Signed-off-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Petr Mladek and committed by
Andrew Morton
e8a1e7ea cd673589

+10 -5
+4 -2
include/linux/ftrace.h
··· 87 87 defined(CONFIG_DYNAMIC_FTRACE) 88 88 int 89 89 ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, 90 - unsigned long *off, char **modname, char *sym); 90 + unsigned long *off, char **modname, 91 + const unsigned char **modbuildid, char *sym); 91 92 #else 92 93 static inline int 93 94 ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, 94 - unsigned long *off, char **modname, char *sym) 95 + unsigned long *off, char **modname, 96 + const unsigned char **modbuildid, char *sym) 95 97 { 96 98 return 0; 97 99 }
+2 -2
kernel/kallsyms.c
··· 389 389 ret = bpf_address_lookup(addr, symbolsize, offset, namebuf); 390 390 391 391 if (!ret) 392 - ret = ftrace_mod_address_lookup(addr, symbolsize, 393 - offset, modname, namebuf); 392 + ret = ftrace_mod_address_lookup(addr, symbolsize, offset, 393 + modname, modbuildid, namebuf); 394 394 395 395 return ret; 396 396 }
+4 -1
kernel/trace/ftrace.c
··· 7753 7753 7754 7754 int 7755 7755 ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, 7756 - unsigned long *off, char **modname, char *sym) 7756 + unsigned long *off, char **modname, 7757 + const unsigned char **modbuildid, char *sym) 7757 7758 { 7758 7759 struct ftrace_mod_map *mod_map; 7759 7760 int ret = 0; ··· 7766 7765 if (ret) { 7767 7766 if (modname) 7768 7767 *modname = mod_map->mod->name; 7768 + if (modbuildid) 7769 + *modbuildid = module_buildid(mod_map->mod); 7769 7770 break; 7770 7771 } 7771 7772 }