From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41 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== 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== 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 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 ; Thu, 3 Dec 2026 09:31:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B23AE606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com 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 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-4a3dd785f65so886121f8f.0 for ; Thu, 03 Dec 2026 01:31:37 -0800 (PST) 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 Syq1aYzWKNOUYShlytU4rJDOdJQuguIAFxN8H0rIupmC/2poNnyzZE4bcHlp0Tehr3OH TJPw== X-Forwarded-Encrypted: i=1; AL+hErGCvjNiBWRoc1BKBIX9i2T8+OFmDZATtazKRO3KpOYfczFTu59ewbxSeQAaZ7Q4F1nU28wWv/E=@vger.kernel.org X-Gm-Message-State: APuU4Z9oak/TgNAPTEr0Q16vXpez5wezU/NpZ33wuAR1JO90TSgestn+ Z65CT9Dg/sTYDvTl/3fvXJAj7K2Fx1JAKGDsHOmrnIs1i4HJlGYBq7CEH5cDl+Pr6BCB+IkVXP5 SR8IP3oM= X-Gm-Gg: AZFdTZd+D13W1t74T9ynHmoYmVKjF0KCxnNlzuXHQC/K/v3BbzORCF9kdwzFEhKtg/G YIoMVOUKSezO+T/hYABt/yq3UzgQKCW4FC76m0Shs29edphIU7Mr3z1Ri3QPlZlqm71Qvmlo/Jl ymGS17f5+IdjiU7MWen34OMxk1GCYsPp8+laOqjGzwlkcFWtCgfUaA+fHT/BspVmZMrr40MhMtA o1zWbBlWbYq1ALZJrLs9APeW5XaqBdAT3NL7YH/gDbwnGRIZfD2ujBTIgu2/AC8ULKdln8tR9/D o5xdIY2PiIx/7BeThHvoRwlG87HXSMTf7pg1HPxJpMACxYZiwRQMesZckj30H6BQ0e/EJl/0WIN bfUERWoZ5A9rEZP0n/029N/QYEjr/u0SiMUoMCxSeAiHO8wwRP9YUxFd0t0lRv9UqFwbMN35YFz fVN/kJp1AnDu5TL9DAWiCqiQTEovH1R8fxLp486ykY7YJhpm4j/R7GNkgxsPSLdKrdghO/+uj8Y C1z/z0ybWlt69KQ//IacWEpoW6efb0ADshhMbYmcpbM+e1Ptadu4+UKevyCWjXI7JcmvQE2Itxa 8gjSPFfPcFZbyXCJ45bsEZQBCgf8wF/nVmKhqsfSqcU1AA4nstzRkcRBcfWKpvIFw4hvRACV5DB sXLAL X-Received: by 2002:a7b:cb42:0:b0:4bb:b631:92e3 with SMTP id 5b1f17b1804b1-4bbe2ec4eddmr11645135e9.2.1796290296127; Thu, 03 Dec 2026 01:31:36 -0800 (PST) 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) Message-ID: <273c02a9-4801-48f3-9341-2b115629d6a1@6wind.com> Date: Thu, 3 Dec 2026 10:31:34 +0100 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 User-Agent: Mozilla Thunderbird Reply-To: nicolas.dichtel@6wind.com Subject: Re: [PATCH ipsec v3 1/2] xfrm: advance the route generation when policies are removed To: Ralf Lici , Steffen Klassert , Herbert Xu Cc: "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 References: From: Nicolas Dichtel Content-Language: en-US Organization: 6WIND In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Regards, Nicolas