Article View: linux.kernel.netdev
Article #25265[PATCH 04/22] xfrm: serialize SA activation with state deletion
From: Steffen Klassert
Date: Tue, 01 Dec 2026 12:41
Date: Tue, 01 Dec 2026 12:41
42 lines
10724 bytes
10724 bytes
From: Kyle Zeng <kylebot@openai.com>
xfrm_add_sa() publishes a newly constructed state and arms its lifetime
timer before marking it VALID. The final VOID-to-VALID test and store
are not serialized with state deletion. If hard expiry deletes the state
between the test and the store, the store resurrects the unlinked state.
An input lookup which found the state before it was removed can then add
it to the per-CPU cache after deletion has removed the cache entries.
Once the remaining references are dropped, the cache points to freed
memory.
Take x->lock around the conditional transition, with bottom halves
disabled as in xfrm_state_delete(). This preserves DEAD if expiry won
the race. The same protection covers UPDSA when it installs a replacement
for an ACQ state.
Fixes: cc01572e2fb0 ("xfrm: Add SA to hardware at the end of xfrm_state_construct()")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_user.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index a5fbe38839c4..f802899d3d13 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1088,8 +1088,10 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
goto out;
}
+ spin_lock_bh(&x->lock);
if (x->km.state == XFRM_STATE_VOID)
x->km.state = XFRM_STATE_VALID;
+ spin_unlock_bh(&x->lock);
c.seq = nlh->nlmsg_seq;
c.portid = nlh->nlmsg_pid;
--
2.53.0
Technical Details
Message-ID:
<20261201124252.1163254-5-steffen.klassert@secunet.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.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-375059-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!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.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-375059-linux-kernel-netdev=dewy.ru From: steffen.klassert@secunet.com (Steffen Klassert) Newsgroups: linux.kernel.netdev Subject: [PATCH 04/22] xfrm: serialize SA activation with state deletion Date: Tue, 1 Dec 2026 13:41:30 +0100 Organization: Usenet Network Message-ID: <20261201124252.1163254-5-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="1712701"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:FXdsfCbRHyV0yrrQJRpm7yY/NIs= sha256:k2z1zB/Yj+ThI+c52Ric8b0QJdQD8JCIlg/qpzBxwxo= sha1:NfcNIDgE11vQcKIMcfkRQ3WLTyI= sha256:YLYX++YItykfa5KSfvMazd14l7BLoCMeVlBkcsB/cBY= 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 4DD71117395; Tue, 1 Dec 2026 15:45:58 +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 ZLSVxZRi4kff; Tue, 1 Dec 2026 15:45:55 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375059-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 8531511737D; Tue, 1 Dec 2026 15:45: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 4083C28E54; Tue, 1 Dec 2026 12:45:39 +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=1796129135; b=4DWpSkFiB9Wqkvg/l5RYXEtL9KUmIb6ts0r9U68ncmMEo3IgNBll+89PYzGkb42SQkBQ uW34JUHa5UeaiSAnX33fXzaGhEQ9Lpquv+6mk39mBHN5G/9m9UpE4LRHL/LzwxtmjBbb/ UHBwb0LBQlylChkhfC9GevJ2Kul4RJBNsQaQlpXLuB4d+CeIRv+HWC8NKUfLilJONm4bD KbY5WWr7gjWw9ZYH/9rdo+lSRBhyYRsvl6olBRcN9L5nF4AdySr3yvfxLbnl6yFlePHTU 3VzgzLcxcbjewFUQyaJwa9QnQlvVtMJwi7870sJuVK5J7DTlTNBOoBjHwdqv3EMUFuA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129135; 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=VSio0lep0kL0eSw9izKOE9yaeGg+OMAPttGXZ9zi4oQ=; b=wydkwxtojyQLdfCiB6LKh2apxQ6ciXfaPTzpsh32ASl2hqoQVhxZ5cY4dwn+IDG1TDBH gKryOG8/bQgMFDmYPwlbC0eV0aXv9g631SZVQs5l67MMtD5JcZTNzCiOm+jGlYyq94dwo mgsoxVwNx4TpgrEhIVYmZg06LHHDIv789sP0BRzxNsoDkMpC78H3xTaRafpaasKLD6AUp WcanblHx0wednE1EbtNCnu+hxy5dp7g/KFHKVKa5shByh0sPmk+zfOb6oaU/wmnFQRlXQ Kp5A5sK3SLIDQUArrJ2ENjPVGCmETtAhCEiHNt6598dBhLU1k4INpZvfZdD1AfwBrGg== 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=BpgXtn+n; 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 6899760A260D; Tue, 1 Dec 2026 12:45:35 +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=BpgXtn+n 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=1796129134; b=xkmODYCkY5JQoRPhY/AY2JCZV4okTtTCVS5jWigtxZ3EKuODl22OVbIa7Jmdupkq+HNj SQOOdURJtlrc6tB1cnO56GJI7GKqqWzkI6Tc0I/i1v9bUnwnymj597avhuhAUKvUxAOnA 4cxAZxsGifm06rfDm8O6VaepUmd0rC7PN4LnXthMXCaoRGb9BkynTLDJRjrE8pLWlc1Ek N/E09W7o74WZUqnmml0D2u5kEys6uB8QCnOy/XKkhsi8TQSd0K4es483NWdFyahBUA9ps +GM9I6vWqp5dppIeqA+k04YpSHLpd0Tnf4xIuv1WGN5Vm3n6dcFNs+qr9c2o9SdX0lg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129134; 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=VSio0lep0kL0eSw9izKOE9yaeGg+OMAPttGXZ9zi4oQ=; b=QtDdgh1uuF0jq2VU+rKx4KEviQoM5K2PLriQOtCmKExdc+ku9c9kMlm1u3HAOJQPzFQe 9Ttqfj83YuwaHxUGqv2lYcTmk47uYnpdb1amA31t2xezQbccNLF0ureH6YS54UbC2RfBz vFDSOtUm0yh49hCKptkrwRY10WN/KOCAc7NAUPgnQGnHSHg5fkv40w5yJxSSNKYmdB3fa OU3KruIS5u1Pt8vcKNQmJ66jSKJ1FFawq56V7qHkV3auSWAKjqswrzQChLkPbBL6V25Ut b+gEVQ1CEgjO2RYCe4ERF0c6EPnpB9EpAkITYBGC0p7KqKequCl+/KTxn/3kB0R0ifw== 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=BpgXtn+n; 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 23084606A6A6 for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 12:45:24 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23084606A6A6 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 B779A205E5; Tue, 1 Dec 2026 13:45:23 +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 osHHHTBM5o0d; Tue, 1 Dec 2026 13:45:23 +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 1A8EF205E3; Tue, 1 Dec 2026 13:45:23 +0100 (CET) X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 1A8EF205E3 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1796129123; bh=VSio0lep0kL0eSw9izKOE9yaeGg+OMAPttGXZ9zi4oQ=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=BpgXtn+nZsGKE5bIssFkk2lSL/NpKQdITs6z6xKDa4pWD0qtsJanMZ4KS2KliIXQy eUSSCG7CXduB2fMLMbtTJ+NRtZh+J4z/wktiNxomtyK0jZpp4ghq9NbSWa88cFk0Kt WpuNams/N/CyiJIURtnNAWK8hg5nfgxWk1jwQ7bU9wwwxdyiisxEZKegUlgtJm8q6n 3T+mcgy+Vy1xDk+QgdD/0WFVZhAWcf3quXA6YjjQjLCAS1AHc/hu0fdi2LOQrh3s6y 4dd9OSyKFbQuZDcXN55p87JO3kf//o3W/IseL/Mo1HNqLd0bnG2p4f8HC5/0G3jTrc wC1hjG+hS61Ew== 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:45:22 +0100 X-Received: (nullmailer pid 1165764 invoked by uid 1000); Tue, 01 Dec 2026 12:43:55 -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-04.secunet.de (10.32.0.184) To EXCH-01.secunet.de (10.32.0.171) X-Received-Bytes: 10465