From: netdev-bot+sashiko@kernel.org
To: opensource@andrii.net
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, willemb@google.com,
chopps@labn.net, netdev@vger.kernel.org, ipsec@lists.linux.dev,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH ipsec 1/3] xfrm: iptfs: don't let the inner MTU wrap around
Date: Mon, 30 Nov 2026 04:52:21 +0000 [thread overview]
Message-ID: <179601434170.3146.9884657168587090352@kernel.org> (raw)
In-Reply-To: <10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch makes __iptfs_get_inner_mtu() return 0 when nothing
fits.
- [Low] The kernel-doc of iptfs_get_inner_mtu()
(net/xfrm/xfrm_iptfs.c:2535) still says 'Return: Correct MTU taking in…
--
xfrm: iptfs: don't let the inner MTU wrap around
This patch makes __iptfs_get_inner_mtu() return 0 instead of wrapping
around when the outer MTU is too small for the SA overhead. It also drops
such packets in iptfs_output_queued(). The get_inner_mtu callback raises
the 0 to 1, as xfrm_state_mtu() does.
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> index 76272b0a18296..ea88c6618ca73 100644
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
[ ... ]
> @@ -2505,17 +2506,25 @@ static int iptfs_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
> * @x: xfrm state.
> * @outer_mtu: the outer mtu
> *
> - * Return: Correct MTU taking in to account the encap overhead.
> + * Return: Correct MTU taking in to account the encap overhead, or 0 if the
> + * outer MTU leaves no room for data.
> */
> static u32 __iptfs_get_inner_mtu(struct xfrm_state *x, int outer_mtu)
> {
> struct crypto_aead *aead;
> - u32 blksize;
> + u32 blksize, overhead, payload;
>
> aead = x->data;
> blksize = ALIGN(crypto_aead_blocksize(aead), 4);
> - return ((outer_mtu - x->props.header_len - crypto_aead_authsize(aead)) &
> - ~(blksize - 1)) - 2;
> + overhead = x->props.header_len + crypto_aead_authsize(aead);
> + if (outer_mtu <= overhead)
> + return 0;
> +
> + payload = (outer_mtu - overhead) & ~(blksize - 1);
> + if (payload <= 2)
> + return 0;
> +
> + return payload - 2;
> }
[Severity: Low]
Only iptfs_get_inner_mtu() raises the new 0 return value to 1.
iptfs_get_cur_pmtu() is the other caller, and it passes the raw value
through:
net/xfrm/xfrm_iptfs.c:iptfs_get_cur_pmtu() {
...
u32 pmtu = __iptfs_get_inner_mtu(x, xdst->child_mtu_cached);
if (payload_mtu && payload_mtu < pmtu)
pmtu = payload_mtu;
return pmtu;
}
Take a dont_frag SA whose outer MTU is at most the overhead, such as the
IPv4 MTU 68 with AES-CBC-256/HMAC-SHA512-256 case from the commit
message. In that case iptfs_output_collect() passes pmtu == 0 to
iptfs_is_too_big(). That function treats every packet as too big and
reports the 0:
net/xfrm/xfrm_iptfs.c:iptfs_is_too_big() {
...
if (sk)
xfrm_local_error(skb, pmtu);
else if (ip_hdr(skb)->version == 4)
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(pmtu));
else
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, pmtu);
...
}
Would this put an MTU of 0 in the ICMP FRAG_NEEDED and PKT_TOOBIG
messages and in the socket error queue? For the same SA,
xfrm_state_mtu() reports 1.
Before this patch the value wrapped to about 4G, so this path never ran
for this configuration. iptfs_output_queued() drops on !mtu without
reporting any MTU, so this enqueue path is the only place that reports 0.
The later patches in the series leave iptfs_get_cur_pmtu() and
iptfs_is_too_big() unchanged here. After "xfrm: iptfs: keep outer packets
within pkt_size", iptfs_get_cur_pmtu() still returns 0 when
child_mtu_cached leaves no room.
The packets are dropped either way, so only the reported value differs.
Should iptfs_get_cur_pmtu() or iptfs_is_too_big() use the same "?: 1"
floor so both paths report the same MTU?
>
> /**
> @@ -2532,7 +2541,8 @@ static u32 iptfs_get_inner_mtu(struct xfrm_state *x, int outer_mtu)
> /* If not dont-frag we have no MTU */
> if (!xtfs->cfg.dont_frag)
> return x->outer_mode.family == AF_INET ? IP_MAX_MTU : IP6_MAX_MTU;
> - return __iptfs_get_inner_mtu(x, outer_mtu);
> + /* Like xfrm_state_mtu() for the other modes, never return 0 */
> + return __iptfs_get_inner_mtu(x, outer_mtu) ?: 1;
> }
[Severity: Low]
This isn't a bug, but the kernel-doc above iptfs_get_inner_mtu() still
says:
* Return: Correct MTU taking in to account the encap overhead.
The function now also returns 1 when the outer MTU can't carry any data.
The patch updated the Return: line of __iptfs_get_inner_mtu() for its 0
case. Could this Return: line mention the 1 case too? The later patches
in the series don't change this comment either.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/8cfaaaca-0668-485f-bc87-f9fde6c4b25d%40mid.andrii.net
next prev parent reply other threads:[~2026-11-30 4:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 4:50 [PATCH ipsec 0/3] xfrm: iptfs: fix the outer packet size arithmetic Andrii Tereshchenko
2026-11-29 4:50 ` [PATCH ipsec 1/3] xfrm: iptfs: don't let the inner MTU wrap around Andrii Tereshchenko
2026-11-30 4:52 ` netdev-bot+sashiko [this message]
2026-11-29 4:50 ` [PATCH ipsec 2/3] xfrm: iptfs: count the IP-TFS header in the ESP padding Andrii Tereshchenko
2026-11-29 4:50 ` [PATCH ipsec 3/3] xfrm: iptfs: keep outer packets within pkt_size Andrii Tereshchenko
2026-11-30 4:52 ` netdev-bot+sashiko
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=179601434170.3146.9884657168587090352@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--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=opensource@andrii.net \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--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