🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15963

[PATCH net] ieee802154: hwsim: free PIB after hardware unregister

#15963
From: Yichong Chen
Date: Fri, 13 Nov 2026 13:41
50 lines
11551 bytes
From: Zhan Jun <zhanjun@uniontech.com>

hwsim_del() queued the current PIB for RCU freeing before calling
ieee802154_unregister_hw(). Unregistering the hardware closes its
interfaces and aborts an in-progress scan; scan cleanup calls
set_channel(), which replaces the same phy->pib and queues the old object
for RCU freeing again. KASAN then reports an invalid free in
hwsim_update_pib().

Unregister the hardware first, then atomically detach the final PIB under
pib_lock and queue only that current object for RCU freeing. This lets all
driver callbacks finish before the PIB is reclaimed and avoids freeing a
PIB that was already replaced during teardown.

Reported-by: syzbot+8a8482d4c33cc58babb4@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6af5f575.b350cda4.2b6a63.0000.GAE@google.com/T/
Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Jun <zhanjun@uniontech.com>
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
 drivers/net/ieee802154/mac802154_hwsim.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index a9bd1555d2dc..a65ae2afb789 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -1008,12 +1008,16 @@ static void hwsim_del(struct hwsim_phy *phy)
 		list_del_rcu(&e->list);
 		hwsim_free_edge(e);
 	}
-	pib = rcu_dereference(phy->pib);
 	rcu_read_unlock();
 
+	ieee802154_unregister_hw(phy->hw);
+
+	spin_lock_bh(&phy->pib_lock);
+	pib = rcu_replace_pointer(phy->pib, NULL,
+				  lockdep_is_held(&phy->pib_lock));
+	spin_unlock_bh(&phy->pib_lock);
 	kfree_rcu(pib, rcu);
 
-	ieee802154_unregister_hw(phy->hw);
 	ieee802154_free_hw(phy->hw);
 }
 
-- 
2.51.0
Technical Details
Message-ID: <0D7C088B45E7283A+20261113134141.2626113-1-chenyichong@uniontech.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362676-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362676-linux-kernel-netdev=dewy.ru
From: chenyichong@uniontech.com (Yichong Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ieee802154: hwsim: free PIB after hardware unregister
Date: Fri, 13 Nov 2026 21:41:41 +0800
Organization: Usenet Network
Message-ID: <0D7C088B45E7283A+20261113134141.2626113-1-chenyichong@uniontech.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1433441"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uLyoIOW0TL8JNnqOv4zBdHeNV/M= sha256:sHPGnR6/ob1koW8BTRzDj9Pup2ihknLFTsrIv7NACc8=
	sha1:SzylE4dAdn5ki1bh1iINc9gRLxg= sha256:Dwcw9ui7+i0kvOWeFR2UpO9QB/zlfU39lMkUDieortw=
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 3BD95116022; Fri, 13 Nov 2026 23:40:14 +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 (1024-bit key)
	header.d=uniontech.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 NXNQLF4EwtXo;
	Fri, 13 Nov 2026 23:40:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-362676-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniontech.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 034FBC99D6; Fri, 13 Nov 2026 23:40:01 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id DAD622C20F6; Fri, 13 Nov 2026 13:43:17 +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=1794577393;
	b=GqZ6HD9qYdK8ylSuq/FJkiaFjyAhPJXk1LB/qbn9Gzfvd6PSq3+95Cgv+1GrgEFdquUo
	 cqe5ZcYAP2Z7wIFSJOLRB9XX09fOMqOJK/y3wjQZS8KgadX4NNFuf+Lfk5wgXQg38eTkf
	 N8IQBltSPYbl5wZSD7ipuqTQLUF7KklNjJCWPY00SrtP7LEe0iiHlwyI6E2DACjVdRgzc
	 FLxjOAxWg8k9GuXDrg5keC4e5BZ8+O68Hp2NmrpzcXEDNzI5UUriQL8w+3WDcIq4cYMt7
	 eC9xx5vHzlvNCg+87eTw0qjjkARfrW+dNSZ3nCZpW30Sy5TCtu4ByMjL8X9uf7L1ApQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794577393;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-QQ-mid:
	 X-QQ-Originating-IP:Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:
	 EX-QQ-RecipientCnt:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=3kcrlVRBobTRT8jOtREfiBLM6vTtQc7X6ndLPnK4qOc=;
	b=K/tcoTj/mqkXZNYnG0AbKg7eh9D0GnNrfWuiGun1uQPx2qks7OY5txhyIZ3u4cScT5He
	 /1OAC8SO8aHyauuWIa/qpY9N7f74SloD8HnAe3Rtb14/LQmYjLpUgdbz/FIKdlVDDRzci
	 o5VzWovq6oOooar47pq3Db8U0G3UJCqZbgVNTZUZcRAC89O8j8MYxOhla/ZyF8vfaDWcH
	 q+yW7eZLa9mntzVFWsRqOpZinqsX17hlkPkeW6bwQmgrAa8WXCHa+ns5QC5mhE7e88SN0
	 Y5VGGctotyMaIbjNTBgV3GDnlb4Ol3m6CY/l/UK3Z9dGTBdMrOOaEEY6QBuVoOK3/Mw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=cKkX2C9T;
	dmarc=pass header.from=uniontech.com;
	spf=pass smtp.mailfrom=uniontech.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 63F2F606A880;
	Fri, 13 Nov 2026 13:43:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=cKkX2C9T
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.204.34.130
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794577392;
	b=4eLyepQf4juKM/NLyYLZu+bIHynEbHhdbQ2qAw8XRVcUwZBMZ96fi/Cc50TbFU/gwkxB
	 9IVsNxRDNznGBSqGMK9ZQWsb8Q3ZlZdcpILM8Kre4n+lQBkXNpZRC+ZSlRu1xB2rpapLr
	 FJWsoHBogZsBxoczeQSSF37T7Jng29EiGCx/86WfW823I1pwcJUu6oZf/mqgnF1HpHIvD
	 8Y8pEdFxRaKZ+xX40+cHzQZfXqQtGbVbJjhJPtt9N+wmW22OsXGiNA8K7rdVCYgaCDMy8
	 qMLqQVEUCvCTnGPPhUL/KVpqZ+wTk32EIi6phrxfQpW8RsULvXPJpDsmZsSJ4M1qW3Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794577392;
	h=DMARC-Filter:DKIM-Signature:X-QQ-mid:X-QQ-Originating-IP:Received:
	 X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=3kcrlVRBobTRT8jOtREfiBLM6vTtQc7X6ndLPnK4qOc=;
	b=aaecWaCZiiuvsGMjvGcGY8Ejgyxcj7BjzH50sZRgXzyHt3s5zSIYUHACyn/Ew/JJp8yL
	 5JvI3vWbmyKZCWPs1wekiTfDcNKqbW4SLbwDbeYaW1VGuC6oitik9h4W7FcviUZCNMU6l
	 OMgU2aK5pcvvlanuoLXDZPFIjKinaImIaHASL3UqXmvkc+0bxQKrJwKbxnhwD4bKwgIFH
	 UwCtCG2c52r5/QYRjlCu3OfCPJdxEOAaSf0a3aHLFzvQAeBqa2uW9zjWlzwZg4DvqDuBZ
	 pnmvSPM8SmMLLvNOHKnHi/5WG1ohLzkwdT4FwYOeaeryQLGcFhtrvdGuWoLOrYdmwIw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=uniontech.com;
	spf=pass smtp.mailfrom=uniontech.com;
	dkim=pass header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=cKkX2C9T;
	arc=none smtp.remote-ip=54.204.34.130
X-Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130])
	(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 69324606A327;
	Fri, 13 Nov 2026 13:43:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 69324606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com;
	s=onoh2408; t=1794577330;
	bh=3kcrlVRBobTRT8jOtREfiBLM6vTtQc7X6ndLPnK4qOc=;
	h=From:To:Subject:Date:Message-ID:MIME-Version;
	b=cKkX2C9TU/v7CMDu8ugevsUTc5a31S7buh2ror1VZhNiorOX6FXSVjxpppf7JpIOI
	 grypYAyhUtU72O4aTG+Qe2pGBRWf8GnC3TKYnMe7+QWAWcHXZp5rE9Kox9jMBi6UBD
	 T7FwdYUsE4487kmxajUaoXmD2tJ4bBMkjvbMoxiw=
X-QQ-mid: zesmtpgz8t1794577305t88a9c797
X-QQ-Originating-IP: UpGU27M314SgLzhWg8rwr6TRitp95Zs5/+Vkkk4Vmrk=
X-Received: from uniontech.com ( [113.57.152.160])
	by bizesmtp.qq.com (ESMTP) with 
	id ; Fri, 13 Nov 2026 21:41:43 +0800 (CST)
X-QQ-SSF: 0000000000000000000000000000000
X-QQ-GoodBg: 1
X-BIZMAIL-ID: 2692691757360946475
X-EX-QQ-RecipientCnt: 10
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Zhan Jun <zhanjun@uniontech.com>,
	syzbot+8a8482d4c33cc58babb4@syzkaller.appspotmail.com,
	stable@vger.kernel.org,
	Yichong Chen <chenyichong@uniontech.com>
X-Mailer: git-send-email 2.51.0
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-QQ-SENDSIZE: 520
X-Feedback-ID: zesmtpgz:uniontech.com:qybglogicsvrgz:qybglogicsvrgz3a-0
X-QQ-XMAILINFO: OE2B1K8X9uN6TKRJknmgrzQ8Ba+/H4Q/PDI3pM1HiENumoaa+39xeTTP
	Tb3HtFJN/ArQZA0ll4i+R4WEyv+c6UCgukuAk8Df64MNbytdWPzGcQUPvBwDpNTJbt60dcU
	III9jEPFMPRX8i4v12nzJVqD45Jm6Orcl/xkko1a7n4LgMW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