Re: [PATCH net-next v8 3/5] ip6_gre: classify the inner packet once on transmit

From: netdev-bot+sashiko

Date: Thu Dec 03 2026 - 07:39:23 EST


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

Critical: 0 · High: 0 · Medium: 1 · 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] In this commit, ip6erspan_tunnel_xmit() (net/ipv6/ip6_gre.c)
passes the classified payload_protocol only to ip6_tnl_xmit() (line…

--

ip6_gre: classify the inner packet once on transmit

This commit adds ip6gre_xmit_classify(). It works out the inner protocol
once, on entry to ip6gre_tunnel_xmit() and ip6erspan_tunnel_xmit(). On
Ethernet devices it looks through VLAN tags and pulls the inner IP header.
The result is passed down to ip6_tnl_xmit() as a new payload_protocol
argument. That replaces the skb_protocol(skb, true) calls, which parsed the
frame again after the GRE and ERSPAN headers were pushed.

Closes: https://syzkaller.appspot.com/bug?extid=6023ea32e206eef7920a

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 51f4311bebfa4..c413e47c6ceb0 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c

[ ... ]

> @@ -950,7 +1005,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
> __u32 mtu;
> int nhoff;
>
> - if (!pskb_inet_may_pull(skb))
> + if (ip6gre_xmit_classify(skb, dev, &payload_protocol))
> goto tx_err;
>
> if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))

[ ... ]

> @@ -1073,7 +1128,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
> htonl(atomic_fetch_inc(&t->o_seqno)));
>
> err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
> - NEXTHDR_GRE);
> + NEXTHDR_GRE, payload_protocol);
> if (err != 0) {
> /* XXX: send ICMP error even if DF is not set. */
> if (err == -EMSGSIZE) {

[Severity: Medium]
payload_protocol is passed to ip6_tnl_xmit() here. Does the rest of
ip6erspan_tunnel_xmit() still go by skb->protocol? In this commit the
truncate checks, the native mode dispatch and the choice of ICMP family
are unchanged:

net/ipv6/ip6_gre.c:ip6erspan_tunnel_xmit() {
...
nhoff = skb_network_offset(skb);
if (skb->protocol == htons(ETH_P_IP) &&
(ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
truncate = true;

if (skb->protocol == htons(ETH_P_IPV6)) {
...
} else {
switch (skb->protocol) {
case htons(ETH_P_IP):
...
if (err == -EMSGSIZE) {
if (skb->protocol == htons(ETH_P_IP))
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
ICMP_FRAG_NEEDED, htonl(mtu));
else
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
...
}

ip6_tnl_xmit() now takes payload_protocol as an argument, but its MTU
floor still checks skb->protocol:

net/ipv6/ip6_tunnel.c:ip6_tnl_xmit() {
...
mtu = max(mtu, skb->protocol == htons(ETH_P_IPV6) ?
IPV6_MIN_MTU : IPV4_MIN_MTU);
...
}

Take a VLAN-tagged IPv4 or IPv6 frame on a native ip6erspan device.
ip6gre_xmit_classify() sets payload_protocol to ETH_P_IP or ETH_P_IPV6, so
the hop limit is inherited from the inner header.

The switch on skb->protocol still takes the default branch, though. That
skips prepare_ip6gre_xmit_ipv4() and prepare_ip6gre_xmit_ipv6(), so the
traffic class, flow label and encap_limit do not come from the inner
header. The truncate bit is not set from the inner length either.

On -EMSGSIZE, a tagged IPv4 frame would be passed to icmpv6_ndo_send()
with an IPv4 header at the network header. icmp6_send() bounds-checks that
read, so the result is a bogus PKT_TOOBIG, not memory corruption.

These sites behaved the same way before this patch. Even so, the
behaviour doesn't seem to match the new comment above
ip6gre_xmit_classify():

Nothing below parses the frame again: the answer is passed down, also to
ip6_tnl_xmit().

The next patch in the series, "ip6_gre: go by the inner protocol behind
VLAN tags in ip6erspan", appears to switch all four sites to
payload_protocol and to send icmpv6_ndo_send() only for ETH_P_IPV6. Could
that change be folded into this one? If not, could the comment and the
commit message be adjusted so this commit is accurate on its own?

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202123613.1708463-1-littlesmilingcloud%40gmail.com