From: Andrii Tereshchenko <opensource@andrii.net>
To: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Christian Hopps <chopps@labn.net>,
netdev@vger.kernel.org, ipsec@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH ipsec] xfrm: iptfs: give a runt-started inner packet a MAC header
Date: Sun, 29 Nov 2026 12:58:14 -0700 [thread overview]
Message-ID: <4de11468-7743-409e-83a6-d7c839df56d7@mid.andrii.net> (raw)
In-Reply-To: <e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e@mid.andrii.net>
Both AI reviews [1][2] raise the same issue with this patch, which
another of my patches fixes, plus two older issues outside it. Neither
review was mailed to the list, so I am answering here.
Sashiko (netdev AI review) wrote:
> Can this write past the end of the newskb buffer when skb->mac_len is
> larger than the headroom of newskb?
>
> newskb comes from iptfs_alloc_skb(skb, ipremain, false). That call reserves
> a fixed amount of headroom and ignores tpl->mac_len:
[...]
> The note below the --- line says "this copy relies on C1 ... for long MAC
> headers". That patch is not in this tree. git am also drops the note, and
> the Cc: stable tag lists no prerequisite.
>
> Would it be safer to check skb->mac_len against skb_headroom(newskb), or to
> call skb_cow_head(), before the copy? Another option is to send this with
> C1 as one ordered series.
>
> __input_process_payload() already has the same unchecked pattern:
[...]
> So a fix would need to cover both places.
Sashiko (sashiko.dev) raised the same point.
Yes. "xfrm: iptfs: reserve room for the outer MAC header in new inner
skbs" [3] fixes it in iptfs_alloc_skb(), which both places allocate
from: it reserves at least tpl->mac_len, rounded up to a cache line.
Without it, this patch adds a second place with the overflow that
__input_process_payload() already has, so it has to be applied after
[3], and stable needs both, in that order.
Steffen, could you take [3] first? If you would rather have them as one
series, I will resend both as a v2, with the order spelled out for
stable.
Sashiko (sashiko.dev) wrote:
> Also, if skb->mac_len is non-zero but smaller than ETH_HLEN, writing
> eth_hdr(newskb)->h_proto writes past the end of the skb->mac_len-byte MAC
> header into the IP header at newskb->data.
That is true of every h_proto store on the xfrm receive path: the
reuse branch of __input_process_payload() and
xfrm4_remove_tunnel_encap() and xfrm6_remove_tunnel_encap() guard with
"if (skb->mac_len)" too. This patch follows them. I don't know of a
device that hands ESP up with a MAC header shorter than ETH_HLEN, so I
have left it as is.
Sashiko (netdev AI review) wrote:
> This issue was not introduced by this patch. The new comment names
> __input_process_payload() as its model, but the allocate path in that
> function does not have this mac_len guard:
[...]
> Should that store also be guarded with if (first_skb->mac_len)?
Sashiko (sashiko.dev) raised the same point.
Yes. Over IPIP, point-to-point GRE, ip6ip6 and ip6gre, only one inner
packet per outer packet survives it. I have a fix ready that adds that
guard, and will post it separately, with other IP-TFS receive fixes.
Sashiko (sashiko.dev) wrote:
> This problem wasn't introduced by this patch, but earlier in
> iptfs_reassem_cont() the blkoff == 0 handling triggers [...] an
> out-of-bounds read when skb is completely non-linear:
[...]
> Direct dereference of *skb->data neither checks that linear data is present
> nor reads from the sequential state st at offset data, so it reads past the
> empty linear buffer on a fully non-linear skb and otherwise inspects the
> outer IP-TFS header subtype byte instead of the inner padding byte.
Yes, that check reads the IP-TFS header instead of the data block. The
fix, which reads the first octet of the data block with
skb_copy_bits(), is in the same receive series.
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e%40mid.andrii.net
[2] https://sashiko.dev/#/patchset/e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e%40mid.andrii.net
[3] https://lore.kernel.org/all/a502a95c-de83-4f8d-986e-80f804ebe76c@mid.andrii.net/
Andrii Tereshchenko
prev parent reply other threads:[~2026-11-29 19:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 22:32 Andrii Tereshchenko
2026-11-29 19:58 ` Andrii Tereshchenko [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=4de11468-7743-409e-83a6-d7c839df56d7@mid.andrii.net \
--to=opensource@andrii.net \
--cc=chopps@labn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ipsec@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
--cc=willemb@google.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
all inboxes | Powered by JetHome®