public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] wifi: ath12k: Fix for out-of bound access error
@ 2024-11-05 10:11 Karol Przybylski
  2024-11-11 16:11 ` Jeff Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karol Przybylski @ 2024-11-05 10:11 UTC (permalink / raw)
  To: kvalo, jjohnson
  Cc: Karol Przybylski, linux-wireless, ath12k, linux-kernel, skhan

Selfgen stats are placed in a buffer using print_array_to_buf_index() function.
Array length parameter passed to the function is too big, resulting in possible
out-of bound memory error.
Decreasing buffer size by one fixes faulty upper bound of passed array.

Discovered in coverity scan, CID 1600742 and CID 1600758

Signed-off-by: Karol Przybylski <karprzy7@gmail.com>
---
Changes in v3:
- Code style: added spaces before and after '-'
- Improved commit msg
- Fixed same error in different function
- Link to previous discussion: https://lore.kernel.org/all/08767ff7-f764-473d-a44b-c3c3b1695008@quicinc.com/
---
 drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
index 799b865b89e5..2d47aca681f4 100644
--- a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
+++ b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
@@ -1562,7 +1562,7 @@ ath12k_htt_print_tx_selfgen_ac_stats_tlv(const void *tag_buf, u16 tag_len,
 			 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndp));
 	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");
+					ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS - 1, "\n\n");
 
 	stats_req->buf_len = len;
 }
@@ -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",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] wifi: ath12k: Fix for out-of bound access error
  2024-11-05 10:11 [PATCH v3] wifi: ath12k: Fix for out-of bound access error Karol Przybylski
@ 2024-11-11 16:11 ` Jeff Johnson
  2024-11-12 10:13 ` Kalle Valo
  2024-11-13  1:01 ` Jeff Johnson
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2024-11-11 16:11 UTC (permalink / raw)
  To: Karol Przybylski, kvalo, jjohnson
  Cc: linux-wireless, ath12k, linux-kernel, skhan

On 11/5/2024 2:11 AM, Karol Przybylski wrote:
> Selfgen stats are placed in a buffer using print_array_to_buf_index() function.
> Array length parameter passed to the function is too big, resulting in possible
> out-of bound memory error.
> Decreasing buffer size by one fixes faulty upper bound of passed array.
> 
> Discovered in coverity scan, CID 1600742 and CID 1600758
> 
> Signed-off-by: Karol Przybylski <karprzy7@gmail.com>
> ---
> Changes in v3:
> - Code style: added spaces before and after '-'
> - Improved commit msg
> - Fixed same error in different function
> - Link to previous discussion: https://lore.kernel.org/all/08767ff7-f764-473d-a44b-c3c3b1695008@quicinc.com/
> ---
>  drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> index 799b865b89e5..2d47aca681f4 100644
> --- a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> +++ b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> @@ -1562,7 +1562,7 @@ ath12k_htt_print_tx_selfgen_ac_stats_tlv(const void *tag_buf, u16 tag_len,
>  			 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndp));
>  	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");
> +					ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS - 1, "\n\n");

Our ath12k-check tool reports:
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c:1565: line length of 92
exceeds 90 columns

I'll fix this in the 'pending' branch

>  
>  	stats_req->buf_len = len;
>  }
> @@ -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",



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] wifi: ath12k: Fix for out-of bound access error
  2024-11-05 10:11 [PATCH v3] wifi: ath12k: Fix for out-of bound access error Karol Przybylski
  2024-11-11 16:11 ` Jeff Johnson
@ 2024-11-12 10:13 ` Kalle Valo
  2024-11-13  1:01 ` Jeff Johnson
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2024-11-12 10:13 UTC (permalink / raw)
  To: Karol Przybylski; +Cc: jjohnson, linux-wireless, ath12k, linux-kernel, skhan

Karol Przybylski <karprzy7@gmail.com> writes:

> Selfgen stats are placed in a buffer using print_array_to_buf_index() function.
> Array length parameter passed to the function is too big, resulting in possible
> out-of bound memory error.
> Decreasing buffer size by one fixes faulty upper bound of passed array.
>
> Discovered in coverity scan, CID 1600742 and CID 1600758
>
> Signed-off-by: Karol Przybylski <karprzy7@gmail.com>

I assume you only compile tested this, it's always good to mention that
in the commit message. But no need resend because of this.

Acked-by: Kalle Valo <kvalo@kernel.org>

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] wifi: ath12k: Fix for out-of bound access error
  2024-11-05 10:11 [PATCH v3] wifi: ath12k: Fix for out-of bound access error Karol Przybylski
  2024-11-11 16:11 ` Jeff Johnson
  2024-11-12 10:13 ` Kalle Valo
@ 2024-11-13  1:01 ` Jeff Johnson
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2024-11-13  1:01 UTC (permalink / raw)
  To: kvalo, jjohnson, Karol Przybylski
  Cc: linux-wireless, ath12k, linux-kernel, skhan


On Tue, 05 Nov 2024 11:11:31 +0100, Karol Przybylski wrote:
> Selfgen stats are placed in a buffer using print_array_to_buf_index() function.
> Array length parameter passed to the function is too big, resulting in possible
> out-of bound memory error.
> Decreasing buffer size by one fixes faulty upper bound of passed array.
> 
> Discovered in coverity scan, CID 1600742 and CID 1600758
> 
> [...]

Applied, thanks!

[1/1] wifi: ath12k: Fix for out-of bound access error
      commit: eb8c0534713865d190856f10bfc97cf0b88475b1

Best regards,
-- 
Jeff Johnson <quic_jjohnson@quicinc.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-13  1:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 10:11 [PATCH v3] wifi: ath12k: Fix for out-of bound access error Karol Przybylski
2024-11-11 16:11 ` Jeff Johnson
2024-11-12 10:13 ` Kalle Valo
2024-11-13  1:01 ` Jeff Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox