* [PATCH AUTOSEL 6.15 03/23] um: vector: Reduce stack usage in vector_eth_configure()
[not found] <20250630204429.1357695-1-sashal@kernel.org>
@ 2025-06-30 20:44 ` Sasha Levin
2025-06-30 20:44 ` [PATCH AUTOSEL 6.15 20/23] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment Sasha Levin
1 sibling, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-06-30 20:44 UTC (permalink / raw)
To: patches, stable
Cc: Tiwei Bie, kernel test robot, Johannes Berg, Sasha Levin, nathan,
richard, anton.ivanov, agordeev, akpm, guoweikang.kernel, tglx,
bpf, llvm
From: Tiwei Bie <tiwei.btw@antgroup.com>
[ Upstream commit 2d65fc13be85c336c56af7077f08ccd3a3a15a4a ]
When compiling with clang (19.1.7), initializing *vp using a compound
literal may result in excessive stack usage. Fix it by initializing the
required fields of *vp individually.
Without this patch:
$ objdump -d arch/um/drivers/vector_kern.o | ./scripts/checkstack.pl x86_64 0
...
0x0000000000000540 vector_eth_configure [vector_kern.o]:1472
...
With this patch:
$ objdump -d arch/um/drivers/vector_kern.o | ./scripts/checkstack.pl x86_64 0
...
0x0000000000000540 vector_eth_configure [vector_kern.o]:208
...
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506221017.WtB7Usua-lkp@intel.com/
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20250623110829.314864-1-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
**YES**
This commit should be backported to stable kernel trees for the
following reasons:
1. **Fixes a real bug**: The commit addresses excessive stack usage
(1472 bytes) that can lead to stack overflow, especially problematic
on systems with limited kernel stack space. This is a legitimate bug
that affects system stability.
2. **Compiler-specific issue with real impact**: While triggered by
clang 19.1.7's handling of compound literals, the resulting stack
usage of 1472 bytes is genuinely excessive and dangerous regardless
of the compiler quirk that exposed it.
3. **Simple and safe fix**: The change is purely mechanical - converting
from compound literal initialization to field-by-field
initialization:
```c
// From:
*vp = ((struct vector_private) { .field = value, ... });
// To:
vp->field = value;
```
4. **Minimal risk**: The fix doesn't change any logic or functionality.
It only changes how the structure is initialized, making it extremely
unlikely to introduce regressions.
5. **Precedent from similar commits**: Looking at the historical commits
marked "YES" for backporting:
- Similar Commit #1: Reduced stack frame in qed driver using
`noinline_for_stack`
- Similar Commit #4: Reduced stack usage in ethtool with clang using
`noinline_for_stack`
Both addressed the same class of problem (excessive stack usage with
clang) and were considered suitable for stable.
6. **Measurable improvement**: The stack usage reduction from 1472 to
208 bytes is dramatic and well-documented by the kernel test robot,
providing clear evidence of the fix's effectiveness.
The commit meets the stable kernel criteria of fixing an important bug
with minimal risk and a contained change. While it doesn't explicitly
include a "Cc: stable" tag, the nature of the fix (preventing potential
stack overflow) makes it a good candidate for stable backporting.
arch/um/drivers/vector_kern.c | 42 +++++++++++------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index b97bb52dd5626..70f8d7e87fb81 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1592,35 +1592,19 @@ static void vector_eth_configure(
device->dev = dev;
- *vp = ((struct vector_private)
- {
- .list = LIST_HEAD_INIT(vp->list),
- .dev = dev,
- .unit = n,
- .options = get_transport_options(def),
- .rx_irq = 0,
- .tx_irq = 0,
- .parsed = def,
- .max_packet = get_mtu(def) + ETH_HEADER_OTHER,
- /* TODO - we need to calculate headroom so that ip header
- * is 16 byte aligned all the time
- */
- .headroom = get_headroom(def),
- .form_header = NULL,
- .verify_header = NULL,
- .header_rxbuffer = NULL,
- .header_txbuffer = NULL,
- .header_size = 0,
- .rx_header_size = 0,
- .rexmit_scheduled = false,
- .opened = false,
- .transport_data = NULL,
- .in_write_poll = false,
- .coalesce = 2,
- .req_size = get_req_size(def),
- .in_error = false,
- .bpf = NULL
- });
+ INIT_LIST_HEAD(&vp->list);
+ vp->dev = dev;
+ vp->unit = n;
+ vp->options = get_transport_options(def);
+ vp->parsed = def;
+ vp->max_packet = get_mtu(def) + ETH_HEADER_OTHER;
+ /*
+ * TODO - we need to calculate headroom so that ip header
+ * is 16 byte aligned all the time
+ */
+ vp->headroom = get_headroom(def);
+ vp->coalesce = 2;
+ vp->req_size = get_req_size(def);
dev->features = dev->hw_features = (NETIF_F_SG | NETIF_F_FRAGLIST);
INIT_WORK(&vp->reset_tx, vector_reset_tx);
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH AUTOSEL 6.15 20/23] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment
[not found] <20250630204429.1357695-1-sashal@kernel.org>
2025-06-30 20:44 ` [PATCH AUTOSEL 6.15 03/23] um: vector: Reduce stack usage in vector_eth_configure() Sasha Levin
@ 2025-06-30 20:44 ` Sasha Levin
1 sibling, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-06-30 20:44 UTC (permalink / raw)
To: patches, stable
Cc: Fangrui Song, Nathan Chancellor, Palmer Dabbelt, Sasha Levin,
paul.walmsley, aou, tglx, thomas.weissschuh, namcao, linux-riscv,
llvm
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 8e86965a8aae4..646e268ede443 100644
--- a/arch/riscv/kernel/vdso/vdso.lds.S
+++ b/arch/riscv/kernel/vdso/vdso.lds.S
@@ -30,7 +30,7 @@ SECTIONS
*(.data .data.* .gnu.linkonce.d.*)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
- }
+ } :text
.note : { *(.note.*) } :text :note
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-30 20:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250630204429.1357695-1-sashal@kernel.org>
2025-06-30 20:44 ` [PATCH AUTOSEL 6.15 03/23] um: vector: Reduce stack usage in vector_eth_configure() Sasha Levin
2025-06-30 20:44 ` [PATCH AUTOSEL 6.15 20/23] riscv: vdso: Exclude .rodata from the PT_DYNAMIC segment Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).