Skip to content

Commit ee86a9d

Browse files
pmladekKernel Patches Daemon
authored andcommitted
kallsyms/bpf: Set module buildid in bpf_address_lookup()
Make bpf_address_lookup() compatible with module_address_lookup() and clear the pointer to @modbuildid together with @modname. It is not strictly needed because __sprint_symbol() reads @modbuildid only when @modname is set. But better be on the safe side and make the API more safe. Fixes: 9294523 ("module: add printk formats to add module build ID to stacktraces") Signed-off-by: Petr Mladek <[email protected]>
1 parent 0679a7f commit ee86a9d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

include/linux/filter.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,12 +1362,18 @@ struct bpf_prog *bpf_prog_ksym_find(unsigned long addr);
13621362

13631363
static inline int
13641364
bpf_address_lookup(unsigned long addr, unsigned long *size,
1365-
unsigned long *off, char **modname, char *sym)
1365+
unsigned long *off, char **modname,
1366+
const unsigned char **modbuildid, char *sym)
13661367
{
13671368
int ret = __bpf_address_lookup(addr, size, off, sym);
13681369

1369-
if (ret && modname)
1370-
*modname = NULL;
1370+
if (ret) {
1371+
if (modname)
1372+
*modname = NULL;
1373+
if (modbuildid)
1374+
*modbuildid = NULL;
1375+
}
1376+
13711377
return ret;
13721378
}
13731379

@@ -1433,7 +1439,8 @@ static inline struct bpf_prog *bpf_prog_ksym_find(unsigned long addr)
14331439

14341440
static inline int
14351441
bpf_address_lookup(unsigned long addr, unsigned long *size,
1436-
unsigned long *off, char **modname, char *sym)
1442+
unsigned long *off, char **modname,
1443+
const unsigned char **modbuildid, char *sym)
14371444
{
14381445
return 0;
14391446
}

kernel/kallsyms.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ static int kallsyms_lookup_buildid(unsigned long addr,
374374
ret = module_address_lookup(addr, symbolsize, offset,
375375
modname, modbuildid, namebuf);
376376
if (!ret)
377-
ret = bpf_address_lookup(addr, symbolsize,
378-
offset, modname, namebuf);
377+
ret = bpf_address_lookup(addr, symbolsize, offset,
378+
modname, modbuildid, namebuf);
379379

380380
if (!ret)
381381
ret = ftrace_mod_address_lookup(addr, symbolsize,

0 commit comments

Comments
 (0)