Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290298; b=k/w0HZI2n3mb3eIrIyUqqiL5NtVLZMWMMaGORL3yF9FRMD2VIbpBK+s20fYHHDZNdz/J ha2vpNG8V+QrkYHQrgdIYnl2quSgIivSDSupS5LRC4Rkdl+u3hnH5YIbzfXJFKMl/6KBS 11lXEcZvQ76qrDzlSQyU2aV2Q8x2Ut5ypf9v2vjMWh0zoIXItZdwTI7pEbtLp8MU0k3LE P0qN0LSeggVJbARo0HDpRhuMk3Y8zsx7lJfr/dO6sYXf4ghD25t8GB4N6vwUxm2/8T/97 phZFU3Qkv93RuE9AXSUVZWTeX1hlFsN/iMkvN8+U5W7MZnopSQ3zV6aCVGl2iZGFVGA== 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=LxhjJ/MRHv4ubGc8aE0lY8MbN0pQNFKutJRjBB3UWTW9Msorjd0h1Ak4AYs11Tl0GaSp LA6XuAbQyjoGSuwqXcunYpatH10DUR0fiy3pB0YAjSbQPCVXJ+4dubHD2ppF+1yfoH1/5 F44VzYBje4W+5X1GdzFYyUS8Lc5s6BBJUyMICKjgiuvWtE88WOK1iNIIeLGs2922T6cgw xALIOoMlecNhPM1OEkR7GtgPOxxvEdpFUnTPwZy2+4+KHOuQTZzWv6/NimWbOa9EROLwC ufSXlwe52ADLK5vHXQNt9SRaBVLQ2ekfRFWFYGvzMrZP3B5suZMJjxdVacprh+7R+TA== 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=ASeJFG4j; arc=none smtp.remote-ip=209.85.221.54 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 B9361606A333 for ; Thu, 3 Dec 2026 09:31:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9361606A333 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=ASeJFG4j Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-49a357e48a2so1030226f8f.3 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=lists.linux.dev; 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=ASeJFG4j40w87GLACmRpgrbywVj6wuIyB8bFSLriLAcEDe0pPzf9LMn29CXR9xb/Zh tAu7FzauSHUJ/+obgf7cM65LK8aXg5zMrIYtd9DdLNj9I6MH3bMg3ylpmi9H6VfUYLhs NKS3T8/8yNerMrlCS8OPQ2YexoGlDGjIpU7xKOyVN5Q2dY/3Z8/zkxqdf1XYoVcJ1Lxl f3KkYA0OX71w1Y5BA9U5PqreWcAT9DG1OzDCF1DDK723cRB9mUvFNjH/ezb1DA7Fsp13 /OeZXuMBHiDfQvOc0PJbGHLu4Yz7JzOgP7UP4dEIgfREb5pKpqlQLHB3v2UEbzcRbfsB QItg== 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=ZLnhznMABaTokcuOk9jtVvo8xM6bt/Gwdh4Ze33/D7hpYJa19/6mSBkDe5n2VXfJv2 DfoCwF6bhe35FjDcHXkWZwWZYKE4OHqB3e6LbA9O+5l/Lg5Xh2IJq5n+OZnEpirxUJYT 0p0LrdCZKrU4LoaNeob49PeMKXEua9SxR+qmL+w2Y6/ngGxDm30gtaxUdCjL8fUL+w1r 93rL6gYi2qm/lg0Mh+Mhmlep06KQNsg5/5lV+ePhnexjM3Q77SbPnhyIdnafEhBttZA6 r6xNxorZxMNq75jiDElTGlUqYRUzcK2UMaG6I+xl/mmySaqnHFe1+xWY2FbQydFiLcXp on8A== X-Forwarded-Encrypted: i=1; AL+hErEMVUu5CgKnMZ8+4Nj5c4WoWcOh3oMrLM4/HsiG2MV76IRxtKHLSenM38DbRLVbSMVbkxk82g==@lists.linux.dev X-Gm-Message-State: APuU4Z+CbKx3uYuI6VWlOL2DR92PomU/PdKmVWwpiYJnYjMjzhrUsDer c4q+XqbCB9BdvJ6MpBqEvgra0x0frWCPbw8TVOoHZcgJwQE5kv8cxcdGwp7Wn9RXULg= X-Gm-Gg: AZFdTZekCiAA2pTSzKjvo0XuTxuUuJf/meDxswOElZm5gDv1oaFVclWdO3egt+ozQEQ qopbclbqPXXvHXbrb8nxirj6X4QuOL8p7EPCyEknqWCPKEaomPMbWXg7f/EKm8FzE2noG72JABZ HXmR93uFC7gj0O76rIbZ8QfjUOuOI2hyeEaf6SFK2e04K5IHC5ElW2XDCqdaCfBvju0/6mrDsMe /HphnTIwkTQwViF9nPMio3+ZU8ti9c7UWhzw3j71SiUF+RwHr93VZ437Gwq79iZMSK7TPdTAOgI VKWgU5hLQ6b06GxqD79tTir6l3XD1C9MCFwG0zNyCA0kLO/Wvi2krfjAgEEhJZPfJtJ4d+aiCX4 EWI7HeKARAnqCFcJHVv8Ciwb8d0nKthIE0hXTTFB2cP78JG9lGtnbsTRbRPsPfrKFXWdkSUCmyB J+wBVG4Zf22mmby4PRtgY5NGYHcYjY/Qn9HbS2j43LaduqN9/AFCw63bOFIAZkzL7iZbm3LCvco FlvsA52J8whWKHSctpKFt2V4VBUPeGwGG2FvTuB84KqZX+JwrgnYYGaFSd56LMSRic/rs4tTIIM Js5mYrHaHHH/96MyLU1X8KnTyco+LUo/CiSj/8dI5wPyc/zYVinLZYj69HcxEwQxonBPn1MQpYS Ljg/G 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: ipsec@lists.linux.dev 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