Article View: linux.kernel.netdev
Article #24400Re: [PATCH ipsec 1/3] xfrm: iptfs: don't let the inner MTU wrap around
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 04:52
Date: Mon, 30 Nov 2026 04:52
130 lines
12455 bytes
12455 bytes
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
Technical Details
Message-ID:
<179601434170.3146.9884657168587090352@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373873-linux-kernel-netdev=dewy.ruReferences:
<10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373873-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179601434170.3146.9884657168587090352@kernel.org> References: <10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1336383"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:dRtjQu/acWyPI5v3v7Wo/7v4JmQ= sha256:JnHSC1iDDz0zo7/YGm1z533eL0umypSH69evZy/L9d0= sha1:ndKA79hXrwZjn+/al380M3apH24= sha256:EM1UIxmGsXIrGqaFgc/pBv2WDnKPlPzuF14Fs5EjZfc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 28038125FC3; Mon, 30 Nov 2026 07:52:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8aq3GP6ZdGnl; Mon, 30 Nov 2026 07:52:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373873-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4E72A125FC1; Mon, 30 Nov 2026 07:52:26 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 33728220E3; Mon, 30 Nov 2026 04:52:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796014344; b=Vvj1vCkyWPCTvOxvDJ7xzoLKctR+D1Cy0goziRCDLOEMuMqvFUr5lGtxTgA5Uk5o/XXb wReV8iOqvH8uQr1qafVy/bmh9OV0HHS+Xxl54fe8GYd8JnFltp/87DyIgZTuw3WuhMdGY W4T2nW0EDorCT+F/bbcrUgCTkh+Is3Y52ma41gaiE2t/p7bs2x3/iBF4AwNRG0g9+dgU8 X1rR9eoP9Gln1tR+buGVW5xpzcWYFe1EKZPxbqrpKwrDHwo2v07LWLcq2ELDzsnJs7Iui fn0HB4AcJAPL+q+YHK4ZCaXuiHTdGlOz9PNzO6Sxy9hsg79ewiNJUneojpBkD1KX2lw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796014344; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=Xx3fGZm2WBcPM96AQVPwnARVkYzeY0SKSmvMYwfPxSY=; b=MZmEfaJ9kWavgCbRLN4AyY/afg0QaIhTGxoKzxusKitk2yfPJN9hdF7OpgAc8rn8cDo7 DE7H3lV5mtUqE8XNnIoIpWFotKQJJJlVUJIe9DPEblGxnzlnRdY6t4+2mS/DbeP6khBdM J8iKw9Ho1qoWMbrPe8baRYLUX+o5d18bzvU8xKFVLmGR9tqhYkzim2qPsfDI4k4YYm5Rl wKyKr4G+vEcZaSvk7UQuuKV76yurIeLUfldSuixw+ghYq2d9QBct5Gefl4Gu+Ana9Nshm S1Tk7sNvkYFPXL+eEp6ScSBF6BVrv7/7sP8/OGsRKV8ZYptxSTyn3F73PIjcPbULATA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXqz0Xu0; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13529606A336; Mon, 30 Nov 2026 04:52:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXqz0Xu0 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796014343; b=B9QJp+FXZgP76hgsU3nRAnu/Feh9rFGPeryRW7tY3XEQ05dpqzGg9uaFd0ybNlHRP2XH 9aFQX/8yDaVirhCIkYKyFR0Br2dMgbdnZq0ghKSRau/ZOEEAjCFjC0JZXddrZr8rfiLTW Kg+Q3LiUVrF3c0E0dcPcXRfrDGysHgrfwW75eyWwAWBJ8rN/JRGU4ubu4FHbBB1W/ekTG AunRDm3wtT0OyO8z9AMClFJ2gsVDELJSqgJsAzz+mNfVaP3aGS5xZfRKn5bXxsWtFsNz6 KHvKAseUvN8u//2ykXTpIwbzZ0EvmfVoDz3LfZbYxUmEozcoOdOaSR1nPSQNDSN4J/A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796014343; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=Xx3fGZm2WBcPM96AQVPwnARVkYzeY0SKSmvMYwfPxSY=; b=zc1Pa1T9oKYECQUbwKwRI6tqDe3CgecwMI/PY/iFHlirNVmSh0m5fWpIbEgo0luvGUde fIOkFVKuvxIqrydV2X5dvSztaOjVU/GQAas6ju9Hhd/43w3gugSBue81+cJgX04JSvBDL zQD2MbyvmIMIEnMc/dP1sVMY7csWBLln3P6J9hMWXFCjgk1e9RKxnhSUAYioMfng76T5p POU04dQsv2W2u4ZeIRxuAmMCmVqyxqnba7T6Szcpavtu2a8CToEDZX55yfqrNE3ldL4kW XY1SS57qHj9FgQEWGNG3rrIXZhz/P/Iw7uwFr2xyO8aJiaJue0kTSExbTfb+YoeUz8w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXqz0Xu0; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30471606A31C; Mon, 30 Nov 2026 04:52:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33CEA1F000C1; Mon, 30 Nov 2026 04:52:22 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796014343; bh=Xx3fGZm2WBcPM96AQVPwnARVkYzeY0SKSmvMYwfPxSY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XXqz0Xu0SqEx+LxZiiHig+zlwxbEgX8f+QbtYEA31kePWlIlVYrKO/HDcEwKQ0fqr n8Q+jbWUTGLz3lxWYq1bHWnFlyqBZQrJb/Jnga5VRLgKp+2SFcO/k5ClLfk8U8mc5s 99AO6uKCsUitkAqw0p8wPaAo2xLW1z9N0tuhYqLaoMVA7d599vHORdZb48y6ph1o4X CxVz2LMECuYJxmccYNH8GnsfJ16fEBJ9DwbE99OM1J3fB8qp6MpK7qFJziepI97ygM NA+Se7MyXmwXgULa9we08B4ucjWpgTfza7bDQwircjep0QJwC5/JdA3Na0l2T419XF +YzvoX1TSS+7A== X-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 X-In-Reply-To: <10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Received-Bytes: 12196