From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 36B942E62C3; Tue, 15 Jul 2025 13:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752586680; cv=none; b=I3gsijLqragGoeCQhvK8OHGSEJCePei0zddm/jUP0zCjXP7dhHSZeofZ6v/MlXR9adkNT9Xz0wKVuX480jeOD8iXSVPnU2xERp63nV1pL/Jw/AbKIDpWXw3hbbyJuRnvHyJ7VhHztAZ20cHv6B8JwHy55yPq4OsI7j5zv8FpwhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752586680; c=relaxed/simple; bh=3T0ghl6RRiT1/pHxjEwtnTHHZqfcc/sg5O7o4pwvKDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EdLYKfOonLs/NBE0w5S3QWc1Bmu2oA8RID71ykniCU4MLWm8S4NgQwXWcYcHR6KWJ462ZgvZHSdU6ce09bZYkowPQc4e0i5qALJejwIjjxkDlYXse3UNyi9CdoRhZXeQBpEe1mU2bWMpYBgrdL/veNTg2D9cBA7t7CC3DrL2WHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wk0qtef7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Wk0qtef7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58A76C4CEE3; Tue, 15 Jul 2025 13:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752586679; bh=3T0ghl6RRiT1/pHxjEwtnTHHZqfcc/sg5O7o4pwvKDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wk0qtef7G38Kpn1mt1fzproljb3/lzieX7IvFiQ7uzgZNsbDqp2ZaUYtH18IInAwS xFvl1CD3YuS7nJtLcc8L2SuGTbeKlCK+emtmMDJHOsjw0z2kgS+/1v0hWPC3hNfsyb neOJ3Gd8u9Jn+N0cQZfaQ4PZ6O9FJfDT+P92tpMk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniil Dulov , Johannes Berg , Sasha Levin Subject: [PATCH 5.4 134/148] wifi: zd1211rw: Fix potential NULL pointer dereference in zd_mac_tx_to_dev() Date: Tue, 15 Jul 2025 15:14:16 +0200 Message-ID: <20250715130805.653694443@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130800.293690950@linuxfoundation.org> References: <20250715130800.293690950@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniil Dulov [ Upstream commit 74b1ec9f5d627d2bdd5e5b6f3f81c23317657023 ] There is a potential NULL pointer dereference in zd_mac_tx_to_dev(). For example, the following is possible: T0 T1 zd_mac_tx_to_dev() /* len == skb_queue_len(q) */ while (len > ZD_MAC_MAX_ACK_WAITERS) { filter_ack() spin_lock_irqsave(&q->lock, flags); /* position == skb_queue_len(q) */ for (i=1; itype == NL80211_IFTYPE_AP) skb = __skb_dequeue(q); spin_unlock_irqrestore(&q->lock, flags); skb_dequeue() -> NULL Since there is a small gap between checking skb queue length and skb being unconditionally dequeued in zd_mac_tx_to_dev(), skb_dequeue() can return NULL. Then the pointer is passed to zd_mac_tx_status() where it is dereferenced. In order to avoid potential NULL pointer dereference due to situations like above, check if skb is not NULL before passing it to zd_mac_tx_status(). Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 459c51ad6e1f ("zd1211rw: port to mac80211") Signed-off-by: Daniil Dulov Link: https://patch.msgid.link/20250626114619.172631-1-d.dulov@aladdin.ru Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/zydas/zd1211rw/zd_mac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c index a9999d10ae81f..bff6e796fde0d 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c @@ -584,7 +584,11 @@ void zd_mac_tx_to_dev(struct sk_buff *skb, int error) skb_queue_tail(q, skb); while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS) { - zd_mac_tx_status(hw, skb_dequeue(q), + skb = skb_dequeue(q); + if (!skb) + break; + + zd_mac_tx_status(hw, skb, mac->ack_pending ? mac->ack_signal : 0, NULL); mac->ack_pending = 0; -- 2.39.5