Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 30 Nov 2026 04:52
Re: [PATCH ipsec 3/3] xfrm: iptfs: keep outer packets within pkt_size
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads