All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Maoyi Xie <maoyixie.tju@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH rtw-next 3/4] wifi: rtw89: phy: check LPS report C2H event length
Date: Wed, 2 Dec 2026 03:03:10 +0000	[thread overview]
Message-ID: <2347be3ddfd141e29f3550f4b9efab6a@realtek.com> (raw)
In-Reply-To: <20261201090138.3652600-4-maoyixie.tju@gmail.com>

Maoyi Xie <maoyixie.tju@gmail.com> wrote:
> The LPS report handler checks the length from the C2H header and the
> counts in the report against each other, but not against the skb. If
> the header claims more data than arrived, the debug prints read up to
> 16 KB past the skb data, even with the debug mask off.
> 
> Check the skb length before processing the report.
> 
> 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 133b591ffa7f..b4f1802025c9 100644
> --- a/drivers/net/wireless/realtek/rtw89/phy.c
> +++ b/drivers/net/wireless/realtek/rtw89/phy.c
> @@ -3449,6 +3449,9 @@ rtw89_phy_c2h_lps_rpt(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len)
>         const __le16 *addr;
>         const u8 *info;
> 
> +       if (c2h->len < sizeof(*c2h_rpt) || len > c2h->len)
> +               return;
> +

Validate 'len > c2h->len' earlier (with unlikely) at rtw89_fw_c2h_cmd_handle().

>         /* elements size of BBCR/BBMCUCR/RFCR are 6/6/10 bytes respectively */
>         cr_len = c2h_rpt->cnt_bbcr * 6 +
>                  c2h_rpt->cnt_bbmcucr * 6 +
> --
> 2.34.1


  reply	other threads:[~2026-12-02  3:03 UTC|newest]

Thread overview: 9+ 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-02  2:57   ` Ping-Ke Shih
2026-12-01  9:01 ` [PATCH rtw-next 2/4] wifi: rtw89: pci: validate hardware index of BD ring Maoyi Xie
2026-12-02  2:59   ` Ping-Ke Shih
2026-12-01  9:01 ` [PATCH rtw-next 3/4] wifi: rtw89: phy: check LPS report C2H event length Maoyi Xie
2026-12-02  3:03   ` Ping-Ke Shih [this message]
2026-12-01  9:01 ` [PATCH rtw-next 4/4] wifi: rtw89: phy: check cur_idx of TAS power report Maoyi Xie
2026-12-02  3:04   ` Ping-Ke Shih

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=2347be3ddfd141e29f3550f4b9efab6a@realtek.com \
    --to=pkshih@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=maoyixie.tju@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.