From: netdev-bot+sashiko@kernel.org
To: edumazet@kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, dsahern@kernel.org, idosch@nvidia.com,
willemdebruijn.kernel@gmail.com, marcelo.leitner@gmail.com,
lucien.xin@gmail.com, aconole@redhat.com, echaudro@redhat.com,
i.maximets@ovn.org, daniel@iogearbox.net,
justin.iurman@gmail.com, linus.luessing@c0d3.blue,
sd@queasysnail.net, sbrivio@redhat.com, imv4bel@gmail.com,
netdev@vger.kernel.org, linux-sctp@vger.kernel.org,
dev@openvswitch.org, stable@vger.kernel.org
Subject: Re: [PATCH net 1/5] ipv6: gro: limit the number of extension headers
Date: Mon, 16 Nov 2026 15:47:25 +0000 [thread overview]
Message-ID: <179484404508.3136.1665023994705750300@kernel.org> (raw)
In-Reply-To: <20261113124625.4010206-2-edumazet@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] This patch caps extension headers per IPv6 GRO layer.
--
ipv6: gro: limit the number of extension headers
The patch caps the number of extension headers that
ipv6_gro_pull_exthdrs() walks at IP6_MAX_EXT_HDRS_CNT, matching
ip6_protocol_deliver_rcu(). The goal is to keep the GRO transport header
offset from overflowing the 16-bit skb->transport_header and causing an
out-of-bounds read in gro_receive_network_flush().
Link: https://lore.kernel.org/netdev/avTTQNyvwPP6LtGx@v4bel/
> diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
> index 700f1861d8eb7..01642900c0fa3 100644
> --- a/net/ipv6/ip6_offload.c
> +++ b/net/ipv6/ip6_offload.c
> @@ -26,6 +26,7 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto)
> {
> const struct net_offload *ops = NULL;
> struct ipv6_opt_hdr *opth;
> + int exthdr_cnt = 0;
>
> for (;;) {
> int len;
> @@ -38,6 +39,13 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto)
> if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
> break;
>
> + /* Same limit as ip6_protocol_deliver_rcu().
> + * @proto is left pointing to an extension header,
> + * so that the caller does not aggregate this packet.
> + */
> + if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
> + break;
[Severity: High]
Does this fully close the out-of-bounds read in
gro_receive_network_flush()?
exthdr_cnt is local and starts at 0 on every call. That bounds each
ipv6_gro_receive() pass to roughly 40 + 12 * 2048 bytes, but it does not
bound the transport offset of the whole packet.
Within a single GRO pass, sit_ip6ip6_gro_receive() sets encap_mark and
calls back into ipv6_gro_receive() for an inner IPv6 header. Each
layer's ipv6_gro_pull_exthdrs() call is allowed another 12 extension
headers:
ipv6_gro_receive()
ipv6_gro_pull_exthdrs() /* up to 12 exthdrs */
sit_ip6ip6_gro_receive()
ipv6_gro_receive()
ipv6_gro_pull_exthdrs() /* another 12 exthdrs */
skb->transport_header is also measured from skb->head, so headroom
counts toward it. __ip6_tnl_rcv() in net/ipv6/ip6_tunnel.c hands the
decapsulated skb back to GRO:
gro_cells_receive(&tunnel->gro_cells, skb);
The outer headers stay in the buffer as headroom. That outer layer was
only checked by ip6_protocol_deliver_rcu(), which also allows 12
extension headers.
Put together, headroom + outer + inner + inner-inner headers can add up
to more than 65535 bytes inside one IPv6 datagram. At that point, this
store in ipv6_gro_receive() silently wraps the __u16:
skb_set_transport_header(skb, skb_gro_offset(skb));
inet_gro_receive() in net/ipv4/af_inet.c has the same pattern for an
inner IPv4 header.
Suppose a second packet of the same flow then arrives. tcp_gro_receive()
takes th2 = tcp_hdr(p) at the wrapped offset. That offset lands in outer
header bytes the sender controls, so the port check in tcp_gro_lookup()
can be made to match. gro_receive_network_flush() then runs:
int off = skb_transport_offset(p);
...
flush = __gro_receive_network_flush(th, th2, p, off - NAPI_GRO_CB(p)->network_offset, false);
off is negative here, so the u16 diff ends up large. In
__gro_receive_network_flush(), nh2 = th2 - diff then points tens of KB
before p->head. Isn't that the same out-of-bounds read this patch is
meant to fix?
The commit message notes that "offsets can still accumulate over nested
encapsulations, so the places storing them should be hardened
separately". The rest of the series adds
skb_set_transport_header_careful() in ipv6_mc_check_exthdrs(),
parse_ipv6hdr(), sctp_v6_err() and __udp6_lib_err_encap(). It does not
touch the two GRO store sites in ipv6_gro_receive() and
inet_gro_receive() that feed gro_receive_network_flush().
The patch carries Fixes: and Cc: stable. Should those two GRO sites also
use skb_set_transport_header_careful(), and flush when it fails, so that
backports close the reported read as well?
> opth = skb_gro_header(skb, off + sizeof(*opth), off);
> if (unlikely(!opth))
> break;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113124625.4010206-1-edumazet%40kernel.org
next prev parent reply other threads:[~2026-11-16 15:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 12:46 [PATCH net 0/5] net: avoid truncated transport header offsets Eric Dumazet
2026-11-13 12:46 ` [PATCH net 1/5] ipv6: gro: limit the number of extension headers Eric Dumazet
2026-11-13 12:58 ` Hyunwoo Kim
2026-11-16 11:33 ` Ido Schimmel
2026-11-16 15:47 ` netdev-bot+sashiko [this message]
2026-11-13 12:46 ` [PATCH net 2/5] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Eric Dumazet
2026-11-16 11:45 ` Ido Schimmel
2026-11-13 12:46 ` [PATCH net 3/5] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Eric Dumazet
2026-11-13 12:46 ` [PATCH net 4/5] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Eric Dumazet
2026-11-16 15:47 ` netdev-bot+sashiko
2026-11-13 12:46 ` [PATCH net 5/5] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Eric Dumazet
2026-11-15 14:40 ` Stefano Brivio
2026-11-14 20:17 ` [PATCH net 0/5] net: avoid truncated transport header offsets Justin Iurman
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=179484404508.3136.1665023994705750300@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aconole@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=dsahern@kernel.org \
--cc=echaudro@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=idosch@nvidia.com \
--cc=imv4bel@gmail.com \
--cc=justin.iurman@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.luessing@c0d3.blue \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbrivio@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
/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