mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: wan: lapbether: validate frame length and headroom in lapbeth_rcv() and xmit
@ 2026-09-19 22:34 Hui Peng
  2026-09-20 22:34 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Peng @ 2026-09-19 22:34 UTC (permalink / raw)
  To: ms, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: linux-x25, netdev, linux-kernel

In drivers/net/wan/lapbether.c, call pskb_may_pull() before reading the
2-byte length prefix in lapbeth_rcv() and ensure sufficient headroom in
lapbeth_data_transmit().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index c3630a82913b..3838910ea7bd 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -133,11 +133,13 @@ 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 */
+	if (pskb_trim_rcsum(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) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-20 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 22:34 [PATCH] net: wan: lapbether: validate frame length and headroom in lapbeth_rcv() and xmit Hui Peng
2026-09-20 22:34 ` netdev-bot+sashiko

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

all inboxes | Powered by JetHome®