Re: [PATCH ipsec] xfrm: advance the route generation when policies are removed

From: Ralf Lici

Date: Thu Nov 26 2026 - 06:32:57 EST


On Thu, 26 Nov 2026 11:18:44 +0000, netdev-bot+sinfo@xxxxxxxxxx wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>

Yes, the policy removal cases were triggered at runtime, in a VM test
setup (not observed in production AFAIK).

There is no kernel message, the symptom is plaintext on the wire. A
connected UDP socket keeps sending unencrypted datagrams after the allow
policy that exempted its flow is removed, although the ESP policy below
it now matches.

This is roughly the setup, in a netns with a veth pair (IPv4 is the
same):

ip xfrm state add src fd00::1 dst fd01::2 proto esp spi 0x1001 \
reqid 1 mode transport aead 'rfc4106(gcm(aes))' <key> 128
ip xfrm policy add src fd00::1 dst fd01::2 dir out priority 100 \
tmpl src fd00::1 dst fd01::2 proto esp reqid 1 mode transport
ip xfrm policy add src fd00::1 dst fd01::2 proto udp dport 5002 \
dir out priority 10 action allow

A UDP socket connected to [fd01::2]:5002 sends one datagram, the allow
policy is removed, then the socket sends 10 more, captured on the veth:

removal net-next ipsec + this patch
delete by selector 10 plain, 0 ESP 0 plain, 10 ESP
delete by index 10 plain, 0 ESP 0 plain, 10 ESP
hard time expiry 10 plain, 0 ESP 0 plain, 10 ESP
flush 10 plain nothing sent

The flush case replaces the ESP policy with "ip xfrm policy setdefault
out block", so that nothing may be sent once the policies are flushed.

The xfrm_policy_insert ordering is a race between the insert and a
concurrent lookup, found by code reading. That I did not reproduce at
runtime.

I can share the reproducer script if useful.

Thanks,

--
Ralf Lici
Mandelbit Srl