Skip to content

Commit 9ef4ca5

Browse files
pmladekKernel Patches Daemon
authored andcommitted
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(). Fixes: 9294523 ("module: add printk formats to add module build ID to stacktraces") Signed-off-by: Petr Mladek <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]>
1 parent 19d6531 commit 9ef4ca5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

include/linux/ftrace.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ struct ftrace_hash;
8787
defined(CONFIG_DYNAMIC_FTRACE)
8888
int
8989
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);
9192
#else
9293
static inline int
9394
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)
9597
{
9698
return 0;
9799
}

kernel/kallsyms.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ static int kallsyms_lookup_buildid(unsigned long addr,
378378
modname, modbuildid, namebuf);
379379

380380
if (!ret)
381-
ret = ftrace_mod_address_lookup(addr, symbolsize,
382-
offset, modname, namebuf);
381+
ret = ftrace_mod_address_lookup(addr, symbolsize, offset,
382+
modname, modbuildid, namebuf);
383383

384384
return ret;
385385
}

kernel/trace/ftrace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7678,7 +7678,8 @@ ftrace_func_address_lookup(struct ftrace_mod_map *mod_map,
76787678

76797679
int
76807680
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
7681-
unsigned long *off, char **modname, char *sym)
7681+
unsigned long *off, char **modname,
7682+
const unsigned char **modbuildid, char *sym)
76827683
{
76837684
struct ftrace_mod_map *mod_map;
76847685
int ret = 0;
@@ -7690,6 +7691,8 @@ ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
76907691
if (ret) {
76917692
if (modname)
76927693
*modname = mod_map->mod->name;
7694+
if (modbuildid)
7695+
*modbuildid = module_buildid(mod_map->mod);
76937696
break;
76947697
}
76957698
}

0 commit comments

Comments
 (0)