Skip to content

Commit 2d3b558

Browse files
Zhi ChenKalle Valo
authored andcommitted
ath10k: fix peer stats null pointer dereference
There was a race condition in SMP that an ath10k_peer was created but its member sta was null. Following are procedures of ath10k_peer creation and member sta access in peer statistics path. 1. Peer creation: ath10k_peer_create() =>ath10k_wmi_peer_create() =>ath10k_wait_for_peer_created() ... # another kernel path, RX from firmware ath10k_htt_t2h_msg_handler() =>ath10k_peer_map_event() =>wake_up() # ar->peer_map[id] = peer //add peer to map #wake up original path from waiting ... # peer->sta = sta //sta assignment 2. RX path of statistics ath10k_htt_t2h_msg_handler() =>ath10k_update_per_peer_tx_stats() =>ath10k_htt_fetch_peer_stats() # peer->sta //sta accessing Any access of peer->sta after peer was added to peer_map but before sta was assigned could cause a null pointer issue. And because these two steps are asynchronous, no proper lock can protect them. So both peer and sta need to be checked before access. Tested: QCA9984 with firmware ver 10.4-3.9.0.1-00005 Signed-off-by: Zhi Chen <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent a3542d0 commit 2d3b558

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/net/wireless/ath/ath10k/debugfs_sta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void ath10k_sta_update_rx_tid_stats_ampdu(struct ath10k *ar, u16 peer_id, u8 tid
7171
spin_lock_bh(&ar->data_lock);
7272

7373
peer = ath10k_peer_find_by_id(ar, peer_id);
74-
if (!peer)
74+
if (!peer || !peer->sta)
7575
goto out;
7676

7777
arsta = (struct ath10k_sta *)peer->sta->drv_priv;

drivers/net/wireless/ath/ath10k/htt_rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,7 +3121,7 @@ static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
31213121
rcu_read_lock();
31223122
spin_lock_bh(&ar->data_lock);
31233123
peer = ath10k_peer_find_by_id(ar, peer_id);
3124-
if (!peer) {
3124+
if (!peer || !peer->sta) {
31253125
ath10k_warn(ar, "Invalid peer id %d peer stats buffer\n",
31263126
peer_id);
31273127
goto out;
@@ -3174,7 +3174,7 @@ static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data)
31743174
rcu_read_lock();
31753175
spin_lock_bh(&ar->data_lock);
31763176
peer = ath10k_peer_find_by_id(ar, peer_id);
3177-
if (!peer) {
3177+
if (!peer || !peer->sta) {
31783178
ath10k_warn(ar, "Invalid peer id %d in peer stats buffer\n",
31793179
peer_id);
31803180
goto out;

0 commit comments

Comments
 (0)