* [PATCH v3] ARM: module.lds: fix unwind metadata for merged .text sections
@ 2026-05-30 15:46 Egg12138
2026-05-30 15:56 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Egg12138 @ 2026-05-30 15:46 UTC (permalink / raw)
To: Russell King
Cc: Josh Poimboeuf, Petr Mladek, linux-arm-kernel, linux-modules,
linux-kernel, Xiao Junzhe
From: Xiao Junzhe <egg12138@foxmail.com>
Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN,
and related macros") made scripts/module.lds.S merge module input
.text.* sections into the output .text section.
On ARM, the paired unwind input sections keep their original names. A
module can therefore contain .ARM.exidx.text.unlikely with sh_link
pointing at .text, while .text.unlikely no longer exists.
This is a valid ELF relationship, but ARM module_finalize() does not use
sh_link when registering module unwind tables. It derives the target
text section from the exidx section name instead:
.ARM.exidx.text.unlikely -> .text.unlikely
The lookup fails and the unwind table is not registered for the actual
.text range. This can make module stack unwinding fail with:
unwind: Index not found
Keep the ARM module unwind output names in sync with the text sections
that scripts/module.lds.S now produces. Coalesce the .ARM.exidx/.ARM.extab
section associated with .text.*, into the
stable output names expected by the existing ARM module unwind code.
Fixes: 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Signed-off-by: Xiao Junzhe <egg12138@foxmail.com>
---
Changes in v3:
- Apply the ARM unwind section coalescing under CONFIG_ARM_UNWIND.
- Remove quotes around linker-script wildcard patterns so GNU ld expands
them correctly.
- Use conventional linker-script wildcard syntax, i.e. *(...) without a
space after the wildcard.
arch/arm/include/asm/module.lds.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
index 0e7cb4e314b4..1d56c0375c18 100644
--- a/arch/arm/include/asm/module.lds.h
+++ b/arch/arm/include/asm/module.lds.h
@@ -1,4 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifdef CONFIG_ARM_UNWIND
+SECTIONS {
+ .ARM.extab 0 : {
+ *(.ARM.extab .ARM.extab.text .ARM.extab.text.[0-9a-zA-Z_]*)
+ }
+ .ARM.exidx 0 : {
+ *(.ARM.exidx .ARM.exidx.text .ARM.exidx.text.[0-9a-zA-Z_]*)
+ }
+}
+#endif
+
#ifdef CONFIG_ARM_MODULE_PLTS
SECTIONS {
.plt : { BYTE(0) }
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ARM: module.lds: fix unwind metadata for merged .text sections
2026-05-30 15:46 [PATCH v3] ARM: module.lds: fix unwind metadata for merged .text sections Egg12138
@ 2026-05-30 15:56 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-05-30 15:56 UTC (permalink / raw)
To: Egg12138; +Cc: linux-modules
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing NULL check on the return value of `unwind_table_add()` in `module_finalize()` causes a kernel panic on memory allocation failure.
--
commit 0098f68f3e89e8e569da9c5eaaa9486505d4ea3d
Author: Xiao Junzhe <egg12138@foxmail.com>
ARM: module.lds: fix unwind metadata for merged .text sections
Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN,
and related macros") made scripts/module.lds.S merge module input
.text.* sections into the output .text section. On ARM, the paired
unwind input sections keep their original names. This commit ensures
the ARM module unwind output names stay in sync with the text sections.
> diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
> index 0e7cb4e314b48..1d56c0375c18b 100644
> --- a/arch/arm/include/asm/module.lds.h
> +++ b/arch/arm/include/asm/module.lds.h
> @@ -1,4 +1,16 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifdef CONFIG_ARM_UNWIND
> +SECTIONS {
> + .ARM.extab 0 : {
> + *(.ARM.extab .ARM.extab.text .ARM.extab.text.[0-9a-zA-Z_]*)
> + }
> + .ARM.exidx 0 : {
> + *(.ARM.exidx .ARM.exidx.text .ARM.exidx.text.[0-9a-zA-Z_]*)
> + }
> +}
> +#endif
[Severity: High]
This is a pre-existing issue and was not introduced by the patch under review,
but while reviewing how ARM module unwind tables are registered, I noticed a
potential concern in arch/arm/kernel/module.c:
arch/arm/kernel/module.c:module_finalize() {
...
if (txt_sec) {
struct unwind_table *table =
unwind_table_add(s->sh_addr,
s->sh_size,
txt_sec->sh_addr,
txt_sec->sh_size);
list_add(&table->mod_list, unwind_list);
...
}
Does this code safely handle a null return from unwind_table_add?
If unwind_table_add fails to allocate memory, it returns a null pointer.
Passing that directly to list_add causes an offset-based dereference of null.
Could this trigger a kernel panic during module loading if the system is out
of memory?
> +
> #ifdef CONFIG_ARM_MODULE_PLTS
> SECTIONS {
> .plt : { BYTE(0) }
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_08845B64E5F38EB7FA1779982A071AB4A607@qq.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-30 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-30 15:46 [PATCH v3] ARM: module.lds: fix unwind metadata for merged .text sections Egg12138
2026-05-30 15:56 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox