All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luka Gejak <luka.gejak@linux.dev>
To: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>,
	linux-wireless@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ping-Ke Shih <pkshih@realtek.com>,
	Kalle Valo <kvalo@kernel.org>
Subject: Re: [PATCH rtw-next v3 1/2] wifi: rtw88: 8822c: fix out-of-bounds access in cck_pd_set
Date: Mon, 16 Nov 2026 15:49:05 +0100	[thread overview]
Message-ID: <80B20AC6-F0A9-46AD-BAEE-3974FD07E20A@linux.dev> (raw)
In-Reply-To: <20261115201826.181662-2-zeshanahmednobin@gmail.com>

On November 15, 2026 9:18:25 PM GMT+01:00, Zeshan Ahmed Nobin
<zeshanahmednobin@gmail.com> wrote:
>rtw8822c_phy_cck_pd_set() reads the bandwidth from a 2-bit register
>field and uses it as the first index into dm_info->cck_pd_lv[], which
>only has entries for 20 and 40 MHz.
>
>When the chip stops responding on the PCIe bus, register reads return
>all ones and bw becomes 3. The function then reads cck_pd_lv[3][nrx],
>past the end of the array. If that byte differs from new_lvl, it calls
>rtw8822c_phy_cck_pd_set_reg(), which rejects bw with WARN_ON(), and
>then writes new_lvl to cck_pd_lv[3][nrx] anyway. UBSAN reports the
>first of these accesses as:
>
>  UBSAN: array-index-out-of-bounds in .../rtw88/rtw8822c.c:4407:21
>  index 3 is out of range for type 'u8 [2][4]'
>  Workqueue: phy0 rtw_watch_dog_work [rtw88_core]
>  Call Trace:
>   <TASK>
>   __ubsan_handle_out_of_bounds+0xdd/0x120
>   rtw8822c_phy_cck_pd_set+0x33c/0x510 [rtw88_8822c]
>   rtw_phy_dynamic_mechanism+0x310/0x330 [rtw88_core]
>   rtw_watch_dog_work+0x217/0x330 [rtw88_core]
>
>The driver doesn't need to read the bandwidth from the chip:
>rtw_set_channel() stores it in rtwdev->hal.current_band_width and
>programs the same value into the chip. Use the stored value. CCK PD
>only runs on 2.4 GHz, where the bandwidth is 20 or 40 MHz, so the
>stored value is always a valid index.
>
>On PCIe, a chip that stops responding still returns nrx = 3; the next
>patch handles nrx values without CCK PD registers.
>
>The fix and this message were drafted with an AI coding assistant
>(Claude Opus 5.5 by Anthropic), then reviewed and tested by the
>submitter.
>
>Fixes: 479c4ee931a6 ("rtw88: add dynamic cck pd mechanism")
>Cc: stable@vger.kernel.org
>Suggested-by: Luka Gejak <luka.gejak@linux.dev>
>Signed-off-by: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>
>---
>

Looks good to me,

Reviewed-by: Luka Gejak <luka.gejak@linux.dev>

Best regards,
Luka Gejak

  reply	other threads:[~2026-11-16 14:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 20:18 [PATCH rtw-next v3 0/2] wifi: rtw88: 8822c: fix cck_pd_set when the chip stops responding Zeshan Ahmed Nobin
2026-11-15 20:18 ` [PATCH rtw-next v3 1/2] wifi: rtw88: 8822c: fix out-of-bounds access in cck_pd_set Zeshan Ahmed Nobin
2026-11-16 14:49   ` Luka Gejak [this message]
2026-11-15 20:18 ` [PATCH rtw-next v3 2/2] wifi: rtw88: 8822c: ignore nrx values without CCK PD registers Zeshan Ahmed Nobin
2026-11-17  6:38   ` Ping-Ke Shih
2026-11-17 13:17     ` Luka Gejak
2026-11-18  0:25       ` 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=80B20AC6-F0A9-46AD-BAEE-3974FD07E20A@linux.dev \
    --to=luka.gejak@linux.dev \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=zeshanahmednobin@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.