From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.47 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6089606A689 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com 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 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) 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== 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 From: Ralf Lici To: Steffen Klassert , Herbert Xu Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Shuah Khan , Nicolas Dichtel , Sabrina Dubroca , 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 Message-ID: X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jfWjC3hCRz3yDs 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