From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.42 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5721F606A32C 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=cQUDqC9i 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) 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== 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: nicolas.dichtel@6wind.com Cc: Steffen Klassert , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Shuah Khan , Sabrina Dubroca , netdev@vger.kernel.org, ipsec@lists.linux.dev, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org 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 Message-ID: <20261203101817.198835-1-ralf@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com> References: <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4jg9Z41hRbz5xFC On Thu, 03 Dec 2026 10:31:34 +0100, Nicolas Dichtel 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 > > [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