From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 323891F000C1; Sun, 29 Nov 2026 02:14:40 +0000 (UTC) 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== Subject: Re: [PATCH ipsec 1/4] xfrm: Give GC list nodes their own storage From: netdev-bot+sashiko@kernel.org To: jianbol@nvidia.com 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 Date: Sun, 29 Nov 2026 02:14:39 +0000 Message-ID: <179591847972.3135.16907973135135504288@kernel.org> In-Reply-To: <20261125013412.1123866-2-jianbol@nvidia.com> References: <20261125013412.1123866-2-jianbol@nvidia.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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