From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33CEA1F000C1; Mon, 30 Nov 2026 04:52:22 +0000 (UTC) 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== Subject: Re: [PATCH ipsec 1/3] xfrm: iptfs: don't let the inner MTU wrap around 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 Date: Mon, 30 Nov 2026 04:52:21 +0000 Message-ID: <179601434170.3146.9884657168587090352@kernel.org> In-Reply-To: <10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net> References: <10ceac4a-a93a-4ed9-9ea5-356c931664fe@mid.andrii.net> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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