From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387711; b=RqLjCeEDjoH2J1ZLmWLNMg/9CGGSZqls2e21F5hrBuQ/h578BWEcw+oRv4zsGbfoFDzY x29hkNQ3X8BioLnhCxmoh/wU/U07wBHyBNnkJ0kkDPggiVN4m6fg4cLAVfvGetX9F7/xw 19FE/265rNOD4+/mLnBqehEwM0u/k/PyJrq0QykOFdNOI/hs94Xinl1AfZNWe5VZJhFZz S5GzfHDraaFIcrsab5rTUDcJ4OEYGnPO7l8cLeiseDsJgR8OWDNTvOUhZLgmvfZeLvJsZ C032gBZMAUXn68iNzs016WMzCN2HInt7ZlmovSCmsa/Uhnt0xxSo1makY8pBqWuGeSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387711; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=xY/zOiN3QZdCytD5igsPMTS95XPx6Y4Cze7XakXAY6Y=; b=4w6asaTl+0+2G/g8WPlLkOut24PoCaLriRyRYtOUKK9NQ/4xnMvbCCkK93nCl598YIzK mL4/8KCU3qul5vNU4yjElfn1PRTAqEw1GLKQb3cp4l2QUNXPf3rZd4KwcZaAytp1uZCfu XQ8OpD2CmaMSqplK64pqnZx9rpivIVaQBfOgxOfjQggRdG3EgAzHzhG9Dv/RJiSiVLip5 KgvrSbPGqM6FVtwkDsEn+rL7yD2lNKnOLhshBnZDBCfBiUgos+4hJ1j62zt/W8L3TmwKs 44YA2JiZB+atZ1galhK/9bYmec0y04+z1RrHUox3CIsr4L8afuyCG1T7+xK25/JD8QA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SqkfpJGL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8257606A322; Fri, 4 Dec 2026 12:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=SqkfpJGL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 228C41F000C2; Fri, 4 Dec 2026 12:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387711; bh=xY/zOiN3QZdCytD5igsPMTS95XPx6Y4Cze7XakXAY6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SqkfpJGLWspSGCcjbIh7Tl8jgSVw/EsNtmrgbU0ZFHC0YdvfK1R43cTzvUup7PlGh /kELYVrllHYV+PKL5ZFvOs9EeuFgEIgPgnCGYLyRFIBAchKtVor8teoJz9gKmH7D+p Cv2WCETrGMAY0LEYHOvkHdE4aGL1K1Vb3GXil2yw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ryan Leung , Felix Fietkau , Sasha Levin Subject: [PATCH 6.1 0357/1059] wifi: mt76: fix wcid->pktid corruption in mt76_wcid_cleanup() Date: Fri, 4 Dec 2026 18:58:08 +0900 Message-ID: <20261204100653.517049713@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryan Leung [ Upstream commit 158c1145fe7ddd82914011a00de7cc3262616b16 ] mt76_wcid_cleanup() releases dev->status_lock before calling idr_destroy(&wcid->pktid) to tear down the pktid idr. Meanwhile, mt76_tx_status_skb_add() from tx.c can concurrently insert into that same idr during tx completion handling: spin_lock_bh(&dev->status_lock); pid = idr_alloc(&wcid->pktid, skb, MT_PACKET_ID_FIRST, MT_PACKET_ID_MASK, GFP_ATOMIC); Since idr_destroy() runs outside the lock, it can execute concurrently with idr_alloc() on the same idr, corrupting its internal data structures. Because idr nodes are freed through the generic slab allocator, this corruption can resurface later as an unrelated-looking crash anywhere in the kernel that happens to reuse the same freed memory. Fix this by calling idr_destroy() before releasing dev->status_lock, so that the table teardown and any concurrent insertion are mutually exclusive. Closes: https://github.com/openwrt/openwrt/issues/24594 Fixes: bd1e3e7b693c ("mt76: introduce packet_id idr") Signed-off-by: Ryan Leung Link: https://patch.msgid.link/20260820-mt76-pktid-idr-race-v1-1-451f176a6495@protonmail.com Signed-off-by: Felix Fietkau [ sashal: Moved idr_destroy(&wcid->pktid) inside the status lock in mt76_packet_id_flush() in mt76.h, since the upstream function mt76_wcid_cleanup() doesn't exist here. ] Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt76.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 6bae36e4f25a7..e6a4bea9f2e3c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1452,9 +1452,8 @@ mt76_packet_id_flush(struct mt76_dev *dev, struct mt76_wcid *wcid) mt76_tx_status_lock(dev, &list); mt76_tx_status_skb_get(dev, wcid, -1, &list); - mt76_tx_status_unlock(dev, &list); - idr_destroy(&wcid->pktid); + mt76_tx_status_unlock(dev, &list); } #endif -- 2.53.0