mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: piyus@iiitd.ac.in
Cc: jhs@mojatatu.com, jiri@resnulli.us, netdev@vger.kernel.org,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	linux-kernel@vger.kernel.org, kapil@presceralabs.ai
Subject: Re: [PATCH net v2] net/sched: act_csum: bound the IPv6 jumbo payload length
Date: Thu, 19 Nov 2026 06:22:28 +0000	[thread overview]
Message-ID: <179506934898.3136.2983483959880388164@kernel.org> (raw)
In-Reply-To: <20261116182108.2581258-2-piyus@iiitd.ac.in>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The v2 changelog says the TCP, ICMPv6 and UDP-Lite ul == 0
  paths were exposed only to "a bounded over-read of up to 63 bytes",…
- [Medium] The changelog understates who can trigger the bug.

--

net/sched: act_csum: bound the IPv6 jumbo payload length

This patch bounds the jumbo payload length parsed by
tcf_csum_ipv6_hopopts(). The length must exceed IPV6_MAXPLEN, the IPv6
payload_len must be zero, and the claimed length must fit within the skb.
This stops the ipl + ntkoff sum in tcf_csum_skb_nextlayer() from wrapping
and keeps csum_partial() from reading past the end of the skb.

Link: https://lore.kernel.org/r/20261112075159.3552470-1-piyus@iiitd.ac.in
Link: https://lore.kernel.org/r/20261112075445.3555341-1-piyus@iiitd.ac.in

> 16-bit length, since ul <= ipl - ihl compares against ~4.29e9, and
> csum_partial() reads that many bytes off the end of the skb.  (The plain
> UDP arm is not affected: it requires ul == ipl - ihl.)

[ ... ]

> So "action csum tcp" and "action csum icmp" setups were exposed to a
> bounded over-read of up to 63 bytes on kernels built without KASAN, while
> the 65535-byte read reported below is the UDP-Lite case specifically.

[Severity: Medium]
Is this impact statement complete? It covers only reads, but the same
wrapped-ipl path also seems to allow out-of-bounds header writes.

When ipl + ntkoff wraps, the only check that any transport header bytes
exist is the loop guard in tcf_csum_ipv6(). It covers one byte:

    } while (pskb_may_pull(skb, hl + 1 + ntkoff));

tcf_csum_skb_nextlayer() then lets the wrapped ipl through. Also,
skb_try_make_writable() does not check the length:

    if (!pskb_may_pull(skb, ipl + ntkoff) || (ipl < hl) ||
        skb_try_make_writable(skb, hl + ntkoff))

After that, the handlers store to header fields whose offsets were never
checked:

    tcf_csum_ipv6_tcp():   tcph->check = 0;          (bytes 16-17)
    tcf_csum_ipv6_icmp():  icmp6h->icmp6_cksum = 0;  (bytes 2-3)
    tcf_csum_ipv6_udp():   udph->check = 0;          (bytes 6-7)

In tcf_csum_ipv6_udp(), the udph->check store comes before the ul tests:

    ul = udp_get_len_short(udph);

    udph->check = 0;

    if (udplite) {
    ...
    } else {
        if (ul != ipl - ihl)
            goto ignore_obscure_skb;

So the plain UDP arm cannot do the large read. It still writes at an
unchecked offset, though, and udph->len is read from the same unchecked
header.

On the rawv6_send_hdrinc() path, the skb is allocated with
length + hlen + tlen + 15 bytes. With tlen = 0 and a length of the form
41 + 8k, the tailroom can be exactly 15 bytes. Two examples are 353 bytes
in the 704-byte small head and 673 bytes in kmalloc-1024. With a 1-byte
TCP header, tcph->check then lands on skb_shared_info at skb->end. KASAN
would not flag this because the store stays inside the allocation.

The code change closes all of these paths, since the new bound on *pl
keeps ipl + ntkoff within skb->len. v2 was a changelog-only respin meant
to describe the exposure. Could the changelog also mention these writes,
and qualify the statement that the plain UDP arm is not affected?

[ ... ]

> The packet is generated locally through a raw AF_INET6 socket with
> IPV6_HDRINCL and leaves an Ethernet device, so skb_network_offset() is
> non-zero and the sum above wraps.  Reaching it needs a clsact qdisc with
> a csum action carrying TCA_CSUM_UPDATE_FLAG_UDPLITE, which is
> CAP_NET_ADMIN in the network namespace - reachable by an unprivileged
> user through a user namespace.  The folded checksum of the out-of-bounds
> bytes is written into the packet and transmitted.

[ ... ]

> Conditions it needs: a clsact qdisc with a csum action carrying
> TCA_CSUM_UPDATE_FLAG_UDPLITE, on an Ethernet-type device, with the packet
> locally generated so that skb_network_offset() is 14 and the sum in
> tcf_csum_skb_nextlayer() can wrap.  CAP_NET_ADMIN in the network namespace,
> which CONFIG_USER_NS makes reachable by an unprivileged user.

[Severity: Medium]
Can a wider set of senders trigger this than described here?
CAP_NET_ADMIN is needed to install the csum action, but not to send the
packet that reaches it.

A bridged IPv6 frame from another host also arrives at tc egress with
skb_network_offset() equal to 14:

__netif_receive_skb_core()
    skb_reset_network_header(skb);
  -> bridge rx_handler -> forward
br_dev_queue_push_xmit()
    skb_push(skb, ETH_HLEN);
    dev_queue_xmit(skb);
  -> tc egress -> tcf_csum_act() -> tcf_csum_ipv6()
     -> tcf_csum_ipv6_hopopts()

These frames never pass through ipv6_rcv() or its jumbo option checks.
The only bridge-side check is br_validate_ipv6()->nf_ip6_check_hbh_len(),
and that only runs with br_netfilter.

act_mirred ingress-to-egress redirects also push the MAC header back, so
ntkoff is mac_len at the target device's egress.

Take a bridge, VM tap or container veth host where action csum is
installed on a port's egress. A remote, guest or container sender with no
privilege on the host could send a jumbo length of 0xFFFFFFCA. That would
trigger the UDP-Lite read, or the TCP/ICMP over-read and header writes,
and the folded checksum would be transmitted.

The new bound uses skb->len - skb_network_offset(skb), so the fix covers
these paths too. Since this affects stable and security triage, could the
changelog and the conditions note describe this broader exposure rather
than only locally generated packets?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116182108.2581258-2-piyus%40iiitd.ac.in

      reply	other threads:[~2026-11-19  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 18:21 [PATCH net] " Piyus Kedia
2026-11-16 18:21 ` [PATCH net v2] " Piyus Kedia
2026-11-19  6:22   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179506934898.3136.2983483959880388164@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kapil@presceralabs.ai \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=piyus@iiitd.ac.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®