Skip to contentSkip to conversation

wifi: ath5k: do not access array OOB

PATCH Superseded Jiri Slaby (SUSE) 1 participant 2 messages Nov 19, 2025 Atheros ATH5K wireless driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiri Slaby (SUSE)

author maintainer
#0 lore raw

PATCH 1/1 wifi: ath5k: do not access array OOB

Vincent reports:

Quoted 12 lines

The ath5k driver seems to do an array-index-out-of-bounds access as shown by the UBSAN kernel message:

UBSAN: array-index-out-of-bounds in drivers/net/wireless/ath/ath5k/base.c:1741:20
index 4 is out of range for type 'ieee80211_tx_rate [4]'
...
Call Trace:
 <TASK>
 dump_stack_lvl+0x5d/0x80
 ubsan_epilogue+0x5/0x2b
 __ubsan_handle_out_of_bounds.cold+0x46/0x4b
 ath5k_tasklet_tx+0x4e0/0x560 [ath5k]
 tasklet_action_common+0xb5/0x1c0

It is real. 'ts->ts_final_idx' can be 3 on 5212, so:
info->status.rates[ts->ts_final_idx + 1].idx = -1;
with the array defined as:
struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
while the size is:
#define IEEE80211_TX_MAX_RATES 4
is indeed bogus.

Set this 'idx = -1' sentinel only if the array index is less than the array size. As mac80211 will not look at rates beyond the size (IEEE80211_TX_MAX_RATES).

Note: The effect of the OOB write is negligible. It just overwrites the next member of info->status, i.e. ack_signal.

---
Cc: [email protected]
Cc: Salvatore Bonaccorso <[email protected]>
Cc: Nick Kossifidis <[email protected]>,
Cc: Luis Chamberlain <[email protected]>
Cc: [email protected]

---
 drivers/net/wireless/ath/ath5k/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/base.c +2 -1
index 4d88b02ffa79..917e1b087924 100644
@@ -1738,7 +1738,8 @@ ath5k_tx_frame_completed(struct ath5k_hw *ah, struct sk_buff *skb,
 	}
 
 	info->status.rates[ts->ts_final_idx].count = ts->ts_final_retry;
-	info->status.rates[ts->ts_final_idx + 1].idx = -1;
+	if (ts->ts_final_idx + 1 < IEEE80211_TX_MAX_RATES)
+		info->status.rates[ts->ts_final_idx + 1].idx = -1;
 
 	if (unlikely(ts->ts_status)) {
 		ah->stats.ack_fail++;
Signature · 1 line
2.51.1
author maintainer
#1 lore raw
Quoted 26 lines · Jiri Slaby (SUSE)

Vincent reports:

Quoted 12 lines

The ath5k driver seems to do an array-index-out-of-bounds access as shown by the UBSAN kernel message:

UBSAN: array-index-out-of-bounds in drivers/net/wireless/ath/ath5k/base.c:1741:20
index 4 is out of range for type 'ieee80211_tx_rate [4]'
...
Call Trace:
  <TASK>
  dump_stack_lvl+0x5d/0x80
  ubsan_epilogue+0x5/0x2b
  __ubsan_handle_out_of_bounds.cold+0x46/0x4b
  ath5k_tasklet_tx+0x4e0/0x560 [ath5k]
  tasklet_action_common+0xb5/0x1c0

It is real. 'ts->ts_final_idx' can be 3 on 5212, so:

    info->status.rates[ts->ts_final_idx + 1].idx = -1;
with the array defined as:
    struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
while the size is:
    #define IEEE80211_TX_MAX_RATES  4

is indeed bogus.

Set this 'idx = -1' sentinel only if the array index is less than the array size. As mac80211 will not look at rates beyond the size (IEEE80211_TX_MAX_RATES).

Quoted 7 lines

Note: The effect of the OOB write is negligible. It just overwrites the next member of info->status, i.e. ack_signal.

I forgot:

Fixes 6d7b97b23e11 ("ath5k: fix tx status reporting issues")

Do you want me to resend?

Quoted 15 lines

---
Cc: [email protected]
Cc: Salvatore Bonaccorso <[email protected]>
Cc: Nick Kossifidis <[email protected]>,
Cc: Luis Chamberlain <[email protected]>
Cc: [email protected]

---
  drivers/net/wireless/ath/ath5k/base.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/base.c +0 -0
index 4d88b02ffa79..917e1b087924 100644

drivers/net/wireless/ath/ath5k/base.c ath5k_tx_frame_completed(struct ath5k_hw *ah, struct sk_buff *skb, · line 1745

Quoted 9 lines
drivers/net/wireless/ath/ath5k/base.c +2 -1
@@ -1738,7 +1738,8 @@ ath5k_tx_frame_completed(struct ath5k_hw *ah, struct sk_buff *skb,
  	}
 
  	info->status.rates[ts->ts_final_idx].count = ts->ts_final_retry;
-	info->status.rates[ts->ts_final_idx + 1].idx = -1;
+	if (ts->ts_final_idx + 1 < IEEE80211_TX_MAX_RATES)
+		info->status.rates[ts->ts_final_idx + 1].idx = -1;
 
  	if (unlikely(ts->ts_status)) {
  		ah->stats.ack_fail++;

thanks,

Signature · 2 lines
js
suse labs