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 3/3] xfrm: iptfs: keep outer packets within pkt_size
Date: Mon, 30 Nov 2026 04:52:23 +0000 [thread overview]
Message-ID: <179601434315.3146.14435933528551398228@kernel.org> (raw)
In-Reply-To: <d72476bc-56b1-4d0a-8e1b-e21107a51564@mid.andrii.net>
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
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
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 [this message]
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=179601434315.3146.14435933528551398228@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
all inboxes | Powered by JetHome®