[PATCH net v4] net/sched: act_csum: bound the IPv6 jumbo payload length
From: Piyus Kedia
Date: Sun Nov 29 2026 - 12:38:12 EST
tcf_csum_ipv6_hopopts() trusts the 32-bit payload length from an
IPV6_TLV_JUMBO hop-by-hop option without checking it against the skb:
*pl = ntohl(*(__be32 *)(xh + off + 2));
tcf_csum_ipv6() adds sizeof(struct ipv6hdr) to *pl and passes the
resulting ipl to the per-protocol handlers as the packet extent. For a
jumbo option near 2^32, ipl + ntkoff in tcf_csum_skb_nextlayer() wraps
to a small unsigned value, so pskb_may_pull() succeeds without pulling
while ipl < hl stays false. The transport handlers then read and write
past the end of the skb:
- tcf_csum_ipv6_udp()'s UDPLITE path passes the coverage length to
csum_partial(), triggering an out-of-bounds read up to 65535 bytes.
The resulting checksum is written into the transmitted packet, and the
coverage length comes from the packet too, so differencing two
coverages discloses the bytes past the skb exactly.
- tcf_csum_ipv6_tcp(), tcf_csum_ipv6_icmp(), and the UDPLITE ul == 0
path pass ipl - ihl (> 2^31) to csum_partial()'s signed int len. On
x86_64 without KASAN, arch/x86/lib/csum-partial_64.c uses bitwise
length checks and reads up to 63 bytes out of bounds (lib/checksum.c
under KASAN returns early on len <= 0, hiding these three).
- Checksum stores write past the validated header into tailroom or
skb_shared_info without tripping KASAN.
Unprivileged users can hit this via CONFIG_USER_NS + CAP_NET_ADMIN, or
remotely from a guest/container behind a bridge or act_mirred egress
redirect where frames reach tc without passing ipv6_rcv() jumbo checks.
BUG: KASAN: slab-out-of-bounds in csum_partial+0x103/0x1f0
lib/checksum.c:119
Read of size 4 at addr ffff8880259642c0 by task syz-executor/13111
tcf_csum_ipv6_udp+0x19e/0x250 net/sched/act_csum.c
tcf_csum_ipv6+0x63c/0x780 net/sched/act_csum.c:549
tcf_csum_act+0x34d/0x480 net/sched/act_csum.c:601
tcf_action_exec+0x109/0x390 net/sched/act_api.c:1161
tcf_classify+0x13d/0x440 net/sched/cls_api.c:1875
tc_run+0x31a/0x460 net/core/dev.c:4491
__dev_queue_xmit+0x1a7e/0x2390 net/core/dev.c:4890
ip6_output+0x280/0x400 net/ipv6/ip6_output.c:248
rawv6_send_hdrinc+0xb90/0x1170 net/ipv6/raw.c:663
The buggy address is located 0 bytes to the right of
allocated 704-byte region [ffff888025964000, ffff8880259642c0)
Fix this by validating the jumbo option in tcf_csum_ipv6_hopopts() the
same way nf_ip6_check_hbh_len() does: require payload_len == 0,
pkt_len > IPV6_MAXPLEN, and enough bytes after the network header to
back the claimed length. Also use check_add_overflow() in
tcf_csum_skb_nextlayer() so length arithmetic cannot wrap.
Per Documentation/process/generated-content.rst: the out-of-bounds read
was found by an AI-driven fuzzing harness developed jointly by Kapil
Vaswani and myself, which exercised the csum action under KASAN on
x86_64. The analysis, changelog, and patch were written with the
assistance of an LLM and reviewed by hand; the before/after testing
below the --- was run by us. Additional affected paths were identified
while addressing AI-generated reviews on the list and verified directly
in the tree.
Link: https://lore.kernel.org/r/20261112075159.3552470-1-piyus@xxxxxxxxxxx
Link: https://lore.kernel.org/r/20261112075445.3555341-1-piyus@xxxxxxxxxxx
Link: https://lore.kernel.org/r/20261119133557.3214802-1-piyus@xxxxxxxxxxx
Fixes: eb4d40654505 ("net/sched: add ACT_CSUM action to update packets checksums")
Suggested-by: Willem de Bruijn <willemb@xxxxxxxxxx>
Signed-off-by: Kapil Vaswani <kapil@xxxxxxxxxxxxxxx>
Signed-off-by: Piyus Kedia <piyus@xxxxxxxxxxx>
---
v4: tcf_csum_skb_nextlayer() checks its sums with check_add_overflow()
rather than the second pskb_may_pull() v3 added, and hl becomes
unsigned int to match ihl/ipl/jhl. That check did not do what its
comment claimed: where skb->len >= hl + ntkoff it passes with a
wrapped ipl still in hand, and where ipl + ntkoff cannot wrap it is
redundant, since ipl >= hl already gives hl + ntkoff <= ipl + ntkoff.
Changelog and comments cut. The jumbo bound is unchanged from v2
apart from its comment.
v3: added that pskb_may_pull(), now replaced.
v2: changelog only - the exposure of the three csum_partial() callers on
a kernel built without KASAN. The code was unchanged from v1.
Tested on 7.3.1 with KASAN, in a single-VM qemu rig, same .config and
image before and after; only net/sched/act_csum.o and the relink differ:
jumbo length payload_len before after
variant A 0xFFFFFFCA 16 KASAN, VM lost ok, exit 0
variant B 0xFFFFFFCA 0 KASAN, VM lost ok, exit 0
control none (PadN) 16 not run ok
Both faulting runs reach csum_partial() through the trace above. After
the patch both programs run to completion with every setup step
succeeding and all four sendto() calls accepted, so the packets do travel
the egress path and the action refuses the length. The control is the
same program with the jumbo option replaced by a PadN and a UDP-Lite
length of 8, run on the patched kernel to show the walker still accepts
an ordinary hop-by-hop option.
Reproducer: not included here. This bug was found with AI assistance,
which Documentation/process/security-bugs.rst says to treat as public;
the same paragraph says not to post the reproducer publicly. It is a
short shell script plus a ~40-line C sender, tested, and available on
request.
net/sched/act_csum.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index 5fff52a8ca90..de314e88659a 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -16,6 +16,7 @@
#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
+#include <linux/overflow.h>
#include <net/ip.h>
#include <net/ipv6.h>
@@ -136,9 +137,16 @@
unsigned int jhl)
{
int ntkoff = skb_network_offset(skb);
- int hl = ihl + jhl;
+ unsigned int hl, total;
- if (!pskb_may_pull(skb, ipl + ntkoff) || (ipl < hl) ||
+ /*
+ * ipl comes from the packet header and can be close to U32_MAX,
+ * so ipl + ntkoff can wrap to a small value and cause pskb_may_pull()
+ * to succeed without pulling. Guard the additions against overflow.
+ */
+ if (ntkoff < 0 || check_add_overflow(ihl, jhl, &hl) || ipl < hl ||
+ check_add_overflow(ipl, (unsigned int)ntkoff, &total) ||
+ !pskb_may_pull(skb, total) ||
skb_try_make_writable(skb, hl + ntkoff))
return NULL;
else
@@ -449,7 +457,8 @@
return 0;
}
-static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, unsigned int ixhl,
+static int tcf_csum_ipv6_hopopts(struct sk_buff *skb,
+ struct ipv6_opt_hdr *ip6xh, unsigned int ixhl,
unsigned int *pl)
{
int off, len, optlen;
@@ -463,13 +472,30 @@
case IPV6_TLV_PAD1:
optlen = 1;
break;
- case IPV6_TLV_JUMBO:
+ case IPV6_TLV_JUMBO: {
+ unsigned int avail = skb->len - skb_network_offset(skb);
+ u32 pkt_len;
+
optlen = xh[off + 1] + 2;
if (optlen != 6 || len < 6 || (off & 3) != 2)
/* wrong jumbo option length/alignment */
return 0;
- *pl = ntohl(*(__be32 *)(xh + off + 2));
+ pkt_len = ntohl(*(__be32 *)(xh + off + 2));
+ /*
+ * Per RFC 2675 (and matching nf_ip6_check_hbh_len()),
+ * a jumbogram must have payload_len == 0, an option
+ * length > IPV6_MAXPLEN, and enough bytes in the skb
+ * to cover the claimed payload.
+ */
+ if (pkt_len <= IPV6_MAXPLEN ||
+ ipv6_hdr(skb)->payload_len)
+ return 0;
+ if (avail < sizeof(struct ipv6hdr) ||
+ pkt_len > avail - sizeof(struct ipv6hdr))
+ return 0;
+ *pl = pkt_len;
goto done;
+ }
default:
optlen = xh[off + 1] + 2;
if (optlen > len)
@@ -521,7 +548,7 @@
goto fail;
ip6xh = (void *)(skb_network_header(skb) + hl);
if ((nexthdr == NEXTHDR_HOP) &&
- !(tcf_csum_ipv6_hopopts(ip6xh, ixhl, &pl)))
+ !(tcf_csum_ipv6_hopopts(skb, ip6xh, ixhl, &pl)))
goto fail;
nexthdr = ip6xh->nexthdr;
hl += ixhl;
--
2.43.0