[ldv-project] Patch "ath9k_htc: fix NULL pointer dereference at ath9k_htc_rxep()" has been added to the 5.10-stable tree

gregkh at linuxfoundation.org gregkh at linuxfoundation.org
Wed Aug 3 14:56:54 MSK 2022


This is a note to let you know that I've just added the patch titled

    ath9k_htc: fix NULL pointer dereference at ath9k_htc_rxep()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ath9k_htc-fix-null-pointer-dereference-at-ath9k_htc_rxep.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.


>From foo at baz Wed Aug  3 01:49:25 PM CEST 2022
From: Fedor Pchelkin <pchelkin at ispras.ru>
Date: Mon,  1 Aug 2022 18:59:07 +0300
Subject: ath9k_htc: fix NULL pointer dereference at ath9k_htc_rxep()
To: stable at vger.kernel.org, Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>, Kalle Valo <quic_kvalo at quicinc.com>, Alexey Khoroshilov <khoroshilov at ispras.ru>, ldv-project at linuxtesting.org, syzbot <syzbot+4d2d56175b934b9a7bf9 at syzkaller.appspotmail.com>, Fedor Pchelkin <pchelkin at ispras.ru>
Message-ID: <20220801155908.1539833-2-pchelkin at ispras.ru>

From: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>

commit b0ec7e55fce65f125bd1d7f02e2dc4de62abee34 upstream.

syzbot is reporting lockdep warning followed by kernel panic at
ath9k_htc_rxep() [1], for ath9k_htc_rxep() depends on ath9k_rx_init()
being already completed.

Since ath9k_htc_rxep() is set by ath9k_htc_connect_svc(WMI_BEACON_SVC)
 from ath9k_init_htc_services(), it is possible that ath9k_htc_rxep() is
called via timer interrupt before ath9k_rx_init() from ath9k_init_device()
is called.

Since we can't call ath9k_init_device() before ath9k_init_htc_services(),
let's hold ath9k_htc_rxep() no-op until ath9k_rx_init() completes.

Link: https://syzkaller.appspot.com/bug?extid=4d2d56175b934b9a7bf9 [1]
Reported-by: syzbot <syzbot+4d2d56175b934b9a7bf9 at syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel at I-love.SAKURA.ne.jp>
Tested-by: syzbot <syzbot+4d2d56175b934b9a7bf9 at syzkaller.appspotmail.com>
Signed-off-by: Kalle Valo <quic_kvalo at quicinc.com>
Link: https://lore.kernel.org/r/2b88f416-b2cb-7a18-d688-951e6dc3fe92@i-love.sakura.ne.jp
Signed-off-by: Fedor Pchelkin <pchelkin at ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/net/wireless/ath/ath9k/htc.h          |    1 +
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c |    8 ++++++++
 2 files changed, 9 insertions(+)

--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -281,6 +281,7 @@ struct ath9k_htc_rxbuf {
 struct ath9k_htc_rx {
 	struct list_head rxbuf;
 	spinlock_t rxbuflock;
+	bool initialized;
 };
 
 #define ATH9K_HTC_TX_CLEANUP_INTERVAL 50 /* ms */
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -1133,6 +1133,10 @@ void ath9k_htc_rxep(void *drv_priv, stru
 	struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
 	unsigned long flags;
 
+	/* Check if ath9k_rx_init() completed. */
+	if (!data_race(priv->rx.initialized))
+		goto err;
+
 	spin_lock_irqsave(&priv->rx.rxbuflock, flags);
 	list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
 		if (!tmp_buf->in_process) {
@@ -1188,6 +1192,10 @@ int ath9k_rx_init(struct ath9k_htc_priv
 		list_add_tail(&rxbuf->list, &priv->rx.rxbuf);
 	}
 
+	/* Allow ath9k_htc_rxep() to operate. */
+	smp_wmb();
+	priv->rx.initialized = true;
+
 	return 0;
 
 err:


Patches currently in stable-queue which might be from pchelkin at ispras.ru are

queue-5.10/ath9k_htc-fix-null-pointer-dereference-at-ath9k_htc_tx_get_packet.patch
queue-5.10/ath9k_htc-fix-null-pointer-dereference-at-ath9k_htc_rxep.patch



More information about the ldv-project mailing list