From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290298; b=H4ZvThMVlucX5RpdNjybxpbdgYsYsCBekrnR6Ly7BuRjvQW29Lmnq8wmYevWR8kgpe5A KjobfMEswSojSvr5VIwcC4fxOt3t3CK2NQyHc3vytvcwW/QOhLs6hniTfNfsexoEuZysU G92EAOktkss/qltncvSzyQLbUApnZZzNk1c90g1ekWbnAJGWF+gc1XqXc7xib5TMB2J/T X8XpsTboVI9aS3+AaFc01JkvnX6GpZ1uPhoS+/cdtuAuStBRPB6uJhPlkX2n25gdjVaat BgptSUIGug5s5TRFmFmXaQiYjLKpxO18eNLnSMuS5wUqaqRNraf690GD2wkkTcckzrQ== 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=lbC10+451eI2Ysc1DhSPg3y7ASc0ytjN2qidfyeXoh4yZBs8dtIafWK+pSD6BA/O9IUG 84uRr5K5e6M1vfm2tYYOV8DHjzQfIxkOhQ+S/N70Fr6ZGbyQLnMt7BYI1/Pzewl1XACFw SQibKIXRSufXfQSrh+H6ne7/9ZyKXZpCV4gphg/MXZukiZPVqJUquv1D6P6xGx91QfyB6 Kn5m7rJ+GcUUW9bJ2ljFfbFwT6v6er5TqvYGFHJKQ79aK0u3nDrp0jRRT4bWiVyhEFYoX it266EAzKHelnz7zURZyQ88mzUBBJsm+HKBlHBE8wxulFfoHK2Siwo/JAzvJotE2kxg== 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.128.47 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 B43D5606A330 for ; Thu, 3 Dec 2026 09:31:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B43D5606A330 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-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4a68f888a41so13385165e9.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=07D81HVOsRG3OxxE4mD7ut+3UvAHOCjwxHFfUTle8TcyMPaKG54w0fHz/wY7y9unL4 f/QTj5XqLmK0z+2i18y2ObWyJ8vt182FqaImh5sLSNjEkFFHj3k53kxmSq4odwROXF8P +ZaRbY2aj5APO7kZmiIR0pqBlt3usVPxRP+Y5SAL82T509mR5/K82TNw8rhyKdJ4mFE6 Yu0AEb6cG4FSY//3w2PdaELzBP9J9swUs5yjyhJQqeTNBUQfKGezXR8OF8lUkOi0qtiF 8XUPj46+yvQ0D0/fxHqA1n6uAPbzmlDkbPy+uwnuivbIl9N2ydXWGsnru+XmlEQ9WoHO nOCQ== X-Forwarded-Encrypted: i=1; AL+hErGy/shSMAYlJ95dfVoRFZzsy9ECC1jxbsFgR/Kt1FFh2XRdI7T0UF8joTRNdWH31366hvtBrj/rtRDTTQg=@vger.kernel.org X-Gm-Message-State: APuU4Z8iDg7/okzA56+VPOzwQmjsmb22fwwokM8pehW9nCojwUsremgG YTxDE93kI1J3foFqOGDstzUOQP19u+VVuPR969z4h1/nOGkGwxr96JtOyf4yHeQLwP8= X-Gm-Gg: AZFdTZczAS6eo1teYR/Wu4LPKCbGOI9WG13td2aLp97bri7SbX7kCSJ4M8zngz9X37k CCxQVaWxOQ3PS5ZZS1Cew/AZt52U1YICtujn/aWTfndzWRrF7CwLlogfMb5BT5zGrVB5Uy7Hw2z u7lbeGoZv1h4mqdc/efVs5ihoKyak4A2eivD/zzCuKf9wHi53vf1YNuV0y99W4duGQdJVmyODIz YWoLvoEWf2Gl4MnnHr8Le0/Xfw6d/1spU51YQX36it3og6wz008r0B0bdzs5Wi2iuyrdQNIoWqE c5ew/H2YBuEhDB75cJJMlzQppkuMZcE4slTJV8nPcCdIuqBZzLLTSMhx4hQgbyiwbH8r7UkmoIA p5vYir0SmhXWM+7O3oVMywUMRK/aspzL9r5v0VjWuPDNuvqFleUOtIxthG3sJZoORgO0cVdnlbn zdNvy6zqJMrR+Jf0QNkGuCP8iuGlNkUsqH05m1nLGlYLqU8IqNRVQpk+0hVkJjWdwZngFiMlHN0 sNztBxW/U4/Mu/wDfR4LE89UJivTY1o1cI/rbNOEHJTm2JNztVHet1IQdXVZEtUifKRNqXUzDtv d/f8VchKmxVCJqtwSbeLUbA7Yjb2S85Qmg6VUO9ZJSDwvSFIxqkppPEdlcoci2ph7FWVl4eT0X9 F5WRx 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: linux-kernel@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