Skip to contentSkip to conversation

wifi: ath12k: Fix for out-of bound access error

PATCH Superseded Karol Przybylski 2 participants 2 messages Oct 21, 2024 – Oct 22, 2024 Qualcomm ATH12K wireless driver

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: ath12k: Fix for out-of bound access error

Size of array passed to print_array_to_buf_index is decremented by 1

Discovered in coverity scan, CID 1600742
---
Changes in v2:
- Code style: added spaces before and after '-'
- Link to v1: https://lore.kernel.org/all/[email protected]/
---

---
 drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +1 -1
index 799b865b89e5..8371df570c42 100644
@@ -1590,7 +1590,7 @@ ath12k_htt_print_tx_selfgen_ax_stats_tlv(const void *tag_buf, u16 tag_len,
 			 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndp));
 	len += print_array_to_buf_index(buf, len, "ax_mu_mimo_brpollX_tried = ", 1,
 					htt_stats_buf->ax_mu_mimo_brpoll,
-					ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS, "\n");
+					ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS - 1, "\n");
 	len += scnprintf(buf + len, buf_len - len, "ax_basic_trigger = %u\n",
 			 le32_to_cpu(htt_stats_buf->ax_basic_trigger));
 	len += scnprintf(buf + len, buf_len - len, "ax_ulmumimo_total_trigger = %u\n",
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Karol Przybylski

Size of array passed to print_array_to_buf_index is decremented by 1

This is not a clear commit message.
Please follow the order normally used in the kernel:
1) describe the current code
2) describe the problem with the current code
3) describe how to fix the code (in imperative voice)

Quoted 9 lines

Discovered in coverity scan, CID 1600742
---
Changes in v2:
- Code style: added spaces before and after '-'
- Link to v1: https://lore.kernel.org/all/[email protected]/
---

SOB needs to be before the first "---"

Quoted 9 lines
---
 drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +0 -0
index 799b865b89e5..8371df570c42 100644

drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c ath12k_htt_print_tx_selfgen_ax_stats_tlv(const void *tag_buf, u16 tag_len, · line 1596

Quoted 8 lines
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +1 -1
@@ -1590,7 +1590,7 @@ ath12k_htt_print_tx_selfgen_ax_stats_tlv(const void *tag_buf, u16 tag_len,
 			 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndp));
 	len += print_array_to_buf_index(buf, len, "ax_mu_mimo_brpollX_tried = ", 1,
 					htt_stats_buf->ax_mu_mimo_brpoll,
-					ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS, "\n");
+					ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS - 1, "\n");
 	len += scnprintf(buf + len, buf_len - len, "ax_basic_trigger = %u\n",
 			 le32_to_cpu(htt_stats_buf->ax_basic_trigger));
 	len += scnprintf(buf + len, buf_len - len, "ax_ulmumimo_total_trigger = %u\n",

Aren't there more than this one? This also looks suspect:

	len += print_array_to_buf_index(buf, len, "ac_mu_mimo_brpollX_tried = ", 1,
					htt_stats_buf->ac_mu_mimo_brpoll,
					ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS, "\n\n");