From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38F8E4C225B for ; Wed, 16 Sep 2026 16:07:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789574826; cv=none; b=RmodqaD2TchiYI955B9JNR6Q8C+ToMd9BKnXj6w9E85+fBoi7Pk3ukjGJhC+HcF3lnG4Mpr0U/7PwompYUH4cIfWqz74jg40T1h3skNucK0Hq0KhPLaVNy1O2VxD8gqZiR36zKwNaoGHo1E/8cpwN7uj3sn+GngAGBo6PnFAi4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789574826; c=relaxed/simple; bh=wQnoTVwmRszLRT6BarxLTnozueSUyOEtUr/nnLQCxkY=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=SDSU/mi5e4AnP3+aleVam8jJsZVoAQ37j8u5M7B9YJWPuLhrT4SG7RZ1fFMSt0mYwV+IX2vgEf+tnGzbCljoyZS23a0C3UpV0u4ZwswVKRHNdlXA5B5iM8alA43iq6rDca+Hl56DcGjSBls2DDewg4r7jEu7S+vJA8ZrPoVuojc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Zh2oeerR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Zh2oeerR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F07E1F000FF; Wed, 16 Sep 2026 16:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789574823; bh=ZpDLqYB5XzU+7TlDaaG/7CyY0Cp2BxRNUz/e95Sa3wQ=; h=Subject:To:Cc:From:Date; b=Zh2oeerRfYYK8jQz67OgqpYyMCBYPJtApazTLN2y+ipnezib70NVo2AuGAjcb4m5s MAM7WunhAGikQp8wMLWfbRCmEHFSuMHS2APknGdm6k21mEwGZU/fc3jYrEZtoSCsJJ 9XZjLissilU4nYcVIr2c2IS2LcDYQWbHFrkcTht4= Subject: FAILED: patch "[PATCH] ieee802154: hwsim: serialize pib updates to fix double-free" failed to apply to 5.10-stable tree To: devnexen@gmail.com,stefan@datenfreihafen.org Cc: From: Date: Wed, 16 Sep 2026 16:44:59 +0100 Message-ID: <2026091659-marry-gender-6432@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 979d5b8de8ed4e1f997aef12da5694b99be7b871 # git commit -s git send-email --to '' --in-reply-to '2026091659-marry-gender-6432@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 979d5b8de8ed4e1f997aef12da5694b99be7b871 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 9 Jul 2026 23:18:58 +0100 Subject: [PATCH] ieee802154: hwsim: serialize pib updates to fix double-free hwsim_update_pib() does an unserialized read-swap-free of phy->pib: pib_old = rtnl_dereference(phy->pib); ... rcu_assign_pointer(phy->pib, pib); kfree_rcu(pib_old, rcu); It assumes the RTNL is held, but ->set_channel is not always called under it: the mac802154 scan worker changes channels via drv_set_channel() without the RTNL. Such an update can race an RTNL-held one on the same phy; both read the same pib_old and both kfree_rcu() it, double-freeing the object. With SLUB percpu sheaves batching kfree_rcu(), this surfaces as a KASAN invalid-free in rcu_free_sheaf(). struct hwsim_phy has no lock for pib. Add one and make the swap atomic with rcu_replace_pointer() under it, dropping the misleading rtnl_dereference(). Reported-by: syzbot+60332fd095f8bb2946ad@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=60332fd095f8bb2946ad Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: David Carlier Cc: stable@vger.kernel.org Link: https://lore.kernel.org/20260709221858.158063-1-devnexen@gmail.com Signed-off-by: Stefan Schmidt diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index 6daa0f198b9f..a9bd1555d2dc 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -72,6 +72,8 @@ struct hwsim_phy { struct ieee802154_hw *hw; u32 idx; + /* Serializes phy->pib_updates. */ + spinlock_t pib_lock; struct hwsim_pib __rcu *pib; bool suspended; @@ -102,8 +104,6 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel, if (!pib) return -ENOMEM; - pib_old = rtnl_dereference(phy->pib); - pib->page = page; pib->channel = channel; pib->filt.short_addr = filt->short_addr; @@ -112,7 +112,10 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel, pib->filt.pan_coord = filt->pan_coord; pib->filt_level = filt_level; - rcu_assign_pointer(phy->pib, pib); + spin_lock_bh(&phy->pib_lock); + pib_old = rcu_replace_pointer(phy->pib, pib, + lockdep_is_held(&phy->pib_lock)); + spin_unlock_bh(&phy->pib_lock); kfree_rcu(pib_old, rcu); return 0; } @@ -952,6 +955,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev, goto err_pib; } + spin_lock_init(&phy->pib_lock); pib->channel = 13; pib->filt.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST); pib->filt.pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);