Article View: linux.kernel.netdev
Article #25257[PATCH 18/22] xfrm: Give GC list nodes their own storage
From: Steffen Klassert
Date: Tue, 01 Dec 2026 12:41
Date: Tue, 01 Dec 2026 12:41
73 lines
11907 bytes
11907 bytes
From: Jianbo Liu <jianbol@nvidia.com>
gclist currently shares storage with bydst, and dev_gclist
shares storage with bysrc.
This is unsafe for bydst and bysrc, which can be traversed under
RCU without holding xfrm_state_lock. __xfrm_state_delete() unlinks
these nodes with hlist_del_init_rcu(), so a reader that started before
the unlink may still be following their linkage after the state has
been removed from the hash table.
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.
Give gclist, bydst, and bysrc separate storage so their hash-list
linkage remains valid for outstanding RCU readers. Share dev_gclist
with byseq instead. byseq has no RCU readers, only
__xfrm_find_acq_byseq() under xfrm_state_lock, and the state is
unlinked from byseq before dev_gclist is used. Sharing keeps the
growth of struct xfrm_state at 16 bytes rather than 32.
Fixes: d737a5805581 ("xfrm: state: don't use lock anymore unless acquire operation is needed")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
include/net/xfrm.h | 10 ++++------
net/xfrm/xfrm_state.c | 1 +
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 5fbb73474e32..cd37aa69c9ac 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -189,16 +189,14 @@ enum xfrm_replay_mode {
/* Full description of state of transformer. */
struct xfrm_state {
possible_net_t xs_net;
- union {
- struct hlist_node gclist;
- struct hlist_node bydst;
- };
+ struct hlist_node bydst;
+ struct hlist_node bysrc;
+ struct hlist_node gclist;
union {
struct hlist_node dev_gclist;
- struct hlist_node bysrc;
+ struct hlist_node byseq;
};
struct hlist_node byspi;
- struct hlist_node byseq;
struct hlist_node state_cache;
struct hlist_node state_cache_input;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index eb984ed11888..9c101be250ee 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -751,6 +751,7 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
INIT_HLIST_NODE(&x->state_cache);
INIT_HLIST_NODE(&x->bydst);
INIT_HLIST_NODE(&x->bysrc);
+ INIT_HLIST_NODE(&x->gclist);
INIT_HLIST_NODE(&x->byspi);
INIT_HLIST_NODE(&x->byseq);
hrtimer_setup(&x->mtimer, xfrm_timer_handler, CLOCK_BOOTTIME,
--
2.53.0
Technical Details
Message-ID:
<20261201124252.1163254-19-steffen.klassert@secunet.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375045-linux-kernel-netdev=dewy.ruReferences:
<20261201124252.1163254-1-steffen.klassert@secunet.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375045-linux-kernel-netdev=dewy.ru From: steffen.klassert@secunet.com (Steffen Klassert) Newsgroups: linux.kernel.netdev Subject: [PATCH 18/22] xfrm: Give GC list nodes their own storage Date: Tue, 1 Dec 2026 13:41:44 +0100 Organization: Usenet Network Message-ID: <20261201124252.1163254-19-steffen.klassert@secunet.com> References: <20261201124252.1163254-1-steffen.klassert@secunet.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1712148"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5LHDgeZRy1QC0BskAjb1AprXV3Y= sha256:8wHp6hQZtszUY/8Jgxt2+xKc6U8GnrPGVBDNxKWrjlo= sha1:qCMqWuOBAsgpZzCgPnWq4Eq4fw4= sha256:GqKi5656ljUrAemIy2R5OOmmw4LaBOsU15qvHNxLiN8= 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 E0828117395; Tue, 1 Dec 2026 15:44:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=secunet.com 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 WvjQIn8i6Enk; Tue, 1 Dec 2026 15:44:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375045-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id EC0ED117383; Tue, 1 Dec 2026 15:44:43 +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 63C0A29A68; Tue, 1 Dec 2026 12:44:29 +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=1796129053; b=g5RO0O04NqS/LRwqBbs5no/TAMk9K4/Rc3J8gb3jkSgl5UPb3nj2YU/QfqFicIC0Ya6u mhmUyjzAsUhbrtvC71vNVoZPGMAOvmgRz+14r7n+/mf9FHMLYc7c3PuJCFj3umaulNhqi Gj4c4XaUB/ep1VGwgPfpsZIyd6GCbutH75v98kg9hu6//5A9D4e5YOQqlRyUTWowXUbqm hEFDgo1y9axeqLT8MERbbvE+xx75ScIIVOhumgQ7zeqUoz4wOPsiFvI0gBVl9IfPAcM8d pAYnGx8klqBrXqj91YJQfXLsREw/QFm3lBV/BxCRasZf2bnUIepTI60wqzXigNGtETA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129053; h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned: Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:From: To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy; bh=DWsFuFFZ1UU7v5EMncGc3Az6dAIJDhsrt9m7KeHBb1I=; b=m3tv2i9kMFvTiBT3SJUp1kxpdzJC3+cZTAU1lW/rtOwoGvAJuNdo5wPZYZdQ1TKdyyZd h3KsW/HRIoSSeja+KTuoFTO76VEQjz5wjFIeVWknOKaW0POIVRybqpztSz+giA3EVJccP IVsZt3tfOdMXK9gBgCXg94ATA2R2Xs9yFfI3VBBH1lQmLqS1Mz0dGI9C6e4IXUS2Rgt/s nFyxLCa69+YS+1Wh+qquXFS6bll+oryDzKQiSRzw3+6X+C4zplrWb/DKcT8Nsvz7RaM/h 9iprXAym64cf7trLS0y7WPpQLAOWbftEe03LRKfE04+e3jGKY1S9kDNsDvyrkZNMerg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=kE19E6Ej; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; 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 C63FE606A697; Tue, 1 Dec 2026 12:44:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=kE19E6Ej X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129053; b=Z2kMiAO+dsJzFhVYFwd10068YvQx8+K8He1UT878/4iBmHOErEDD79fdWvVg4iOpiDMz jdAVBF0Unn4E6FuOhs/ebZrB6Ejxki9lZFfHX6kYBBQxD0q5fQdIF/F0NSkm5VrSTyS7D lWiQumy/4YuTER6oymOTyzJMAeVfdV6YulIDoX2xDaIepyqlk6whApWQbp8GQXFSSJ4oi jbormAxZLXKmOFFULLfPmJFujiPRyHCKWm6Hf+QFd2jabOh+/+FG4EOq3bU03y/26hKdw QjFYXiYni0K+rNUHmjmQ6vvQqkPRE2GHBWc9XOr8bZ2GqZrQyJueM8RC/Yc9DwsN4EQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129053; h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter: DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy; bh=DWsFuFFZ1UU7v5EMncGc3Az6dAIJDhsrt9m7KeHBb1I=; b=tPdoVpRAozw806ckmhNZCuVqVnlPAMfuniQrSvBrY4YnHCj7t2OxZlN8YyIDE0/wbX6d 4NwtSxXWKTW8brzAz5WAyyGv+19FZG2QGlj0587h9aecOiWG1lHvrqzAJsdPyASbSUgRF f0gQ3j3kadYYt8CqEmb97umUmpghZquvT0FYM/CjbaIY06nyRECM/Opf7wBqhytAJJOKp Rm00WyYESU+ieQfHRfBalc6s6M4sLzmas9KG4H+EKQY59GHbVNTEqlRfQt9qykky5wIPp E+FX79lekDz8Wc1n4Plz9YTIfrJ80dcfWZI/fG1r6iQCV4es5uwBJZVtSa7Ul9Fk4Vg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=kE19E6Ej; arc=none smtp.remote-ip=62.96.220.36 X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54B5B606A68F for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 12:44:12 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 54B5B606A68F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com X-Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 25045207FB; Tue, 1 Dec 2026 13:44:11 +0100 (CET) X-Virus-Scanned: by secunet X-Received: from mx1.secunet.com ([127.0.0.1]) by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2s_NRkFYcWu4; Tue, 1 Dec 2026 13:44:10 +0100 (CET) X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.secunet.com (Postfix) with ESMTPS id 817AF20684; Tue, 1 Dec 2026 13:44:10 +0100 (CET) X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 817AF20684 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1796129050; bh=DWsFuFFZ1UU7v5EMncGc3Az6dAIJDhsrt9m7KeHBb1I=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=kE19E6EjpNMJ0rNHKI+XX54kE/FVO0fE0Id+XWIf/SAGjgKqqEzsL4lQl7lsrDkkP cGbILD8OWeaOZr4kg+YSD0AkETqvPVAxkoEfarLSIlNiIgo2f6gHAx5ohMzovnsn2I Lwp0UuObaDY8O3bkQ8Wmf1Z+O0opSCkGjwgSeamg3f2GepFkSJsAZu4LbeGT5V5F3U 7NlaRkXBCFcBeqSDaomnlkbqLxQUJT+tOLFeErQEfVIukqk9BjqEgnbZX1gao3PtK4 TThnxy+De6/6Bcamn6p7RZzWd4iBnoV5Kvp3i9EVmnOPk/5msnO6NuUj+WrtCxm6z8 tZauS5CK37GQQ== X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 1 Dec 2026 13:44:09 +0100 X-Received: (nullmailer pid 1165829 invoked by uid 1000); Tue, 01 Dec 2026 12:43:56 -0000 X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert <steffen.klassert@secunet.com>, <netdev@vger.kernel.org> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com> 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-ClientProxiedBy: EXCH-02.secunet.de (10.32.0.172) To EXCH-01.secunet.de (10.32.0.171)