🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25677

[PATCH ipsec v3 0/2] xfrm: advance the route generation when policies are removed

#25677
From: Ralf Lici
Date: Wed, 02 Dec 2026 08:52
53 lines
11193 bytes
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
Technical Details
Message-ID: <cover.1796200887.git.ralf@mandelbit.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375651-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375651-linux-kernel-netdev=dewy.ru
From: ralf@mandelbit.com (Ralf Lici)
Newsgroups: linux.kernel.netdev
Subject: [PATCH ipsec v3 0/2] xfrm: advance the route generation when policies are removed
Date: Wed,  2 Dec 2026 09:52:01 +0100
Organization: Usenet Network
Message-ID: <cover.1796200887.git.ralf@mandelbit.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1927673"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:d4oaA0uEZ2YaSUyqXxbU6q24VTw= sha256:XZztlAvQotHkxzL14qq5L+3SZEtUTVks0BXGc0l0k48=
	sha1:T5jywDuGmwm8CQuIHxi1bnmbvOM= sha256:gWBCrIckAm/AYPhX3nU5XFZI0klYyYnW1E0OdANeLmk=
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 34C7B1175B8; Wed,  2 Dec 2026 11:52:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=mandelbit.com
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 g0te5WAsKpqe;
	Wed,  2 Dec 2026 11:52:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375651-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 08AED11757C; Wed,  2 Dec 2026 11:52:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 9420E2AD4D; Wed,  2 Dec 2026 08:52:22 +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=1796201542;
	b=s+bnUEH8oksMwZviLc6sQjXZXcY4hN7LwtgBC/Zmh3QK75/8kAVKmpelhw2H1Za9PSvw
	 fZEcv32GUin6/pz8ncoZIJ/pq62iDL/4Pc82q2bbcH3TWqFY4F6ZlVqZVOQDkXSPPBPwB
	 y2XKls+CImd6MmoFIR06vvpxEXLpmnHdkGZ+m+XH5stTPoblK+oBNPJ2lB9A7lMRw17dC
	 EEIKB6PK4+hAUdgp73ZF2RIVsUuVMUNd11u9PXpkl9bICSNHMwCq5Xq51wNvcfed6oxLK
	 m3xbzNjO3QxdkgIfDn309Rca5MlLPgIT5sWUTypqFODJjSi0JWmtvl0slXoqs0yn+Cw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796201542;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Transfer-Encoding:X-Rspamd-Queue-Id;
	bh=gjup5IPQKN8F4JEXISZ1q+p9kOZuWQ0fhyIE9nJ2p28=;
	b=QOl1SK60YzUheyTcwr6JNaCaWx9NJn43+MfzwUM6uDdW8udyL4nhYSwh015La939YkTC
	 bBfOgXnWVG7sw+voKrUYoYUdWcAyqqG5mWm1x5LOJHVfZbxRzK7gddPkpE0mPfZumdqJz
	 pObA+q9D3fwMyj+XmJxPMQ5Q4wr9QZyGvu0XFPJy/M7D1ZcVzM6kT9aikj9MclMr72rvc
	 zf2cd7Z1dRgFux6/4E3mUj6HcbhqAf7nZaQDkh4HMxix3cW+KjeTBrHa2z9iOQrtGaHCg
	 q4aRyPeWnZUxnqcAQq4T71hSTRn1Sg3MAUVn0EWPzSC/e/TpXAiApuwu7Dkdkh6zHvw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=F5ttr0ba;
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	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 6D8DE606A686;
	Wed,  2 Dec 2026 08:52:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=F5ttr0ba
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.47
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796201541;
	b=M4Jhx2pdUj9L765bqO8Zl1o4WsMe6QWeHv42dH0RZQzG/JuUkNmtW0cgfckb82jwpgmj
	 1aQJHB04XDHh8VP5A2h0CgAHleqXMIHjzUVmdJq1Zuf7LtQ/kmaUH81yBkEzR+2jhB2Uf
	 tYNnXnFMoH2+e4GZKZzYqizbiQbXU7WXUT1byuvFsPvcTMerwckL1+xK01CoTL6nGq1t/
	 vKABn+qRIP8yQc0mxdV2cOinGKQXmt22K6e/5GTjgtPGNplkOwoxN7RrpA3ifs6jdXIzr
	 dG868QRr4T9SoRS3kyDDLHvdqNJ7jOhzGVH6nmr+y3y7DCJIry7orNsGIzSsRiKbGfw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796201541;
	h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding:
	 X-Rspamd-Queue-Id;
	bh=gjup5IPQKN8F4JEXISZ1q+p9kOZuWQ0fhyIE9nJ2p28=;
	b=jCshQHQKgVpptWlJPt5JnXUKdShc95euiI6gBPmS5rPR/ayyJN000YjURHV7RiXDa7Zk
	 Z2bzJlOU7clVAM6Cji29fGM6lf2qtQ06/7jGyb7Spz3UKVTd2kRzH8HFuDKRXdkOCuY8N
	 A1vOKfacBi+tetClrPIKY3jRGsdDdDQBCJSf5wplc8rn1oRNqoh0hEvtg5pnUw4ZsGfdJ
	 dgunTzzywca1S/X9+cmPpMKiVYC6gkLYQkBoOYokzg/IsCjiRL8iU1F9HHqPXWz8L6+Fw
	 kiNS5DT5xwUu1Fb71HVxaoo3MoxkYYWED/v2W1nzjz3cHsKS6bFytuUsYnOi3tx2R6w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mandelbit.com;
	spf=pass smtp.mailfrom=mandelbit.com;
	dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=F5ttr0ba;
	arc=none smtp.remote-ip=195.10.208.47
X-Received: from mout-b-107.mailbox.org (mout-b-107.mailbox.org [195.10.208.47])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6089606A689;
	Wed,  2 Dec 2026 08:52:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6089606A689
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com
X-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by mout-b-107.mailbox.org (Postfix) with ESMTPS id 4jfWjC3hCRz3yDs;
	Wed, 02 Dec 2026 09:52:15 +0100 (CET)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com;
	s=MBO0001; t=1796201535;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:
	 content-transfer-encoding:content-transfer-encoding;
	bh=gjup5IPQKN8F4JEXISZ1q+p9kOZuWQ0fhyIE9nJ2p28=;
	b=F5ttr0batjkfTDFLr5aDyzksdpvgs0mg/iP4DrYVas4IY26EXn16UF+rN2su0mjOe/zh8x
	W6Uat7uxiQeDuQhOTd6vffhbug4PkGoIEsq3EbI8tPGLNRRwDUlLWSC4i0FjW+vi1n3FOu
	iSOi7aAMwBIbIaEBPPnvt5oIbTGbUE359/BUJrsXL5CBE0WbjVbHE0b57vq2gRFKBvmlL4
	Lh0dRwGSVo03Yjva8cb3xSJcOT1k1YDv47VZp4kUGqa6P0Qu32AwRUJaPJW7WJi+TIy2/F
	yl4rhdHp+7I0IPgX62/vQEL+UBKroTqaGXrg26BQaeoDCBdRRgP9CDs/+JRZiQ==
X-Authentication-Results: outgoing_mbo_mout;
	dkim=none;
	spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=ralf@mandelbit.com
X-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
X-Mailer: git-send-email 2.56.1
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
X-Rspamd-Queue-Id: 4jfWjC3hCRz3yDs