Skip to content

Commit 485983b

Browse files
pmladekKernel Patches Daemon
authored andcommitted
kallsyms: Prevent module removal when printing module name and buildid
kallsyms_lookup_buildid() copies the symbol name into the given buffer so that it can be safely read anytime later. But it just copies pointers to mod->name and mod->build_id which might get reused after the related struct module gets removed. The lifetime of struct module is synchronized using RCU. Take the rcu read lock for the entire __sprint_symbol(). Signed-off-by: Petr Mladek <[email protected]>
1 parent 5c77fea commit 485983b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/kallsyms.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ static int __sprint_symbol(char *buffer, unsigned long address,
468468
unsigned long offset, size;
469469
int len;
470470

471+
/* Prevent module removal until modname and modbuildid are printed */
472+
guard(rcu)();
473+
471474
address += symbol_offset;
472475
len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
473476
buffer);

0 commit comments

Comments
 (0)