Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Roshan Kumar <roshaen09@gmail.com>
To: linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Yousef Alhouseen <alhouseenyousef@gmail.com>,
	syzbot+4707bb8a43a42fca2b97@syzkaller.appspotmail.com,
	syzbot+8a8482d4c33cc58babb4@syzkaller.appspotmail.com
Subject: [PATCH net v2 1/2] ieee802154: hwsim: free PIB after unregistering hardware
Date: Sun,  6 Dec 2026 13:30:35 +0530	[thread overview]
Message-ID: <20261206080036.2769662-2-roshaen09@gmail.com> (raw)
In-Reply-To: <20261206080036.2769662-1-roshaen09@gmail.com>

From: Yousef Alhouseen <alhouseenyousef@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: syzbot+4707bb8a43a42fca2b97@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4707bb8a43a42fca2b97
Reported-by: syzbot+8a8482d4c33cc58babb4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8a8482d4c33cc58babb4
Cc: stable@vger.kernel.org
Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
Signed-off-by: Roshan Kumar <roshaen09@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/20260627235805.17310-1-alhouseenyousef@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);
 }
 

  reply	other threads:[~2026-12-06  8:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  8:00 [PATCH net v2 0/2] ieee802154: hwsim: fix PIB lifetime during teardown and error unwind Roshan Kumar
2026-12-06  8:00 ` Roshan Kumar [this message]
2026-12-06  8:00 ` [PATCH net v2 2/2] ieee802154: hwsim: free the current PIB on registration failure Roshan Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206080036.2769662-2-roshaen09@gmail.com \
    --to=roshaen09@gmail.com \
    --cc=alex.aring@gmail.com \
    --cc=alhouseenyousef@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stefan@datenfreihafen.org \
    --cc=syzbot+4707bb8a43a42fca2b97@syzkaller.appspotmail.com \
    --cc=syzbot+8a8482d4c33cc58babb4@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox