From: Yousef Alhouseen <alho…@gmail.com>
hwsim_del() queues the currently published PIB for RCU freeing before
unregistering the hardware. The unregister path can still invoke driver
callbacks, including set_promiscuous_mode(), after that grace period has
started. Depending on timing, a callback can consequently dereference the
freed PIB or queue the same object for RCU freeing twice.
Unregister the hardware first, then fetch and free the final PIB. This also
handles a PIB replacement performed by a callback during unregister.
Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
Reported-by: syzb…@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4707bb8a43a42fca2b97
Reported-by: syzb…@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8a8482d4c33cc58babb4
Cc: stab…@vger.kernel.org
Signed-off-by: Yousef Alhouseen <alho…@gmail.com>
Signed-off-by: Roshan Kumar <rosh…@gmail.com>
---
Changes in v2:
- move the final PIB lookup and free after ieee802154_unregister_hw()
- use rcu_access_pointer(), as requested by Miquel
- correct the Fixes tag to f25da51fdc38
- rebase on wpan.git commit bc10f5da3e77
- preserve Yousef's authorship and existing sign-off while forwarding
- complete 200 KASAN teardown race rounds after both patches, with no
sanitizer findings
- complete targeted W=1 allmodconfig and allyesconfig builds, with no hwsim
diagnostics
v1:
https://lore.kernel.org/r/2026…@gmail.com/
drivers/net/ieee802154/mac802154_hwsim.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index a9bd1555d2dc..fc2b7415afec 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -1008,12 +1008,11 @@ 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();
- kfree_rcu(pib, rcu);
-
ieee802154_unregister_hw(phy->hw);
+ pib = rcu_access_pointer(phy->pib);
+ kfree_rcu(pib, rcu);
ieee802154_free_hw(phy->hw);
}
[PATCH net v2 1/2] ieee802154: hwsim: free PIB after unregistering hardware
- From
- rosh…@gmail.com (Roshan Kumar)
- Organization
- Usenet Network
- Message-ID
- <2026…@gmail.com>
- Date
- Newsgroups
- linux.kernel.netdev