ath9k: fix a potential buffer leak in the STA teardown path
PATCH 1/2 ath9k: fix a potential buffer leak in the STA teardown path
It looks like it might be possible for a TID to be paused, while still holding some queued buffers, however ath_tx_node_cleanup currently only iterates over active TIDs.
Fix this by always checking every allocated TID for the STA that is being cleaned up.
Signed-off-by Felix Fietkau <[email protected]>
--- drivers/net/wireless/ath/ath9k/xmit.c | 52 ++++++++++++++++---------------- 1 files changed, 26 insertions(+), 26 deletions(-)
drivers/net/wireless/ath/ath9k/xmit.c +26 -26
@@ -2430,37 +2430,37 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)void ath_tx_node_cleanup (struct ath_softc *sc,struct ath_node *an) { -int i; -struct ath_atx_ac *ac, *ac_tmp; -struct ath_atx_tid *tid, *tid_tmp; +struct ath_atx_ac *ac; +struct ath_atx_tid *tid;struct ath_txq *txq; +int i, tidno; -for (i =0 ; i <ATH9K_NUM_TX_QUEUES ; i++) { -if (ATH_TXQ_SETUP (sc, i)) { - txq = &sc->tx.txq[i]; +for (tidno =0 , tid = &an->tid[tidno]; + tidno <WME_NUM_TID ; tidno++, tid++) { + i = tid->ac->qnum; -spin_lock_bh (&txq->axq_lock); +if (!ATH_TXQ_SETUP (sc, i)) +continue ; -list_for_each_entry_safe (ac, - ac_tmp, &txq->axq_acq, list) { - tid =list_first_entry (&ac->tid_q, - struct ath_atx_tid, list); -if (tid && tid->an != an) -continue ; -list_del (&ac->list); - ac->sched = false; - -list_for_each_entry_safe (tid, - tid_tmp, &ac->tid_q, list) { -list_del (&tid->list); - tid->sched = false; -ath_tid_drain (sc, txq, tid); - tid->state &= ~AGGR_ADDBA_COMPLETE ; - tid->state &= ~AGGR_CLEANUP ; - } - } + txq = &sc->tx.txq[i]; + ac = tid->ac; -spin_unlock_bh (&txq->axq_lock); +spin_lock_bh (&txq->axq_lock); + +if (tid->sched) { +list_del (&tid->list); + tid->sched = false; + } + +if (ac->sched) { +list_del (&ac->list); + tid->ac->sched = false; } + +ath_tid_drain (sc, txq, tid); + tid->state &= ~AGGR_ADDBA_COMPLETE ; + tid->state &= ~AGGR_CLEANUP ; + +spin_unlock_bh (&txq->axq_lock); } }
Signature · 1 line
1.6.4.2
PATCH 2/2 ath9k: fix a buffer leak in A-MPDU completion
When ath_tx_complete_aggr() is called, it's responsible for returning all buffers in the linked list. This was not done when the STA lookup failed, leading to a race condition that could leak a few buffers when a STA just disconnected.
Fix this by immediately returning all buffers to the free list in this case.
Signed-off-by Felix Fietkau <[email protected]>
--- drivers/net/wireless/ath/ath9k/xmit.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/xmit.c +5 -0
@@ -329,6 +329,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,int isaggr, txfail, txpending, sendbar =0 , needreset =0 , nbad =0 ;bool rc_update = true;struct ieee80211_tx_rate rates[4 ]; +unsigned long flags; skb = bf->bf_mpdu; hdr = (struct ieee80211_hdr *)skb->data;
@@ -344,6 +345,10 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, sta =ieee80211_find_sta_by_hw (hw, hdr->addr1);if (!sta) {rcu_read_unlock (); + +spin_lock_irqsave (&sc->tx.txbuflock, flags); +list_splice_tail_init (bf_q, &sc->tx.txbuf); +spin_unlock_irqrestore (&sc->tx.txbuflock, flags);return ; }
Signature · 1 line
1.6.4.2