From: Ping-Ke Shih <pkshih@realtek.com>
To: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Luka Gejak <luka.gejak@linux.dev>, Kalle Valo <kvalo@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH rtw-next v4] wifi: rtw88: 8822c: validate bw and nrx read from registers
Date: Fri, 27 Nov 2026 00:37:36 +0000 [thread overview]
Message-ID: <2942bdc6c66949bcb90cbc9ea61dfcaa@realtek.com> (raw)
In-Reply-To: <20261125203753.428868-1-zeshanahmednobin@gmail.com>
Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com> wrote:
> rtw8822c_phy_cck_pd_set() reads nrx and bw from the chip with
> rtw_read32_mask() and uses them as indexes into dm_info->cck_pd_lv[][]
> and rtw8822c_cck_pd_reg[][].
>
> When the chip stops responding on the PCIe bus, register reads return
> all ones, so bw and nrx both become 3. bw = 3 is past the end of both
> arrays. When the chip stopped responding on Ubuntu's 7.0.0-43 kernel,
> UBSAN reported:
>
> 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:
> 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]
>
> nrx = 3 fits in cck_pd_lv[][], but rtw8822c_cck_pd_reg[][] only has
> registers for nrx 0 and 1. The entry for nrx 3 is empty: register 0,
> mask 0. If bw is valid and the level changes, the driver uses that
> empty entry. rtw_read32_mask() then shifts by __ffs(0), which is
> undefined; in a test that faked only nrx 3, UBSAN reported "shift
> exponent 64 is too large".
>
> Return early if bw or nrx is out of range, before either is used as
> an index.
>
> Fixes: 479c4ee931a6 ("rtw88: add dynamic cck pd mechanism")
> Reported-by: Luka Gejak <luka.gejak@linux.dev>
> Closes: https://lore.kernel.org/linux-wireless/f6a7d3272fe7635c6a83698dfab5d85500437ca6@linux.dev/
> Cc: stable@vger.kernel.org
> Signed-off-by: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
next prev parent reply other threads:[~2026-11-27 0:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 20:37 [PATCH rtw-next v4] wifi: rtw88: 8822c: validate bw and nrx read from registers Zeshan Ahmed Nobin
2026-11-25 21:14 ` Luka Gejak
2026-11-27 0:37 ` Ping-Ke Shih [this message]
2026-11-27 4: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=2942bdc6c66949bcb90cbc9ea61dfcaa@realtek.com \
--to=pkshih@realtek.com \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luka.gejak@linux.dev \
--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.