* [PATCH net] net/sched: act_csum: reject over-long packets before adding the offset
@ 2026-11-25 7:14 Jun Yang
0 siblings, 0 replies; only message in thread
From: Jun Yang @ 2026-11-25 7:14 UTC (permalink / raw)
To: jhs, jiri
Cc: davem, edumazet, kuba, pabeni, horms, hadi, baronchon, netdev,
junvyyang, corvus, stable
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 7:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 7:14 [PATCH net] net/sched: act_csum: reject over-long packets before adding the offset Jun Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox