Article View: linux.kernel.netdev
Article #24399Re: [PATCH ipsec 3/3] xfrm: iptfs: keep outer packets within pkt_size
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 04:52
Date: Mon, 30 Nov 2026 04:52
130 lines
12757 bytes
12757 bytes
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
Technical Details
Message-ID:
<179601434315.3146.14435933528551398228@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373874-linux-kernel-netdev=dewy.ruReferences:
<d72476bc-56b1-4d0a-8e1b-e21107a51564@mid.andrii.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373874-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH ipsec 3/3] xfrm: iptfs: keep outer packets within pkt_size Date: Mon, 30 Nov 2026 04:52:23 +0000 Organization: Usenet Network Message-ID: <179601434315.3146.14435933528551398228@kernel.org> References: <d72476bc-56b1-4d0a-8e1b-e21107a51564@mid.andrii.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1336332"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:4fNbHwoT+DoTiV/sPsLmT030x94= sha256:Enim4Js5ROJMRF8vTPNeHWlh+fO+qz6TOkK/+nebrf8= sha1:dadXgsBzZHEKMM6rsEDV9cnx8Ng= sha256:RK5AefDrmcGd6f7YGVOSI4Q+jElaw/Ag2aPO2uJvdhs= 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 1F031125FC4; Mon, 30 Nov 2026 07:52:41 +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 eWVgA00vBrNb; Mon, 30 Nov 2026 07:52:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-373874-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 5C5F0125FC3; Mon, 30 Nov 2026 07:52:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id DF14C60065C; Mon, 30 Nov 2026 04:52:26 +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=1796014345; b=Ckz/1GNybUUyDP/o8k9rFyrkGyIeMWB2jd9ua+ccpbXpiBT74ritVTFXgPmcQObEdahJ JbpNGrr++bz+cp/lzj+unb1t73so28OzC+2C2u+Tkw687Lr+knHvwXTKFtM+TYxbNBGNH 4D4PGzT3w3gl3pKKz7bRfkP997BtMLwJucHPpRprbtBgF/UeyuFLbaRlMDJmtCEF9DcWi vGtjAqTI4dT3PWKw67s8Xr0H6utB+SFsdu3f8itHzaM6YZT4fOLOQPez8/oHnzX6DvrOP aqKf4lU5/cQRLd8hpjQ1SWM2JIzZVp7I4aGn29pNYagPzvp8kIfwSL33maeu586EwJQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796014345; 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=Y/cdkWfmTCPgtZ8Gi4SOgsrQgupS6VI2MGD8vWMFhoQ=; b=uh3iauCcT3erck5fM7HXAEexxZM5bF3OGbGLpQ9MaVjgM1n7a1EsvhTLGf38ZfARfO57 ZikeVVgQkEKTP4Ofe+VCtbtl/mDHOaVRq+FvA7u/Dkq9w0EbIf3hL1KTQZUjpvGMlhwfT Zf8VHhO4J6z8iBXUwTSwanZf4ouODqkKe7glR1m9eyBnXKyFETYCUx0cxfcXwxwBvgVF2 mL3h6OtWOMlxZu6n4JHizDLLP7tSYzzh32ikisxRS6FX3SuXK0xLA3xjZNLxZKV8K390f G3DabE5YrW7oyw3xGFeo9Jq+bWYRSY/8hTCAWkzEtp7t91VRshm941JwoUeHPxzOgpA== 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=Oe+9HGEW; 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 42F28606A331; Mon, 30 Nov 2026 04:52:25 +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=Oe+9HGEW 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=1796014344; b=IXrSBID8ahdF2rhI7Ql9vfecEtElPlB03a+crhhmiw6Iu6D/x2VMTpG0kGU7YI2J7Nb7 heK0x1ZejvrfK2DEOdER4uDZmfSTTOulKG4BcNuyDMoCyT4fHp/vTeM85Icc0aB6xkpuK vs9oD1rEPZYEllkNo8HFN3qw+kUlWNHNf9FZlp6Z+mX5L7M51Zno9mRTXFeiis8DgJ1w5 Yb5TLZQ+jbFIIxESuK9LBV/rY+qGgdtB7nmOdQNX+ZGhmnkgeJGUuz6L7gBAitVhIxBIR n4OyUpG3B1cht0GRuD0qdF8kQPN2FBhyfb5xqyKkY8y7JGhm7hGSolQ1rH4aBZ+thIA== X-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== 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=Oe+9HGEW; 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 63C42606A33A; Mon, 30 Nov 2026 04:52:24 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C2E11F00899; Mon, 30 Nov 2026 04:52:23 +0000 (UTC) X-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== 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: <d72476bc-56b1-4d0a-8e1b-e21107a51564@mid.andrii.net> X-sashiko-severity: Medium 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