Re: [PATCH net] ieee802154: hwsim: free PIB after hardware unregister
From: Miquel Raynal
Date: Tue Nov 17 2026 - 05:17:52 EST
On 13/11/2026 at 21:41:41 +08, Yichong Chen <chenyichong@xxxxxxxxxxxxx> wrote:
> From: Zhan Jun <zhanjun@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://lore.kernel.org/all/6af5f575.b350cda4.2b6a63.0000.GAE@xxxxxxxxxx/T/
> Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Zhan Jun <zhanjun@xxxxxxxxxxxxx>
> Signed-off-by: Yichong Chen <chenyichong@xxxxxxxxxxxxx>
This is a duplicate of:
https://lore.kernel.org/all/20260627235805.17310-1-alhouseenyousef@xxxxxxxxx/
https://lore.kernel.org/all/20260709221858.158063-1-devnexen@xxxxxxxxx/
https://lore.kernel.org/all/20260919223434.3882824-1-benquike@xxxxxxxxx/
Miquèl