Article View: linux.kernel.netdev
Article #26270Re: [PATCH ipsec v3 1/2] xfrm: advance the route generation when policies are removed
From: Ralf Lici
Date: Thu, 03 Dec 2026 10:18
Date: Thu, 03 Dec 2026 10:18
53 lines
12103 bytes
12103 bytes
On Thu, 03 Dec 2026 10:31:34 +0100, Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
> 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.
>
Right, I'll mention it in v4, together with the hard XFRM_MSG_POLEXPIRE
case. Thanks for the review!
--
Ralf Lici
Mandelbit Srl
Technical Details
Message-ID:
<20261203101817.198835-1-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!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376472-linux-kernel-netdev=dewy.ruReferences:
<cover.1796200887.git.ralf@mandelbit.com> <c8dd9a89e7a293b30f69b12a8b8888e7bb47c241.1796200887.git.ralf@mandelbit.com> <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com>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!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376472-linux-kernel-netdev=dewy.ru From: ralf@mandelbit.com (Ralf Lici) 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 11:18:16 +0100 Organization: Usenet Network Message-ID: <20261203101817.198835-1-ralf@mandelbit.com> References: <cover.1796200887.git.ralf@mandelbit.com> <c8dd9a89e7a293b30f69b12a8b8888e7bb47c241.1796200887.git.ralf@mandelbit.com> <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2457862"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:tGRZDN9l7un+TdZAYio+vEm2mu0= sha256:nXaD32uCLAD5JBh/CVLbgJN5DGkWl96kp7My+X68IVw= sha1:IqvzmDow2X+6C4A4Wqtl59uKt6Y= sha256:BAi4reS/bYQnMXDgG+IFJgFQj3M68vXClL4X85OFU4I= 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 5734F1178C5; Thu, 3 Dec 2026 13:19:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 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] 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 Q2cdHYEmvL2T; Thu, 3 Dec 2026 13:18:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376472-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 8C7CA11786C; Thu, 3 Dec 2026 13:18:41 +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 B159F26581; Thu, 3 Dec 2026 10:18:37 +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=1796293117; b=AsVQGHGhWU+wRMt1lsY2vx9rAs6LIZO6ctOWuIoXWQ2pj3V8Mi8w6oqvvYfpStIvZkKR eIwXhFJxf/mAZHzoWBjWFZDWrsvGaNV1Fdb/W2zruY+j18yjzQLBEvZ6ThSzzjOV+rGyp kUoNZA9mKEEaiyyYs4XDikCUi+LrbefLjMyVqJb2p/F5/xefi7AREKG1RoS1YGfjKzvcF /wqGQRetzNKD8VlNWionCd2+CYbMVhA2fC8uUu0h1c1oiIbBmm8uv0GIBTzWwRtarrVtX 6LwsrYE5agO5YeuxASy4LDP1JhC7IJxU0Hy50KKx/IaFIfritXn1qQjzm0QF9a8jCeQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293117; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=YemrX5QAsLSMu2/3Kn4rkbFaRP1DMgwlbCEHn/FtxIo=; b=1FiYhg4rxsj+M3tCdRj6eOCf9l7BY0T1QlYEvud8vcYsdFjvwVXKoPaJDdgFJI6UZPLE gb0IhiXqj1iMy8bCar3LYlkcveWC8FOPMdc7/giXLBTjoyN9mZTr3wPhsKVHYAE9XwVd1 GpHVmvMaOMNGLcaU/cNdJPe2KxzeNb+LvhPEC8950dGp7iCFF3VaA4RiR+RHztgjCQjlw ieBsokHycP90PifARKbePlJnbdsN+ffN/S+SvMVuXfTKYL4ZON4XgcqL1uEbhz7c9pOHh DXbri/i13nzj5UOigGoBkkodKqBPO4XxxO+z4ueJcqIC94EuFH7jXYQiRHyqo/Dn9sw== 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=cQUDqC9i; 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 8A187606A332; Thu, 3 Dec 2026 10:18:37 +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=cQUDqC9i X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.42 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796293111; b=4vEuiyrhbzvQN1JPJ1l4Of4ygfs+yUGEaBm7bbWjRe3cfrWie3L5+g60lL9ae4ggQA0E SwXyQNXNJEwpg/grLUV7DIfCEuiwLdHNqTN+Vz2gcoeTmW+3Q58R6Ek/OiDadppmoO65e fErGsBd6IwRdF9ykyfl+UFADJo17oOawAHvLgliba1NAw0U3MA/PlqmJY5n83ChW+r4wL smPxSNlbSHGHMKK9V4HmyPVG04tgmW88MXWZFprr6aNvFk2fUDwaU9LXt4bPuMGPHQE1v K0GkJo/Y74OUWjlpXZvYChzO9QWhPGN0x75mX+kdwt7McIeew38vKxUIQMJ30s1PLTQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293111; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=YemrX5QAsLSMu2/3Kn4rkbFaRP1DMgwlbCEHn/FtxIo=; b=nJfe0LRNg7J3zM5+msDXLljM57Aa3g99bsg96QkFAM98R6soAIm8zNaa9TB8N6k+LDk1 6o8H853/ijo5Uxy1AiFmV+WmJyVJx4zIxYKe4BFiAfOPhtywp7KawTwO/LI8zubc6O9yG TljUU3i5Z4wLlNAuHscjkyS8hCdxYTmgWh9hVRyqRWItIzDxD9CG/TOWBozU0P5uy2XCY +xzPS5rHfRPvaI5j2sv1qIdlHlndCbXkB1IqjZTtOBsxcdHMCx4eehMsnKkmikAwJjQhg z9OMaGv6m6QkXDNoyevKz6D/fF+I66aCcXOaX2+5hBxGM2dFjFKeljqsLE1PpBms5VQ== 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=cQUDqC9i; arc=none smtp.remote-ip=195.10.208.42 X-Received: from mout-b-112.mailbox.org (mout-b-112.mailbox.org [195.10.208.42]) (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 5721F606A32C; Thu, 3 Dec 2026 10:18:30 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5721F606A32C 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-112.mailbox.org (Postfix) with ESMTPS id 4jg9Z41hRbz5xFC; Thu, 03 Dec 2026 11:18:20 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796293100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YemrX5QAsLSMu2/3Kn4rkbFaRP1DMgwlbCEHn/FtxIo=; b=cQUDqC9i78w4538NJwIqgqKCt8piKTqqLqNbitZUWV80UF/D+Fy/HVDX4TNKWcHkM04/84 iIkTCmxqtabVw9Fth7v9uqFvPUnOSQOau/R9CRAJgNhT+UHC9cxYhM2xftrNPah3XmZCN2 V6bNqb5vNl1Fz303QFnwCDb8fAYf/HfA38S2d5+OXRAIJGee7ftDZF62l3y3X2LXdohzD+ w80+8Nr18fIamqaMh7BCpgZiEWGZ6ZxeAmOSF3YjCgULe4u2qc7mN0F6QcoQRNKtfOcm8F Jo7YWMG7cWbg8PxledaFnmzGxGzCrbpW0jvGRyq1RwgvWh1ZJzpqAOt1jF7K2A== 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: Steffen Klassert <steffen.klassert@secunet.com>, Herbert Xu <herbert@gondor.apana.org.au>, "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-Mailer: git-send-email 2.56.1 X-In-Reply-To: <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com> 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: 4jg9Z41hRbz5xFC