Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Martin Schiller
Tue, 01 Dec 2026 11:41
[PATCH net v3] net: wan: lapbether: validate the frame length in lapbeth_rcv()
Author: Martin Schiller
Date: Tue, 01 Dec 2026 11:41
Date: Tue, 01 Dec 2026 11:41
97 lines
13686 bytes
13686 bytes
From: Hui Peng <benquike@gmail.com>
lapbeth_rcv() takes the length of the LAPB frame from a 2-byte field in
front of it and trims the skb to that length with skb_trim().
skb_trim() only works on linear skbs: a nonlinear skb hits the
WARN_ON() in __skb_set_length() and is not trimmed at all, so LAPB
gets the Ethernet padding as part of the frame. A length field that is
larger than the received data is not caught either.
Use pskb_trim(), which trims nonlinear skbs as well, and drop frames
whose length field is larger than the received data. Count a frame in
the statistics only once it has been accepted. The checksum handling
of pskb_trim_rcsum() is not needed here: the length bytes are removed
with a plain skb_pull(), and neither LAPB nor X.25 looks at skb->csum.
lapbether handles every ETH_P_DEC frame, so any peer on the Ethernet
segment can send such frames, and NIC drivers that build skbs from page
fragments deliver them as nonlinear skbs. As the WARN_ON() fires for
every such frame, a remote peer can flood the log, or take the machine
down with panic_on_warn.
It is also easy to trigger locally without kernel changes: a packet
socket with a virtio-net header and a small hdr_len builds a nonlinear
skb for a frame larger than a page, and a veth pair hands it to
lapbether unchanged. With a length field shorter than the frame, an
unpatched kernel warns:
WARNING: ./include/linux/skbuff.h:3347 at skb_trim+0xf/0x18, CPU#0: x25test/26
Call Trace:
<IRQ>
lapbeth_rcv+0x130/0x178
__netif_receive_skb_one_core+0x3e/0x44
process_backlog+0x85/0x1c5
__napi_poll.constprop.0+0x1f/0x107
net_rx_action+0x134/0x26c
handle_softirqs+0x14c/0x2e5
With this patch the frame is trimmed without a warning.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Hui Peng <benquike@gmail.com>
[ms: use pskb_trim(), drop short frames, rewrite the message]
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
Changes in v3:
- use pskb_trim() instead of pskb_trim_rcsum(), which could drop frames
because of their checksum state
- mention the remote trigger, add Cc: stable
- v3 was prepared with the help of an AI assistant (Claude, Anthropic)
- Link to v2: https://lore.kernel.org/r/20261130-lapbether-length-v2-1-db62bd1e2ea7@dev.tdt.de
Changes in v2:
- also drop frames whose length field is larger than the received data
- new subject and commit message that describe the actual change; v1
also mentioned pskb_may_pull() and headroom changes that were not
part of the patch
- add how to trigger the warning
- 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/20260919223433.3882618-1-benquike@gmail.com/
---
drivers/net/wan/lapbether.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index c3630a82913bfa300d6e9add078b9bfab51755cc..7099a613be1bb84d2283272ba5a54a8385436760 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -133,11 +133,14 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev,
goto drop_unlock;
len = skb->data[0] + skb->data[1] * 256;
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += len;
skb_pull(skb, 2); /* Remove the length bytes */
- skb_trim(skb, len); /* Set the length of the data */
+ /* Drop frames that are shorter than their length field */
+ if (len > skb->len || pskb_trim(skb, len))
+ goto drop_unlock;
+
+ dev->stats.rx_packets++;
+ dev->stats.rx_bytes += len;
err = lapb_data_received(lapbeth->axdev, skb);
if (err != LAPB_OK) {
---
base-commit: d73525e6950b982fb67c74a1a64163529305a003
change-id: 20261130-lapbether-length-a3c09a48be6a
Best regards,
--
Martin Schiller <ms@dev.tdt.de>
Re: [PATCH net v3] net: wan: lapbether: validate the frame length in lapbeth_rcv()
Author: netdev-bot+sinfo
Date: Tue, 01 Dec 2026 11:43
Date: Tue, 01 Dec 2026 11:43
19 lines
8531 bytes
8531 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net v3] net: wan: lapbether: validate the frame length in lapbeth_rcv()
Author: Martin Schiller
Date: Tue, 01 Dec 2026 12:07
Date: Tue, 01 Dec 2026 12:07
13 lines
10061 bytes
10061 bytes
On Tue, 01 Dec 2026 12:43:09 +0100, netdev-bot wrote: > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. Hui Peng found the issue and posted v1 [1]. v1 does not say how he found it; it carried an "Assisted-by: LLM" line, so an LLM was involved at least in preparing the patch. I took the patch over and confirmed the issue at runtime with the reproducer described in the commit message, without kernel changes. [1] https://lore.kernel.org/all/20260919223433.3882618-1-benquike@gmail.com/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads