linux/kernel/module
Sebastian Andrzej Siewior 570db4b39f module: Make sure relocations are applied to the per-CPU section
The per-CPU data section is handled differently than the other sections.
The memory allocations requires a special __percpu pointer and then the
section is copied into the view of each CPU. Therefore the SHF_ALLOC
flag is removed to ensure move_module() skips it.

Later, relocations are applied and apply_relocations() skips sections
without SHF_ALLOC because they have not been copied. This also skips the
per-CPU data section.
The missing relocations result in a NULL pointer on x86-64 and very
small values on x86-32. This results in a crash because it is not
skipped like NULL pointer would and can't be dereferenced.

Such an assignment happens during static per-CPU lock initialisation
with lockdep enabled.

Allow relocation processing for the per-CPU section even if SHF_ALLOC is
missing.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202506041623.e45e4f7d-lkp@intel.com
Fixes: 1a6100caae425 ("Don't relocate non-allocated regions in modules.") #v2.6.1-rc3
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Link: https://lore.kernel.org/r/20250610163328.URcsSUC1@linutronix.de
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
Message-ID: <20250610163328.URcsSUC1@linutronix.de>
2025-07-08 20:52:30 +02:00
..
debug_kmemleak.c
decompress.c
dups.c
internal.h module: Add a separate function to mark sections as read-only after init 2025-05-18 13:56:21 +02:00
kallsyms.c module: Use RCU in all users of __module_address(). 2025-03-10 11:54:45 +01:00
Kconfig kbuild: Require pahole <v1.28 or >v1.29 with GENDWARFKSYMS on X86 2025-05-12 15:03:16 +09:00
kdb.c
kmod.c
livepatch.c
main.c module: Make sure relocations are applied to the per-CPU section 2025-07-08 20:52:30 +02:00
Makefile
procfs.c
signing.c
stats.c
strict_rwx.c module: Make .static_call_sites read-only after init 2025-05-18 13:56:22 +02:00
sysfs.c Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
tracking.c module: Remove module_assert_mutex_or_preempt() from try_add_tainted_module(). 2025-03-10 11:54:44 +01:00
tree_lookup.c module: Begin to move from RCU-sched to RCU. 2025-03-10 11:54:43 +01:00
version.c module: Use RCU in find_symbol(). 2025-03-10 11:54:44 +01:00