From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Fangrui Song <i@maskray.me>,
Nathan Chancellor <nathan@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Sasha Levin <sashal@kernel.org>,
paul.walmsley@sifive.com, aou@eecs.berkeley.edu,
tglx@linutronix.de, namcao@linutronix.de,
thomas.weissschuh@linutronix.de, linux-riscv@lists.infradead.org,
llvm@lists.linux.dev
Subject: [PATCH AUTOSEL 6.12 18/21] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
Date: Mon, 30 Jun 2025 16:45:33 -0400 [thread overview]
Message-ID: <20250630204536.1358327-18-sashal@kernel.org> (raw)
In-Reply-To: <20250630204536.1358327-1-sashal@kernel.org>
From: Fangrui Song <i@maskray.me>
[ Upstream commit e0eb1b6b0cd29ca7793c501d5960fd36ba11f110 ]
.rodata is implicitly included in the PT_DYNAMIC segment due to
inheriting the segment of the preceding .dynamic section (in both GNU ld
and LLD). When the .rodata section's size is not a multiple of 16
bytes on riscv64, llvm-readelf will report a "PT_DYNAMIC dynamic table
is invalid" warning. Note: in the presence of the .dynamic section, GNU
readelf and llvm-readelf's -d option decodes the dynamic section using
the section.
This issue arose after commit 8f8c1ff879fab60f80f3a7aec3000f47e5b03ba9
("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr"), which
placed .rodata directly after .dynamic by removing .eh_frame.
This patch resolves the implicit inclusion into PT_DYNAMIC by explicitly
specifying the :text output section phdr.
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://github.com/ClangBuiltLinux/linux/issues/2093
Signed-off-by: Fangrui Song <i@maskray.me>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20250602-riscv-vdso-v1-1-0620cf63cff0@maskray.me
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
**YES**
This commit should be backported to stable kernel trees for the
following reasons:
1. **Regression Fix**: The commit explicitly fixes a regression
introduced by commit 8f8c1ff879fab60f80f3a7aec3000f47e5b03ba9
("riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr").
Regression fixes are high-priority candidates for stable backporting.
2. **Fixes Invalid ELF Structure**: The issue is not merely cosmetic.
The PT_DYNAMIC segment is reported as "invalid" by llvm-readelf,
indicating the ELF structure is technically incorrect. From the
linker script:
```
.dynamic : { *(.dynamic) } :text :dynamic
.rodata : {
...
} // implicitly inherits :dynamic from previous section
```
Without the explicit `:text` specification, `.rodata` inherits the
segment attributes from the preceding `.dynamic` section, incorrectly
including it in the PT_DYNAMIC segment.
3. **Minimal and Safe Change**: The fix is a single-line change that
adds `:text` to the `.rodata` section definition:
```diff
- }
+ } :text
```
This explicitly places `.rodata` in the text segment only, excluding
it from PT_DYNAMIC. The change has no functional impact beyond
correcting the ELF structure.
4. **Similar to Previous Backported Commits**: This is similar to commit
#2 in the reference list ("riscv: vdso: fix section overlapping under
some conditions") which was marked YES for backporting. Both commits
fix structural issues in the vDSO linker script that cause
build/tooling errors.
5. **Potential for Broader Impact**: While the immediate symptom is a
warning from llvm-readelf, an invalid PT_DYNAMIC segment could
potentially cause issues with:
- Build systems that validate ELF structures
- Runtime loaders with strict ELF validation
- Debugging and analysis tools
- Future toolchain versions that may be less tolerant of invalid
structures
The commit meets the stable tree criteria: it fixes an important bug
(invalid ELF structure), the fix is small and contained, and there's
minimal risk of regression.
arch/riscv/kernel/vdso/vdso.lds.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
index cbe2a179331d2..99e51f7755393 100644
--- a/arch/riscv/kernel/vdso/vdso.lds.S
+++ b/arch/riscv/kernel/vdso/vdso.lds.S
@@ -31,7 +31,7 @@ SECTIONS
*(.data .data.* .gnu.linkonce.d.*)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
- }
+ } :text
.note : { *(.note.*) } :text :note
--
2.39.5
next prev parent reply other threads:[~2025-06-30 21:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 20:45 [PATCH AUTOSEL 6.12 01/21] ublk: sanity check add_dev input for underflow Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 02/21] atm: idt77252: Add missing `dma_map_error()` Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 03/21] um: vector: Reduce stack usage in vector_eth_configure() Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 04/21] ASoC: SOF: Intel: hda: Use devm_kstrdup() to avoid memleak Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 05/21] Revert "PCI/ACPI: Fix allocated memory release on error in pci_acpi_scan_root()" Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 06/21] ALSA: hda/realtek: Add mic-mute LED setup for ASUS UM5606 Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 07/21] io_uring: make fallocate be hashed work Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 08/21] ASoC: amd: yc: add quirk for Acer Nitro ANV15-41 internal mic Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 09/21] ALSA: hda/realtek - Enable mute LED on HP Pavilion Laptop 15-eg100 Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 10/21] ALSA: hda/realtek: Add quirks for some Clevo laptops Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 11/21] net: usb: qmi_wwan: add SIMCom 8230C composition Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 12/21] driver: bluetooth: hci_qca:fix unable to load the BT driver Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 13/21] HID: lenovo: Add support for ThinkPad X1 Tablet Thin Keyboard Gen2 Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 14/21] net: mana: Record doorbell physical address in PF mode Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 15/21] btrfs: fix assertion when building free space tree Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 16/21] vt: add missing notification when switching back to text mode Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 17/21] bpf: Adjust free target to avoid global starvation of LRU map Sasha Levin
2025-06-30 20:45 ` Sasha Levin [this message]
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 19/21] HID: Add IGNORE quirk for SMARTLINKTECHNOLOGY Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 20/21] HID: quirks: Add quirk for 2 Chicony Electronics HP 5MP Cameras Sasha Levin
2025-06-30 20:45 ` [PATCH AUTOSEL 6.12 21/21] HID: nintendo: avoid bluetooth suspend/resume stalls Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250630204536.1358327-18-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=i@maskray.me \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=namcao@linutronix.de \
--cc=nathan@kernel.org \
--cc=palmer@dabbelt.com \
--cc=patches@lists.linux.dev \
--cc=paul.walmsley@sifive.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox