Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] net: lapb: fix uninitialized stack frame fields in lapb_decode()
@ 2026-11-30  9:00 Martin Schiller
  0 siblings, 0 replies; only message in thread
From: Martin Schiller @ 2026-11-30  9:00 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman
  Cc: Hui Peng, linux-x25, netdev, linux-kernel, Martin Schiller

From: Hui Peng <benquike@gmail.com>

lapb_decode() fills a struct lapb_frame on the stack of
lapb_data_input(), but sets frame->cr only if the address byte of the
received frame is one of the two values expected for the configured
mode. For any other address byte, frame->cr stays uninitialized, and
it is used later: lapb_check_need_response() decides from it whether
to answer the frame, and lapb_transmit_frmr() sets a bit of an FRMR
frame from it. How such a frame is handled therefore depends on
leftover stack contents.

Zero the frame at the start of lapb_decode(). A frame with an
unexpected address byte is then neither a command nor a response, so
it is not answered, and an FRMR for it does not mark it as a response.

This has not been reproduced at runtime: without KMSAN, the
uninitialized value causes no warning, only behaviour that depends on
the stack contents. The fix was validated by code inspection.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Hui Peng <benquike@gmail.com>
[ms: keep only the initialization, rewrite the commit message]
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
v2 (Martin Schiller):
- keep only the initialization; dropping frames with an unexpected
  address byte changes the protocol behaviour and belongs in net-next
- rewrite the commit message: only frame->cr is affected, control[1]
  is always set in extended mode and never sent in standard mode
- drop the Assisted-by line; v1 said an LLM was used, without naming
  which
- v2 was prepared with the help of an AI assistant (Claude, Anthropic)
- Link to v1: https://lore.kernel.org/all/20260919213639.3314894-1-benquike@gmail.com/
---
 net/lapb/lapb_subr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/lapb/lapb_subr.c b/net/lapb/lapb_subr.c
index 592a22d86a97d0d591886ecf9d7d81d726ce5eb8..6911e6269d1f58976e3b80c6c817d340e376a2d5 100644
--- a/net/lapb/lapb_subr.c
+++ b/net/lapb/lapb_subr.c
@@ -106,6 +106,7 @@ int lapb_validate_nr(struct lapb_cb *lapb, unsigned short nr)
 int lapb_decode(struct lapb_cb *lapb, struct sk_buff *skb,
 		struct lapb_frame *frame)
 {
+	memset(frame, 0, sizeof(*frame));
 	frame->type = LAPB_ILLEGAL;
 
 	lapb_dbg(2, "(%p) S%d RX %3ph\n", lapb->dev, lapb->state, skb->data);

---
base-commit: e2fb9368a41662bc54624f9be87ea8989b109306
change-id: 20261130-lapb-decode-86833403f849

Best regards,
-- 
Martin Schiller <ms@dev.tdt.de>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30  9:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  9:00 [PATCH net v2] net: lapb: fix uninitialized stack frame fields in lapb_decode() Martin Schiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox