From: Luka Gejak <luka.gejak@linux.dev>
To: Zeshan Ahmed Nobin <zeshanahmednobin@gmail.com>,
linux-wireless@vger.kernel.org
Cc: Ping-Ke Shih <pkshih@realtek.com>, Kalle Valo <kvalo@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH rtw-next v4] wifi: rtw88: 8822c: validate bw and nrx read from registers
Date: Wed, 25 Nov 2026 22:14:25 +0100 [thread overview]
Message-ID: <E6ECB3B5-5DEE-49A5-BDDC-0F20CE84065F@linux.dev> (raw)
In-Reply-To: <20261125203753.428868-1-zeshanahmednobin@gmail.com>
On November 25, 2026 9:37:53 PM GMT+01:00, 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>
>---
Looks good to me,
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Best regards,
Luka Gejak
prev parent reply other threads:[~2026-11-25 21:14 UTC|newest]
Thread overview: 2+ 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 [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=E6ECB3B5-5DEE-49A5-BDDC-0F20CE84065F@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox