๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25800

Re: [PATCH 18/22] xfrm: Give GC list nodes their own storage

#25800
From: netdev-bot+sashiko
Date: Wed, 02 Dec 2026 13:12
80 lines
10868 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 Fixes: tag is incomplete, and the description of the bysrc
  half is imprecise.

--

xfrm: Give GC list nodes their own storage

This patch takes gclist out of its union with bydst. It also moves
dev_gclist out of its union with bysrc and into a union with byseq. This
keeps the bydst and bysrc hash linkage intact for RCU readers that are
still walking a state after it has been unlinked.

The code change appears to fix both overlays. The questions below are
only about the commit message.

> The same issue applies to dev_gclist and bysrc.

[Severity: Low]
Is the bysrc case really the same issue as the gclist case?

The gclist overwrite only happens when the last reference is dropped in
__xfrm_state_destroy(). xfrm_state_gc_task() then runs synchronize_rcu()
before freeing.

For offloaded states, dev_gclist is written right after bysrc is
unlinked. It does not wait for the last reference:

__xfrm_state_delete()
    hlist_del_init_rcu(&x->bysrc);
    ...
    spin_unlock(&net->xfrm.xfrm_state_lock);
    xfrm_dev_state_delete(x)
        hlist_add_head(&x->dev_gclist, &xfrm_state_dev_gc_list);

That overwrites bysrc.next while a reader in
__xfrm_state_lookup_byaddr() may still be sitting on x:

    hlist_for_each_entry_rcu(x, state_ptrs->bysrc + h, bysrc) {

After that, xfrm_dev_state_flush() can call xfrm_dev_state_free(). That
function does hlist_del(&x->dev_gclist), which sets next to LIST_POISON1
without a grace period. A concurrent bysrc reader could then dereference
the poison pointer.

Could the commit message describe the bysrc case separately?

> Fixes: d737a5805581 ("xfrm: state: don't use lock anymore unless acquire operation is needed")

Does this tag cover the bysrc half of the fix? d737a5805581 only made
xfrm_state_find() walk bydst under rcu_read_lock(), so it matches the
gclist/bydst overlay.

The dev_gclist/bysrc union came from 07b87f9eea0c ("xfrm: Fix unregister
netdevice hang on hardware offload."). When that commit landed, every
bysrc reader held xfrm_state_lock, so the overlay was safe.

The overlay became unsafe with 2e460eefbd4469 ("xfrm: state: make
xfrm_state_lookup_byaddr lockless"). That commit replaced
spin_lock_bh(&net->xfrm.xfrm_state_lock) with rcu_read_lock() in
xfrm_state_lookup_byaddr(). This turned __xfrm_state_lookup_byaddr() into
a lockless reader of bysrc while dev_gclist still shared its storage.

Should the patch also carry the following tag, possibly together with
07b87f9eea0c?

Fixes: 2e460eefbd4469 ("xfrm: state: make xfrm_state_lookup_byaddr lockless")

Backporting to trees without 07b87f9eea0c will hit a conflict in the
xfrm.h hunk. The current message doesn't say that only the gclist/bydst
split applies to those trees.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201124252.1163254-2-steffen.klassert%40secunet.com
Technical Details
Message-ID: <179621715135.3146.4147128045971415279@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375800-linux-kernel-netdev=dewy.ru
References: <20261201124252.1163254-19-steffen.klassert@secunet.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375800-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 18/22] xfrm: Give GC list nodes their own storage
Date: Wed, 02 Dec 2026 13:12:31 +0000
Organization: Usenet Network
Message-ID: <179621715135.3146.4147128045971415279@kernel.org>
References: <20261201124252.1163254-19-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1977086"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BMVTXItPiNbn84nCcnAn5SKvqgI= sha256:JogYC+DjuVLHVZ/VUnOb+AkUmkow4qN4vQJQwlqwKrQ=
	sha1:AJl16Osnwq41VW5UjHuE9XvsQ3Q= sha256:iHsQcJ/7z9U0LsSlf1dAXVi+4kOlxu+gq0aP6QVL1Rk=
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 F0D01117649; Wed,  2 Dec 2026 16:12:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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, URIBL_BLOCKED=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 Jc3QV9QwhAyt;
	Wed,  2 Dec 2026 16:12:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375800-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id AE249117647; Wed,  2 Dec 2026 16:12:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C48F12DEB4; Wed,  2 Dec 2026 13:12:33 +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=1796217153;
	b=k8HQGVhyDPc29XFqfZH8AC9zy423PHZZboM6lpX2QZRmPhqwsou5VTacvprgQkjriLLV
	 KA7LuvRQMgT0mm/Enkf5NkOYibdmjZLcOBrEhX27v49+NyLjDWJo3w1qPDG9To0XILby5
	 DIhe7ML7Xx1aNXJtXrC37iDgRZ4ODxpPYFZazzbpKS0ESw1z8g9xITi+2kZz/i66rqGau
	 lYDk+EbTGpR7QbXKUJj2EeX6BfXjChIFUGEeoPvCvWGhyVY9ptt4TEeLOqLENtcVGH0HS
	 pEL/OwgVxU553p+Ve0ccCevhJngWZVJ7OMd5AAAQEZoM1zDVSZ7MytAeBz54nALq/9A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796217153;
	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=S+pNwhZiHRnigxWHceEKRHFiAXj98yowtQ66Dc9vnL0=;
	b=YlJ4rTiy9dly5u8tX3D7FSACJK4hGKd8drSEargONyR2rtWICFrIToC3qQR7Ews9VyxA
	 Xqbcdkf7L4l5PUbLD3rwcTLaadh6wbNb9NOtDulowZCqXk9QN3OVK39gr2h5YAqSoCBx9
	 YiMrouTiQ1P+SVn5KVaH3KwGSPPzbBJtq/8gnqFADvvw7OeAoJK4o9S7bFKIQW/sq9IZ4
	 KP7avNUAqGY1NRIEKtudr4Z3Ip9NaeBdqt4jl0MmtyedofVgD85h+XYnMvp6TpCndMiCt
	 V/52leO/3FqeiUI64TK/H1hyWZ/a8kBTSd8JbbIVZGf9Cqiq4QogzYNob7D46wSqlWw==
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=gPqY9O4a;
	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 6A08A606A325;
	Wed,  2 Dec 2026 13:12:33 +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=gPqY9O4a
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=1796217152;
	b=xAFjrKGWFiiW03mXT1SSPFTQrB2aKaBkBXQrj8aMN480+8aLjk74/jwQ6nM/0JvjFjRT
	 8RclM8YgSBTL1yyNzG0RQzynMeIJUBNgu5PiMn8lszpuhtqXDj9hnd5DyVMCm5QQw7z2+
	 Udx8F45516H4Y+NJJmA46ViBhP3cUsI6up2uiWV6Bg4i+C0Q0iwuehPIfjzf8/GoKBM79
	 K2uW8/u6PhjbdeWpoJHhjAxhg1Bi+ybpmdJPmuYguLUgYjEiL4Puct+FNVeJgTtmZGMzK
	 jAOSayVt2SRH4xWhBRiqtTiIdUTvu4B0odKDMwYqSVgK/P3w4Fzfe58pyWRgubMdpKA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796217152;
	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=S+pNwhZiHRnigxWHceEKRHFiAXj98yowtQ66Dc9vnL0=;
	b=lkb6VUMEt2pcDOqLHllCSM0upcu0Wnpt0/IhtaA8zGN0VgMPxTb9qdpxsj0Ta8mIylu3
	 FWOk1C/mJOBrHTYqAYJNLX0Cm0P0307iqZVBcwRHXQnsOElkrGEnadAzgllOTgeSoNxd7
	 EDB3w8FtYHC33pnUcgvyOoO8LKP6nqtRafFNsDLU6dspvcRQznIOFFJRVuW0nACu7w0t7
	 Mwy2+BFBwxK/sLPaLduKID32GnraP/EkuGEPjZl9vIkAOlEPPedN4kSjRsgDtw5rnjZvD
	 Dq5rLF9YI9DeSRvZ+0CooM9RLpDARCmmYaxZDO7x9AT5YDXUfDpKlnmc8EvrskYvLkQ==
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=gPqY9O4a;
	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 8BDFF606A31A
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 13:12:32 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFE4B1F0089B;
	Wed,  2 Dec 2026 13:12:31 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796217152;
	bh=S+pNwhZiHRnigxWHceEKRHFiAXj98yowtQ66Dc9vnL0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=gPqY9O4afqSq6NgyfgPrz9dMtfFZPhpV/M/rIpS0rRng8PaIct7NZgA2y4oB1uBc1
	 h2pGnoe+cOrm11ypLq8IqjvSZ6kd/qace9wL6bnW9Kw0aegsmVDppNSgjZzj1Zq1r+
	 E3BSh6dMBYwJiprA1macZAzyRIEbXOxWMaagtN7AGcK18uc2l0bDceZqA599LiavWE
	 TdMhxxL2i73GD3lZCIgyuogznFVywTTDmdczdln480dBhfZ0eHN0pkTmv8msoFdVn2
	 w9CfRJpLHQQBL0vw/FyL5ocTKstYzVYAR6dptvJTLdKchJpPu0Xr6kZiEBDgwj9myH
	 uJp0tzoh6Tulw==
X-Cc: davem@davemloft.net, kuba@kernel.org, herbert@gondor.apana.org.au,
 netdev@vger.kernel.org
X-In-Reply-To: <20261201124252.1163254-19-steffen.klassert@secunet.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