Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Jun Yang
Wed, 25 Nov 2026 07:14
[PATCH net] net/sched: act_csum: reject over-long packets before adding the offset
Author: Jun Yang
Date: Wed, 25 Nov 2026 07:14
Date: Wed, 25 Nov 2026 07:14
71 lines
13287 bytes
13287 bytes
From: Jun Yang <junvyyang@tencent.com>
tcf_csum_skb_nextlayer() validates the claimed packet length @ipl by
calling pskb_may_pull(skb, ipl + ntkoff), where @ntkoff is the offset of
the network header from skb->data and @ipl is taken from the packet
itself.
For IPv6 the action honours the jumbo payload option, so @ipl is derived
from an attacker controlled 32-bit value and can be made to wrap when
@ntkoff is added:
ipl = 0xFFFFFFF2, ntkoff = 14 -> ipl + ntkoff = 0
pskb_may_pull(skb, 0) then succeeds and the ipl < hl check is also
defeated, so tcf_csum_ipv6_udp() hands the packet's own (u16) UDPLITE
length to csum_partial(), which reads up to 65535 bytes from an skb that
is only a few dozen bytes long. The ICMPv6, TCP and SCTP branches pass
ipl - ihl, which is negative as an int, so they do not read.
Reject any @ipl that does not fit in the skb before adding @ntkoff.
BUG: KASAN: slab-use-after-free in do_csum (lib/checksum.c:64)
Read of size 4 at addr ffff88803506ed88 by task act_csum/9648
Call Trace:
do_csum (lib/checksum.c:64)
csum_partial (lib/checksum.c:119)
tcf_csum_ipv6_udp (net/sched/act_csum.c:346)
tcf_csum_act (net/sched/act_csum.c:601)
tcf_action_exec (net/sched/act_api.c:1149)
mall_classify (net/sched/cls_matchall.c:42)
tcf_classify (net/sched/cls_api.c:1875)
tc_run (net/core/dev.c:4635)
__dev_queue_xmit (net/core/dev.c:5034)
Fixes: eb4d40654505 ("net/sched: add ACT_CSUM action to update packets checksums")
Cc: stable@kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Signed-off-by: Jun Yang <junvyyang@tencent.com>
---
A KASAN reproducer for this issue is available if requested.
net/sched/act_csum.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index 5fff52a8ca90..64002a4bebac 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -135,8 +135,14 @@ static void *tcf_csum_skb_nextlayer(struct sk_buff *skb,
unsigned int ihl, unsigned int ipl,
unsigned int jhl)
{
- int ntkoff = skb_network_offset(skb);
- int hl = ihl + jhl;
+ unsigned int ntkoff = skb_network_offset(skb);
+ unsigned int hl = ihl + jhl;
+
+ /* @ipl comes from the packet and may exceed the skb; reject it before
+ * adding @ntkoff, which would otherwise wrap.
+ */
+ if (ntkoff > skb->len || ipl > skb->len - ntkoff)
+ return NULL;
if (!pskb_may_pull(skb, ipl + ntkoff) || (ipl < hl) ||
skb_try_make_writable(skb, hl + ntkoff))
base-commit: c5de2ce2fccdb7d3b48946179634eaa3d7ce2e7e
--
2.56.1
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