Article View: linux.kernel.netdev
Article #24039Re: [PATCH ipsec 1/4] xfrm: Give GC list nodes their own storage
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 02:14
Date: Sun, 29 Nov 2026 02:14
99 lines
11945 bytes
11945 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit fixes two aliasing bugs but has only one Fixes: tag,
d737a5805581 ("xfrm: state: don't use lock anymore unless acquire…
- [Low] The message says the gclist/bydst linkage is overwritten "later,
when the last reference is dropped", and then that "the same issue…
--
xfrm: Give GC list nodes their own storage
This patch stops struct xfrm_state from sharing storage between gclist
and bydst, and between dev_gclist and bysrc. Without the split, lock-free
RCU readers of the bydst and bysrc hash chains could follow linkage that
the GC lists had already overwritten. dev_gclist now shares a union with
byseq, which is only walked under xfrm_state_lock.
> Later, when the last reference is dropped, __xfrm_state_destroy()
> adds x->gclist to xfrm_state_gc_list. Since gclist and bydst
> currently share the same storage, adding the state to the GC list can
> overwrite the bydst linkage while an RCU reader is still using it.
> The same issue applies to dev_gclist and bysrc.
[Severity: Low]
Is "the same issue" accurate for the dev_gclist/bysrc half? Its mechanism
and its consequence look different from the gclist/bydst case.
dev_gclist is not written when the last reference is dropped. It is
written right after the RCU unlink, and no grace period passes first:
__xfrm_state_delete()
hlist_del_init_rcu(&x->bysrc); /* ->next kept for readers */
...
spin_unlock(&net->xfrm.xfrm_state_lock);
xfrm_dev_state_delete(x)
hlist_add_head(&x->dev_gclist, &xfrm_state_dev_gc_list);
Then xfrm_dev_state_flush() calls xfrm_dev_state_free() right after
xfrm_state_delete(), with no synchronize_rcu(). xfrm_dev_state_free()
does this:
if (!hlist_unhashed(&x->dev_gclist))
hlist_del(&x->dev_gclist);
hlist_del() writes LIST_POISON1 into the storage that used to alias
x->bysrc.next.
Suppose a reader in __xfrm_state_lookup_byaddr() is on x at that point:
hlist_for_each_entry_rcu(x, state_ptrs->bysrc + h, bysrc) {
if (x->props.family != family ||
It can load LIST_POISON1. hlist_entry_safe() only filters NULL, so the
read of x->props.family would fault. The reader could also follow
x->bysrc.next into another state on the dev GC list, and that state may
already have been freed.
These lookups run from xfrm6_input_addr() on IPv6 receive, and from the
XFRM_MSG_DELSA/GETSA netlink path in xfrm_user.c.
For gclist/bydst, xfrm_state_gc_task() calls synchronize_rcu() before
freeing. The result there is mostly a diverted or truncated walk, so
SAs get missed.
Could the commit message say that the offload half fixes a possible oops
or use-after-free, and not only a corrupted walk?
> Fixes: d737a5805581 ("xfrm: state: don't use lock anymore unless acquire operation is needed")
[Severity: Low]
This tag covers the gclist/bydst alias. Does the dev_gclist/bysrc alias
need its own Fixes: tags?
Commit 07b87f9eea0c ("xfrm: Fix unregister netdevice hang on hardware
offload.") added the union of dev_gclist and bysrc in 2024.
Later, commit 2e460eefbd44 ("xfrm: state: make xfrm_state_lookup_byaddr
lockless") replaced spin_lock_bh(&net->xfrm.xfrm_state_lock) with
rcu_read_lock() in xfrm_state_lookup_byaddr().
Before that change, every bysrc walker held xfrm_state_lock. This
includes __xfrm_state_lookup_byaddr() through both
xfrm_state_lookup_byaddr() and __xfrm_state_locate(), and also
xfrm_migrate_state_find(). Reusing the bysrc storage only became unsafe
once both commits were in the tree.
Stable trees older than 6.10 don't have the dev_gclist union, so the
include/net/xfrm.h hunk won't apply there as-is.
Would Fixes: tags for 07b87f9eea0c and 2e460eefbd44 make it clearer
which trees need the bysrc half?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125013412.1123866-1-jianbol%40nvidia.com
Technical Details
Message-ID:
<179591847972.3135.16907973135135504288@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373338-linux-kernel-netdev=dewy.ruReferences:
<20261125013412.1123866-2-jianbol@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373338-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH ipsec 1/4] xfrm: Give GC list nodes their own storage Date: Sun, 29 Nov 2026 02:14:39 +0000 Organization: Usenet Network Message-ID: <179591847972.3135.16907973135135504288@kernel.org> References: <20261125013412.1123866-2-jianbol@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1082310"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:C0tfKG90rtC838IR5mJkBCdDINI= sha256:V+0+1hCtvAAlCHTK2opD4AfBiAdfWsHSiQOHKJVRBIg= sha1:C2XAe2ijdgzRpIxpSSuztJEm+AI= sha256:qFCxTrpsh6Zu2Jc+hH0hzjsBK4dMlmIQ4rgbibZjHWQ= 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 4C2FD125F96; Sun, 29 Nov 2026 05:15:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 dHVwqlHH8nOX; Sun, 29 Nov 2026 05:14:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373338-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 29858125F90; Sun, 29 Nov 2026 05:14:47 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id B3C8F25A18; Sun, 29 Nov 2026 02:14:44 +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=1795918482; b=fW6y3YI53Jx1bRHA9DcVtlWQ0B0O2DTOt0aWwKFQqqYjxBer1R2fOJk2BB8i4LgNi2+u XRd15ryj63+VtPD9IFyAI8jkiLck9rtmUvfUCsA2HRQPxrFnwHk+d0RwVVEL6KFjV2B+C GyUayz3aKF5PhR+DqvEMDDrWjZSzioDsFOWmo9NcRGKrYjBZ2Om47G2H2nBDkV+cq1MPJ DQLp1TgLYRED1jwxxt8xdOR9498eT4YDriZ3t1SdVEfmLLX9cI5a54a/g1PW0tF2ia18J oa3Q5zZyjdyaDwcbUDCvhVm48hFyXc2CxIZiCZZqAa+nCVPirx8JWnHhnky3yKnc41A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795918482; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=KikW2Gd8y/W4EynWvcJWgRQrN0S9iY9I8kgLWc7UYqs=; b=YLm9y8d7PV7L3a8X+JTUhUbzMF5vIH2SLTO+7HnYcU9zJWsUZtz4EvBiCJ8ZNvBpri60 C10/nd9zemLQu3g0pResNAYhY6NBnWdj365dc3ywH/iq4onVx9Ds1Ynqsd83TNg8Z2tCJ nesH6kS4fbu1couUAiNW9487vmeOYBDu8M9YXWvIrXpokXaHlttjEcxeNkMqHIpNnLxu2 clAZCbcwE534PQjPcTdkp7HIFtNT2GZ2b+V6YvWa6a2ILnBgYcuhvmTeX96ubdbr8iPjv mv+e1GP2K/jtSBaGeK4NqYNB02EUBI+fORF7omVfl355TnOEWRHnA6xVpvbnnjGT9/w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=amLtL95p; 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 2E977606A32D; Sun, 29 Nov 2026 02:14:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=amLtL95p X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795918481; b=ilk3MiboQ6Q5bshvX1anEIYJmDRH0RlZi2inOvihyCOJGAYP+IWx1J/D1oiUdwiCETno Dh64ysbrhcYY1Mptx8rfSaQOmNzeVbvxL4NG4o4/0qXKem+UJOLJkj+YVGWzs4wBsRXnP 2STEAblPG5L11cy+J6tGUYk7GeyorE2mR0hNBuc3DaDhC0TY0CVdi7/55ukvr6GJrjsAQ ReyuG+JLlV5qgcNcwKBnfIFypOXBBKGyCAYnSp5ewZdP59ZSGd2HBE8p7QTX2SKPyZGqM 7EK0vFsZlM0jXEsxj/eXrK/FH+ROaVsU/eGHLi2L8ucL+GVymHH6mPmIl2W9HSchXtQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795918481; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=KikW2Gd8y/W4EynWvcJWgRQrN0S9iY9I8kgLWc7UYqs=; b=w9PDAeAvqBrUh1Jl5ffmpnIvf/Pu0bqo8zKHyBse5aqEF1PDZP6A0HHETPEbZyQtHcY3 BWiu26gJ4CLyksfzpUUe+FiCx83U2x3Enz7z7MX0v7v5k3jz1Ek9c7BjSvWagqF18/uLY gUNYG8e3q2XBQUXJqaS8/aZlwvp2XtLFQJ5UpIzRQk1W4owAxgQ3iTyh8ZX06TDFvk0Z1 A/vncNI9CyCc/KffqDQyOFrm5mUHrn1ejGxmS37qeerhw78Xxa5zAvwGkWR5rbV14h1eD Mg+ylVJSlOOV5LHB0HkJeUlxkZtDpiq83QqL8xoBwMKiG4TPDNSWjRxQ9g+YlQoHyfA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=amLtL95p; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A860606A31C; Sun, 29 Nov 2026 02:14:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 323891F000C1; Sun, 29 Nov 2026 02:14:40 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795918480; bh=KikW2Gd8y/W4EynWvcJWgRQrN0S9iY9I8kgLWc7UYqs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=amLtL95phNim4MauxDV4zz9/EDaj/LvMoiev4JHZy4wvA0lP1A9kXAa4o1VJdBaW2 rJgZlD7J03wnnvNLlr+/9ryb6TbVzESl6hlsOXGzG4rs/+OBfnG9ypf/Hwzne9KMoq MFLQjTTo9dFOkKZOo8S2FsTnFOsE83N+VrBJoeZeHWPmmM2fjLiXa0F3yZNiP6jmuv 6c1R7thiCSpZvS4gR9Urzl9lnjkQxlMj/8dMeZw6W2tAQgK3JH2qvD04YAk+ps9WCo b5RbuxhyHfsGwypDb1/RSvVTgHjemAQaG0uSTuWqJpTt5TeKy3K7kYstY9lz6n+3vF Auqlk4TBOgPsQ== X-Cc: netdev@vger.kernel.org, ipsec@lists.linux.dev, steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, fw@strlen.de, linux-kernel@vger.kernel.org, cjubran@nvidia.com X-In-Reply-To: <20261125013412.1123866-2-jianbol@nvidia.com> X-sashiko-severity: Low 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-Received-Bytes: 11659