All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Lici <ralf@mandelbit.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Sabrina Dubroca <sd@queasysnail.net>,
	netdev@vger.kernel.org, ipsec@lists.linux.dev,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH ipsec v3 0/2] xfrm: advance the route generation when policies are removed
Date: Wed,  2 Dec 2026 09:52:01 +0100	[thread overview]
Message-ID: <cover.1796200887.git.ralf@mandelbit.com> (raw)

Hi,

Deleting, flushing or expiring an xfrm policy does not advance the IPv4
and IPv6 route generations, so a socket that cached a plain route while
an allow policy matched its flow keeps sending in plaintext after that
policy is removed, although a policy requiring IPsec now matches.

This was triggered at runtime in a VM test setup (not observed in
production): a connected UDP socket keeps sending unencrypted datagrams
after the allow policy that exempted its flow is deleted, deleted by
index or expires, and keeps sending after a flush with the output
default set to block. Patch 2 adds that reproducer as a selftest, which
fails in all these cases without patch 1, for both IPv4 and IPv6.

Thanks,

Ralf Lici
Mandelbit Srl

---
Changes since v2 https://lore.kernel.org/netdev/cover.1795797791.git.ralf@mandelbit.com/
- Leave the IPv6 route generation bump in xfrm_policy_delete, which also
  runs from the policy timer in softirq context, to a work item, which
  coalesces the expiries into one FIB walk. (Sashiko, Nicolas)
- Order the policy unlink before the IPv4 bump. (Sashiko)
- Drop Nicolas's Reviewed-by on 1/2, since the delete path changed.
- selftest: pass nodad for IPv6 only and give the expiring policy a
  longer lifetime. (Nicolas)
- selftest: fail rather than skip when a policy is rejected or the first
  datagram fails, and wait for the deferred invalidation after an
  expiry. (Sashiko)

Changes since v1 https://lore.kernel.org/netdev/20261126111516.317545-1-ralf@mandelbit.com/
- Add a selftest. (Nicolas)
- Cc ipsec@lists.linux.dev.

Ralf Lici (2):
  xfrm: advance the route generation when policies are removed
  selftests: net: add a test for xfrm policy removal

 include/net/netns/xfrm.h                      |   1 +
 net/xfrm/xfrm_policy.c                        |  58 ++++-
 tools/testing/selftests/net/Makefile          |   1 +
 tools/testing/selftests/net/config            |   1 +
 .../selftests/net/xfrm_policy_removal.sh      | 236 ++++++++++++++++++
 5 files changed, 287 insertions(+), 10 deletions(-)
 create mode 100755 tools/testing/selftests/net/xfrm_policy_removal.sh


base-commit: bb65a0da99bf4861dce01149ba64e875e47ae5a3
-- 
2.56.1


             reply	other threads:[~2026-12-02  8:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:52 Ralf Lici [this message]
2026-12-02  8:52 ` [PATCH ipsec v3 1/2] xfrm: advance the route generation when policies are removed Ralf Lici
2026-12-02  8:52 ` [PATCH ipsec v3 2/2] selftests: net: add a test for xfrm policy removal Ralf Lici

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=cover.1796200887.git.ralf@mandelbit.com \
    --to=ralf@mandelbit.com \
    --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=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=shuah@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.