Article View: linux.kernel.netdev
Article #26243Re: [PATCH ipsec v3 1/2] xfrm: advance the route generation when policies are removed
From: Nicolas Dichtel
Date: Thu, 03 Dec 2026 09:31
Date: Thu, 03 Dec 2026 09:31
47 lines
13907 bytes
13907 bytes
Le 02/12/2026 ร 09:52, Ralf Lici a รฉcritย :> Only xfrm_policy_insert and
xfrm_set_default advance the IPv4 and IPv6
> route generations. Deleting, flushing or expiring a policy does not, so
> a route that a socket cached while an allow policy without templates
> matched its flow keeps validating after that policy is removed, and the
> socket keeps sending in plaintext although a policy requiring IPsec now
> matches. xfrm_policy_insert also advances the generation before
> unlinking the policy that the new one replaces, which can still be
> matched until then, since the new policy can be linked behind it.
>
> Advance the generation once a policy is unlinked by a delete, once after
> all policies are unlinked by a flush, and after the replaced policy is
> unlinked by an insert. xfrm_policy_delete also runs from the policy
> timer, in softirq context, where the IPv6 bump, a walk of the FIB, would
> run once for each expiring policy, so leave it to a work item, which
> coalesces the expiries into one walk in process context. The IPv4 bump
> is a plain atomic_inc, so order the unlink before it. Socket policies
> only apply to their own socket and are left out.
>
> Fixes: ee8372dd1989 ("xfrm: invalidate dst on policy insertion/deletion")
> Signed-off-by: Ralf Lici <ralf@mandelbit.com>
[snip]
> @@ -2365,6 +2387,16 @@ int xfrm_policy_delete(struct xfrm_policy *pol, int dir)
>
> spin_lock_bh(&net->xfrm.xfrm_policy_lock);
> pol = __xfrm_policy_unlink(pol, dir);
> + /* The policy timer calls this in softirq context, so leave the IPv6
> + * FIB walk to process context, once for all the policies that expire
> + * together. Socket policies only apply to their own socket.
> + */
> + if (pol && dir < XFRM_POLICY_MAX) {
> + if (pol->family == AF_INET)
> + xfrm_policy_bump_rt_genid(net, AF_INET);
> + else
> + schedule_work(&net->xfrm.policy_genid_ipv6_work);
> + }
With this, an IPv6 socket can still send in plaintext after the policy is
removed, until the work runs. This also applies to a hard XFRM_MSG_POLEXPIRE,
which goes through xfrm_policy_delete() too. The window is probably short, and
the selftest tolerates it, but given the nature of the bug, I think the commit
log should mention it.
Regards,
Nicolas
Technical Details
Message-ID:
<273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376443-linux-kernel-netdev=dewy.ruReferences:
<cover.1796200887.git.ralf@mandelbit.com> <c8dd9a89e7a293b30f69b12a8b8888e7bb47c241.1796200887.git.ralf@mandelbit.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376443-linux-kernel-netdev=dewy.ru
From: nicolas.dichtel@6wind.com (Nicolas Dichtel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH ipsec v3 1/2] xfrm: advance the route generation when
policies are removed
Date: Thu, 3 Dec 2026 10:31:34 +0100
Organization: Usenet Network
Message-ID: <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com>
References: <cover.1796200887.git.ralf@mandelbit.com>
<c8dd9a89e7a293b30f69b12a8b8888e7bb47c241.1796200887.git.ralf@mandelbit.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2448762"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AMOW0exEVmXcxVEA4Y9j5VuBLKQ= sha256:OjewW3vHyQx/7+n6nPpz8TeHIzBczwpQ5Y0YTFFw0Os=
sha1:qPNqI+h0pJZ+vn5SZDk95V9qr/Y= sha256:fPlTZpuVIrTM25Y7Nwt2RuvbZbhzHbJ77jhYGWnRPTM=
Content-Language: en-US
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 2C3E81178A5; Thu, 3 Dec 2026 12:31:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
tests=[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]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=6wind.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 CbC10Vyhm574;
Thu, 3 Dec 2026 12:31:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376443-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=6wind.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 8D7271178A1; Thu, 3 Dec 2026 12:31:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 52EF926269; Thu, 3 Dec 2026 09:31:43 +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=1796290299;
b=TbJMWatUpqjJ1jUBhvQAIomI1myWhjZNGJ/ZUWQyZ6jljdm1Au8EYyLt4SNrJbKsKh9h
+bjZiAQJwfrzXCwhMpI3rsuLqB6MMAzNyrqiceM2u1P/4WOjI3ZjBoKMuyVxJ+ym5temB
Lqo88/iTyI3XhPoHnDkGx1z54scfU7DFKUfE2Bw3YBPnuHg+5fzQ8V6k4rtkIBHGK22KA
A34cvV9vO7guv827V2jWfCO/vdvyE9xDV1LlAlqcMYwlfk2z6w9G3odgZ84mW0S8EGlv/
NuCpyg6HqHw2t/eModfJ7Q5+K1doZLNZqq1Lsc8JMrydeSiPMq+JIggtUDoDUtzUwlg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796290299;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:References:
From:Content-Language:Organization:In-Reply-To:Content-Type:
Content-Transfer-Encoding;
bh=vl0DkdeFvQayNfq+2sWPkgzjAAWf/t9ndmJDlkee7Mo=;
b=dI/XMVbUOjO57SW0WVU6rPNW4f0uXGvcheQO1o0wf+0P03NYOHqs39YoUSawehRO4hSH
0zy9d/QxVZNZxl7Us6fLNDhKzJB/vbEp/ShdfoT5XxVUKMvbCgCC+Nb8AKcQXoxk34vaR
Ps5G7evvTnRTgT8g5+Pmh/4WpfELSVmHGxWzyyPEcKSneR2/QFfi3dO5L3s3bwCKP6ink
vy8Xz3p2aEAKcaEt35kYunjt1hta6zui87r6UH2EThPUBSkNf3GyUo7/XVp49dbWqukum
ody79ZzZTRCO43Kl0pldHBYL9su6yj7Q7jH6Wu8rB/2auGYXBDBs5LDIry2fht4F8hA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=hOmLyGGY;
dmarc=pass header.from=6wind.com;
spf=pass smtp.mailfrom=6wind.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 E2B79606A692;
Thu, 3 Dec 2026 09:31:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=hOmLyGGY
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796290298;
b=qtE3rDgEVJKcG4hlsnMIdzlvW3s3+w2LzGwz3qsWBkLvkKj9mjBRUMF0xmU/IVAaEzO6
774Yjv7PkQe6toYTPSCyuurztfvkd3i2ymTB54k9O7mAEPgOUuU8MMD4SX+LR68h0sGZr
eh/VXjubDlhWiqzimB/ThaI5v5sFo0tfF3/D+vVzrPcCyVoqgYd8iQJK4/ciOa4YqDWvY
VvqHYdTIevBMgiUKUG23s8nH3O6aetXq3CpEgr35ry6JIWrOr6s/FrAj1gYWthD5lrbQd
5MlVeWBB/zegIuDRC9TtotBmBp5VAiNokqtbYDOY5j4pFRj2RT4NoleNtFmsbnt4wVw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796290298;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Message-ID:Date:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:
References:From:Content-Language:Organization:In-Reply-To:
Content-Type:Content-Transfer-Encoding;
bh=vl0DkdeFvQayNfq+2sWPkgzjAAWf/t9ndmJDlkee7Mo=;
b=O0lyA3NTm9KBkRHyDoFGHwOfiqWCfrCw3pfCTL/Dvb8U9blE3Gdx1AmDQD952fE4aEuO
AtDzh9deD52DhfIIGCxNXoeO+iVdfRAA2lgr1u9AOE7WHOj95f7qq6OXiI/5DrHKD4hKs
xonvvBeGgdGpzuvw6/ZpzUEzcMNnOSHvbG2tqvfqgshHRkYhhpBml6xfWssYQUDhp2u6n
usyWnTqdKrJ8EKhl7gbP/4DiJ+z0gSFGKJlj0R1Pww2oSr8urzaEYQE8nBnC/CWDUp7PX
69cQOISA/3ml2UTBj+oKJ/P/JJoeUnLCK1OS82wKzzOAICDLoo0BKu8dtfkLaGuXhCQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=6wind.com;
spf=pass smtp.mailfrom=6wind.com;
dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=hOmLyGGY;
arc=none smtp.remote-ip=209.85.221.41
X-Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id B23AE606A32C
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 09:31:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B23AE606A32C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com
X-Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-4a3dd785f65so886121f8f.0
for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 01:31:37 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=6wind.com; s=google; t=1796290296; x=1796895096; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:in-reply-to:organization
:content-language:from:references:cc:to:subject:reply-to:user-agent
:mime-version:date:message-id:from:to:cc:subject:date:message-id
:reply-to:content-type;
bh=vl0DkdeFvQayNfq+2sWPkgzjAAWf/t9ndmJDlkee7Mo=;
b=hOmLyGGYPvss/4yLprVUoDOokJaxeOjqW9UQKL6TCnP2ZpBypqPOjuaC7XMwB0lOHF
P7gQzq9bue+bpzQcXnAOWCV2dRdkBg8A2gp1C1Se88G6InfmYH7mM2xOfkZ0HlJK11eG
KCKlSfMpl/KlbcqkoZ2NuRFTBRhUXlj+swKWzTU7Cmg/4x3/jj51yIh35GnDPoD29G+p
jYiNfqlKKYoZEPUir4maluRswCdvrMD5Q0amqQTftCAS3/o52XOk0hqKUV7z5bmrFjfT
Z+kSQv7UEZ4vnpGy1cek5u5/2FFFkONr32vwSLFCWErnu88pMXpwv865W79hDqTSAVdv
SigQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796290296; x=1796895096;
h=content-transfer-encoding:content-type:in-reply-to:organization
:content-language:from:references:cc:to:subject:reply-to:user-agent
:mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=vl0DkdeFvQayNfq+2sWPkgzjAAWf/t9ndmJDlkee7Mo=;
b=GgFInqrayWQRoIY9XQSwi7BrwDwlMfsiiFSZrc36KZb8aqAn8YdIz2l0KCC6rrHto8
rs3SJ5tFTbP0uJnBFz7JAwNZXqS86+ZPdPY+9fL6gdR5nAFypyq7vvq64qK0v5mRIaM6
FZ8mAVu7dCKC75swEMRbnmlKEU43LrjEWxdFVxl1Ux1M6p/ORUolKOsH65K5mV7igX95
7NSOB3JNTmJli4Ft0AT5L3n3XqoF+YdBoeTh6rh5KH4JfkzAyQVdGMF72+nlw2D/zquf
Syq1aYzWKNOUYShlytU4rJDOd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mr11645135e9.2.1796290296127;
Thu, 03 Dec 2026 01:31:36 -0800 (PST)
X-Received: from ?IPV6:2a01:e0a:ab7:2110:6a1d:efff:fe52:1959? ([2a01:e0a:ab7:2110:6a1d:efff:fe52:1959])
by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe007079fsm63500015e9.15.2026.12.03.01.31.35
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Thu, 03 Dec 2026 01:31:35 -0800 (PST)
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-User-Agent: Mozilla Thunderbird
X-Reply-To: nicolas.dichtel@6wind.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>,
Sabrina Dubroca <sd@queasysnail.net>, netdev@vger.kernel.org,
ipsec@lists.linux.dev, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Organization: 6WIND
X-In-Reply-To: <c8dd9a89e7a293b30f69b12a8b8888e7bb47c241.1796200887.git.ralf@mandelbit.com>