From: Martin Schiller <ms@dev.tdt.de>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>
Cc: Hui Peng <benquike@gmail.com>,
linux-x25@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Martin Schiller <ms@dev.tdt.de>
Subject: [PATCH net v2] net: lapb: fix uninitialized stack frame fields in lapb_decode()
Date: Mon, 30 Nov 2026 10:00:43 +0100 (CET) [thread overview]
Message-ID: <20261130-lapb-decode-v2-1-d441aa763c33@dev.tdt.de> (raw)
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>
reply other threads:[~2026-11-30 9:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261130-lapb-decode-v2-1-d441aa763c33@dev.tdt.de \
--to=ms@dev.tdt.de \
--cc=benquike@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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