Linux wireless drivers development
 help / color / mirror / Atom feed
From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
To: Pardeep Kaur <pardeep.kaur@oss.qualcomm.com>, ath12k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH ath-next v2 1/8] wifi: ath12k: fix out-of-bounds access on TX stats arrays
Date: Thu, 6 Aug 2026 19:07:37 -0700	[thread overview]
Message-ID: <34ab0833-45fc-4e21-bbf3-bc5a167d9bde@oss.qualcomm.com> (raw)
In-Reply-To: <20260806132427.3704828-2-pardeep.kaur@oss.qualcomm.com>

On 8/6/2026 6:24 AM, Pardeep Kaur wrote:
> From: Pardeep Kaur <pardeep.kaur@oss.qualcomm.com>
> 
> The fw_tx_status[], tx_wbm_rel_source[], and tqm_rel_reason[] arrays
> are indexed directly by values read from hardware without bounds checks.
> Values at or beyond MAX_FW_TX_STATUS, HAL_WBM_REL_SRC_MODULE_MAX, or
> MAX_TQM_RELEASE_REASON respectively would write past the end of the
> arrays causing memory corruption.
> 
> Add bounds checks using likely() and WARN_ON_ONCE() before incrementing
> each counter, consistent with the existing pattern used elsewhere in
> the ath12k codebase.
> 
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6.r1-00402-QCAHKSWPL_SILICONZ-1
> 
> Fixes: c5c62287e690 ("wifi: ath12k: Add device dp stats support")
> Signed-off-by: Pardeep Kaur <pardeep.kaur@oss.qualcomm.com>
> ---
>  drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c b/drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c
> index 587d58eeccfa..632230e77802 100644
> --- a/drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c
> +++ b/drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c
> @@ -582,7 +582,10 @@ ath12k_dp_tx_process_htt_tx_complete(struct ath12k_dp *dp, void *desc,
>  
>  	wbm_status = le32_get_bits(status_desc->info0,
>  				   HTT_TX_WBM_COMP_INFO0_STATUS);
> -	dp->device_stats.fw_tx_status[wbm_status]++;
> +	if (likely(wbm_status < MAX_FW_TX_STATUS))
> +		dp->device_stats.fw_tx_status[wbm_status]++;
> +	else
> +		WARN_ON_ONCE(1);

My review agent tells me this will now double warn since the default: case of
the switch (wbm_status) that follows will also ath12k_warn()

So for wbm_status warn in one place or the other, but not both

>  
>  	switch (wbm_status) {
>  	case HAL_WBM_REL_HTT_TX_COMP_STATUS_OK:
> @@ -984,11 +987,17 @@ void ath12k_wifi7_dp_tx_completion_handler(struct ath12k_dp *dp, int ring_id)
>  		/* Find the HAL_WBM_RELEASE_INFO0_REL_SRC_MODULE value */
>  		buf_rel_source = le32_get_bits(tx_status->info0,
>  					       HAL_WBM_RELEASE_INFO0_REL_SRC_MODULE);
> -		dp->device_stats.tx_wbm_rel_source[buf_rel_source]++;
> +		if (likely(buf_rel_source < HAL_WBM_REL_SRC_MODULE_MAX))
> +			dp->device_stats.tx_wbm_rel_source[buf_rel_source]++;
> +		else
> +			WARN_ON_ONCE(1);
>  
>  		rel_status = le32_get_bits(tx_status->info0,
>  					   HAL_WBM_COMPL_TX_INFO0_TQM_RELEASE_REASON);
> -		dp->device_stats.tqm_rel_reason[rel_status]++;
> +		if (likely(rel_status < MAX_TQM_RELEASE_REASON))
> +			dp->device_stats.tqm_rel_reason[rel_status]++;
> +		else
> +			WARN_ON_ONCE(1);
>  
>  		/* Release descriptor as soon as extracting necessary info
>  		 * to reduce contention
> base-commit: 691e5e43b2aa
> --
> 2.34.1


  reply	other threads:[~2026-08-07  2:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 13:24 [PATCH ath-next v2 0/8] wifi: ath12k: extend device DP stats for TX and RX observability Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 1/8] wifi: ath12k: fix out-of-bounds access on TX stats arrays Pardeep Kaur
2026-08-07  2:07   ` Jeff Johnson [this message]
2026-08-06 13:24 ` [PATCH ath-next v2 2/8] wifi: ath12k: rename wbm_status to htt_status in HTT TX completion Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 3/8] wifi: ath12k: add TCL ring TX buffer allocation failure counter Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 4/8] wifi: ath12k: add device DP stats reset support via debugfs Pardeep Kaur
2026-08-07  2:14   ` Jeff Johnson
2026-08-06 13:24 ` [PATCH ath-next v2 5/8] wifi: ath12k: add WBM RX error drop statistics Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 6/8] wifi: ath12k: track per-ring RX sent-to-stack count Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 7/8] wifi: ath12k: fix 1-based ring index in REO Rx Received debugfs output Pardeep Kaur
2026-08-06 13:24 ` [PATCH ath-next v2 8/8] wifi: ath12k: add WBM SW desc fallback counter Pardeep Kaur
2026-08-06 14:40 ` [PATCH ath-next v2 0/8] wifi: ath12k: extend device DP stats for TX and RX observability Jeff Johnson
  -- strict thread matches above, loose matches on Subject: below --
2026-08-06 12:09 Pardeep Kaur
2026-08-06 12:09 ` [PATCH ath-next v2 1/8] wifi: ath12k: fix out-of-bounds access on TX stats arrays Pardeep Kaur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34ab0833-45fc-4e21-bbf3-bc5a167d9bde@oss.qualcomm.com \
    --to=jeff.johnson@oss.qualcomm.com \
    --cc=ath12k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pardeep.kaur@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox