Skip to content

Commit 6de03b4

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(). Reviewed-by: Aaron Tomlin <[email protected]> Signed-off-by: Petr Mladek <[email protected]>
1 parent d314756 commit 6de03b4

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
@@ -471,6 +471,9 @@ static int __sprint_symbol(char *buffer, unsigned long address,
471471
unsigned long offset, size;
472472
int len;
473473

474+
/* Prevent module removal until modname and modbuildid are printed */
475+
guard(rcu)();
476+
474477
address += symbol_offset;
475478
len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
476479
buffer);

0 commit comments

Comments
 (0)