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 2baa8d4a33ed3..1a068859a4185 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -1600,35 +1600,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);