module: Use proper RCU assignment in add_kallsyms().
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 8 Jan 2025 09:04:32 +0000 (10:04 +0100)
committerPetr Pavlu <petr.pavlu@suse.com>
Mon, 10 Mar 2025 10:54:44 +0000 (11:54 +0100)
commit039de46874bb08fef027342c9c5077f2ea85ab42
treec70777059d32bb2741ea0ef28440afaa539d7743
parent838e6dd8b59262d0b59041d65d21331daa83dd36
module: Use proper RCU assignment in add_kallsyms().

add_kallsyms() assigns the RCU pointer module::kallsyms and setups the
structures behind it which point to init-data. The module was not
published yet, nothing can see the kallsyms pointer and the data behind
it. Also module's init function was not yet invoked.
There is no need to use rcu_dereference() here, it is just to keep
checkers quiet. The whole RCU read section is also not needed.

Use a local kallsyms pointer and setup the data structures. Assign that
pointer to the data structure at the end via rcu_assign_pointer().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250108090457.512198-4-bigeasy@linutronix.de
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
kernel/module/kallsyms.c