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=1796014344; b=IXrSBID8ahdF2rhI7Ql9vfecEtElPlB03a+crhhmiw6Iu6D/x2VMTpG0kGU7YI2J7Nb7 heK0x1ZejvrfK2DEOdER4uDZmfSTTOulKG4BcNuyDMoCyT4fHp/vTeM85Icc0aB6xkpuK vs9oD1rEPZYEllkNo8HFN3qw+kUlWNHNf9FZlp6Z+mX5L7M51Zno9mRTXFeiis8DgJ1w5 Yb5TLZQ+jbFIIxESuK9LBV/rY+qGgdtB7nmOdQNX+ZGhmnkgeJGUuz6L7gBAitVhIxBIR n4OyUpG3B1cht0GRuD0qdF8kQPN2FBhyfb5xqyKkY8y7JGhm7hGSolQ1rH4aBZ+thIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796014344; 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=Y/cdkWfmTCPgtZ8Gi4SOgsrQgupS6VI2MGD8vWMFhoQ=; b=OagAYzft5eP73Limh9U73qJw/1ZLi54JTeD1qyByxHl/isaGlADEiqxV//g6tayLOnyC /eMSPiFaGtFL5yfmUXofAgLtxonD0THeYvElcNvM1bZ7n1nRwE6qpqkKkwEEhjARcX1vi vfrtYFHTXmCAsZalvbE7FQRG6aV3UWiOVcVvK00s5GEBxpqtYkpkUoiCaL8cYMjH11E6e BZNDg2Mp4fBORZrGsjWnbCUE20dz8KDYmg4bkSDOyIm0lj3CGOV4MKq+O+xTn2ftcR73p HrA3V7GOkb1173exJOUKahBvsffFs0FsmaS2WGyRSAxv8Hef8RWa/Dc+wvIeWamagmg== 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=Oe+9HGEW; 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 63C42606A33A; Mon, 30 Nov 2026 04:52:24 +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=Oe+9HGEW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C2E11F00899; Mon, 30 Nov 2026 04:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796014344; bh=Y/cdkWfmTCPgtZ8Gi4SOgsrQgupS6VI2MGD8vWMFhoQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Oe+9HGEWcIP/xj3NWE5Ml0eOr7qghJmEXeNK663ZlQG2Q+KSyfTRcPgV9Lpfr9Zge JrFW55W+cAmFas8zYkCjuupcXkjeLMngSQWGRUYCuSeL0sMxDCNq/79R2SAxH8+Re1 CKlBQ4nfEeHwRpU/esrS232/1DOyzzFbSIbI6ib6C7uxP2sqkyK+aaGsXINHYRYD2V XJSVpct/txwp+GEmo7PWBm9Q+8e9WiAExiVVNFEoouzr5AmJlvp4GEpWNjwwTkgIb2 oaLhOAg+DHHdEvpMIvv7tRDfHE/SpGIYCa759z4qT/+So5/sEcGaOtLFmsIeEafJXD PvpKm6INXObAw== Subject: Re: [PATCH ipsec 3/3] xfrm: iptfs: keep outer packets within pkt_size 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:23 +0000 Message-ID: <179601434315.3146.14435933528551398228@kernel.org> In-Reply-To: References: X-sashiko-severity: Medium 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 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] This patch checks pkt_size only once, in iptfs_user_init(), against the header_len the SA has when it is created. -- xfrm: iptfs: keep outer packets within pkt_size This commit removes payload_mtu. iptfs_get_cur_pmtu() now converts XFRMA_IPTFS_PKT_SIZE into an inner data budget with __iptfs_get_inner_mtu() each time it is used, so ESP padding, trailer and ICV are counted, and header_len changes from SA migration are picked up. iptfs_user_init() also refuses a pkt_size that leaves no room for data. > diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c > index 9ecc2a39b6543..172da3940a32f 100644 > --- a/net/xfrm/xfrm_iptfs.c > +++ b/net/xfrm/xfrm_iptfs.c [ ... ] > @@ -1812,11 +1810,13 @@ static int iptfs_get_cur_pmtu(struct xfrm_state *x, struct xfrm_iptfs_data *xtfs > struct sk_buff *skb) > { > struct xfrm_dst *xdst = (struct xfrm_dst *)skb_dst(skb); > - u32 payload_mtu = xtfs->payload_mtu; > u32 pmtu = __iptfs_get_inner_mtu(x, xdst->child_mtu_cached); > > - if (payload_mtu && payload_mtu < pmtu) > - pmtu = payload_mtu; > + /* Converted here rather than once, as migration can change > + * header_len. > + */ > + if (xtfs->cfg.pkt_size) > + pmtu = min(pmtu, __iptfs_get_inner_mtu(x, xtfs->cfg.pkt_size)); > > return pmtu; > } > @@ -2589,13 +2589,12 @@ static int iptfs_user_init(struct net *net, struct xfrm_state *x, > } > if (attrs[XFRMA_IPTFS_PKT_SIZE]) { > xc->pkt_size = nla_get_u32(attrs[XFRMA_IPTFS_PKT_SIZE]); > - if (!xc->pkt_size) { > - xtfs->payload_mtu = 0; > - } else if (xc->pkt_size > x->props.header_len) { > - xtfs->payload_mtu = xc->pkt_size - x->props.header_len; > - } else { > + /* pkt_size is the whole outer packet, ESP padding, trailer > + * and ICV included; iptfs_get_cur_pmtu() converts it. > + */ > + if (xc->pkt_size && !__iptfs_get_inner_mtu(x, xc->pkt_size)) { [Severity: Medium] This check only runs when the SA is created, against the header_len the SA has at that point. Is it also needed on the migration path, given that the new comment in iptfs_get_cur_pmtu() says migration can change header_len? On migration, xfrm_state_migrate_create() goes through xfrm_state_clone_and_setup()->iptfs_clone_state(). That function kmemdup()s orig->mode_data, so cfg.pkt_size is copied unchanged: net/xfrm/xfrm_iptfs.c:iptfs_clone_state() { ... xtfs = kmemdup(orig->mode_data, sizeof(*xtfs), GFP_KERNEL); ... } xfrm_state_clone_and_setup() then sets x->props.family = m->new_family and may set a new encap. After that, xfrm_init_state() rebuilds header_len. iptfs_init_state() takes the clone branch, and iptfs_user_init() is not called again: net/xfrm/xfrm_iptfs.c:iptfs_init_state() { if (x->mode_data) { /* We have arrived here from xfrm_state_clone() */ xtfs = x->mode_data; } else { ... __iptfs_init_state(x, xtfs); ... } Take AES-GCM as an example. On IPv4 the overhead is 52 bytes with 4-byte alignment, so iptfs_user_init() accepts a pkt_size of 60 to 79. After migration to IPv6 the overhead becomes 72. __iptfs_get_inner_mtu(x, pkt_size) then returns 0, and iptfs_get_cur_pmtu() returns min(pmtu, 0) = 0. UDP encap adds 8 bytes and opens a similar window. With pmtu == 0, could every outbound packet on the migrated SA be dropped? Without dont_frag, iptfs_output_queued() drops each one here, and only LINUX_MIB_XFRMOUTERROR is incremented: if (!mtu || (skb->len > mtu && xtfs->cfg.dont_frag)) { With dont_frag set, iptfs_output_collect()->iptfs_is_too_big() would send ICMP_FRAG_NEEDED or ICMPV6_PKT_TOOBIG advertising an MTU of 0, or call xfrm_local_error(skb, 0), for every packet. Before this patch, the stale payload_mtu stayed non-zero, so traffic kept flowing after such a migration. iptfs_get_inner_mtu() keeps a "?: 1" floor so it never returns 0. iptfs_get_cur_pmtu() has no equivalent. Could the pkt_size check be repeated in the clone path of iptfs_init_state() after __iptfs_init_state() recomputes header_len, so that such a migration fails instead of creating an SA that drops all traffic? > NL_SET_ERR_MSG(extack, > - "Packet size must be 0 or greater than IPTFS/ESP header length"); > + "Packet size must be 0 or greater than IPTFS/ESP overhead"); > return -EINVAL; > } > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/8cfaaaca-0668-485f-bc87-f9fde6c4b25d%40mid.andrii.net