summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiaoqing Pan <miaoqing@codeaurora.org>2017-06-27 17:31:49 +0300
committerBen Hutchings <ben@decadent.org.uk>2017-10-12 15:27:54 +0100
commit3757358b308fb0a8a16f0646cc4c64deb1229063 (patch)
treeaa28006d9fc8d07edfc30445871d5b41c9321bb4
parent0210302574d9ec879a3b7b18365f8fd872ec9636 (diff)
downloadlinux-stable-3757358b308fb0a8a16f0646cc4c64deb1229063.tar.gz
linux-stable-3757358b308fb0a8a16f0646cc4c64deb1229063.tar.bz2
linux-stable-3757358b308fb0a8a16f0646cc4c64deb1229063.zip
ath9k: fix tx99 use after free
commit cf8ce1ea61b75712a154c93e40f2a5af2e4dd997 upstream. One scenario that could lead to UAF is two threads writing simultaneously to the "tx99" debug file. One of them would set the "start" value to true and follow to ath9k_tx99_init(). Inside the function it would set the sc->tx99_state to true after allocating sc->tx99skb. Then, the other thread would execute write_file_tx99() and call ath9k_tx99_deinit(). sc->tx99_state would be freed. After that, the first thread would continue inside ath9k_tx99_init() and call r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl); that would make use of the freed sc->tx99_skb memory. Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/net/wireless/ath/ath9k/tx99.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/wireless/ath/ath9k/tx99.c b/drivers/net/wireless/ath/ath9k/tx99.c
index a65cfb91adca..fa48dcf3fe03 100644
--- a/drivers/net/wireless/ath/ath9k/tx99.c
+++ b/drivers/net/wireless/ath/ath9k/tx99.c
@@ -184,22 +184,27 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
if (strtobool(buf, &start))
return -EINVAL;
+ mutex_lock(&sc->mutex);
+
if (start == sc->tx99_state) {
if (!start)
- return count;
+ goto out;
ath_dbg(common, XMIT, "Resetting TX99\n");
ath9k_tx99_deinit(sc);
}
if (!start) {
ath9k_tx99_deinit(sc);
- return count;
+ goto out;
}
r = ath9k_tx99_init(sc);
- if (r)
+ if (r) {
+ mutex_unlock(&sc->mutex);
return r;
-
+ }
+out:
+ mutex_unlock(&sc->mutex);
return count;
}