Linux wireless drivers development
 help / color / mirror / Atom feed
From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH rtw-next 4/4] wifi: rtw89: phy: check cur_idx of TAS power report
Date: Tue,  1 Dec 2026 17:01:38 +0800	[thread overview]
Message-ID: <20261201090138.3652600-5-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20261201090138.3652600-1-maoyixie.tju@gmail.com>

rtw89_phy_c2h_rfk_tas_pwr() averages txpwr_history[i] for i below
cur_idx. cur_idx comes from the firmware report, and nothing checks it
against the 20 entries of txpwr_history[]. A larger value makes the
loop read past the report.

Ignore the report when cur_idx exceeds the size of txpwr_history[].

Found with a CodeQL-based static analysis tool. Reproduced in a
userspace harness under AddressSanitizer. Not tested on hardware.

Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.

 drivers/net/wireless/realtek/rtw89/phy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index b4f1802025c9..26675a31ced9 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -3541,6 +3541,9 @@ void rtw89_phy_c2h_rfk_tas_pwr(struct rtw89_dev *rtwdev,
 		return;
 
 	cur_idx = le32_to_cpu(content->cur_idx);
+	if (cur_idx > ARRAY_SIZE(content->txpwr_history))
+		return;
+
 	for (i = 0; i < cur_idx; i++) {
 		txpwr = le16_to_cpu(content->txpwr_history[i]);
 		linear += rtw89_db_quarter_to_linear(txpwr);
-- 
2.34.1


      parent reply	other threads:[~2026-12-01  9:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:01 [PATCH rtw-next 0/4] wifi: rtw89: check lengths and indices reported by the chip Maoyi Xie
2026-12-01  9:01 ` [PATCH rtw-next 1/4] wifi: rtw89: pci: reject oversized RX packets Maoyi Xie
2026-12-01  9:01 ` [PATCH rtw-next 2/4] wifi: rtw89: pci: validate hardware index of BD ring Maoyi Xie
2026-12-01  9:01 ` [PATCH rtw-next 3/4] wifi: rtw89: phy: check LPS report C2H event length Maoyi Xie
2026-12-01  9:01 ` Maoyi Xie [this message]

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=20261201090138.3652600-5-maoyixie.tju@gmail.com \
    --to=maoyixie.tju@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.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