mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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: 9294523e37 ("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>
This commit is contained in:
parent
cd6735896d
commit
e8a1e7eaa1
3 changed files with 10 additions and 5 deletions
|
|
@ -87,11 +87,13 @@ struct ftrace_hash;
|
|||
defined(CONFIG_DYNAMIC_FTRACE)
|
||||
int
|
||||
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
|
||||
unsigned long *off, char **modname, char *sym);
|
||||
unsigned long *off, char **modname,
|
||||
const unsigned char **modbuildid, char *sym);
|
||||
#else
|
||||
static inline int
|
||||
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
|
||||
unsigned long *off, char **modname, char *sym)
|
||||
unsigned long *off, char **modname,
|
||||
const unsigned char **modbuildid, char *sym)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -389,8 +389,8 @@ static int kallsyms_lookup_buildid(unsigned long addr,
|
|||
ret = bpf_address_lookup(addr, symbolsize, offset, namebuf);
|
||||
|
||||
if (!ret)
|
||||
ret = ftrace_mod_address_lookup(addr, symbolsize,
|
||||
offset, modname, namebuf);
|
||||
ret = ftrace_mod_address_lookup(addr, symbolsize, offset,
|
||||
modname, modbuildid, namebuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7753,7 +7753,8 @@ ftrace_func_address_lookup(struct ftrace_mod_map *mod_map,
|
|||
|
||||
int
|
||||
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
|
||||
unsigned long *off, char **modname, char *sym)
|
||||
unsigned long *off, char **modname,
|
||||
const unsigned char **modbuildid, char *sym)
|
||||
{
|
||||
struct ftrace_mod_map *mod_map;
|
||||
int ret = 0;
|
||||
|
|
@ -7765,6 +7766,8 @@ ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
|
|||
if (ret) {
|
||||
if (modname)
|
||||
*modname = mod_map->mod->name;
|
||||
if (modbuildid)
|
||||
*modbuildid = module_buildid(mod_map->mod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue