From: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
To: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>,
Felix Fietkau <nbd@nbd.name>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
Ming Yen Hsieh <mingyen.hsieh@mediatek.com>,
Deren Wu <deren.wu@mediatek.com>,
linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wifi: mt76: mt7921: validate CLC firmware records
Date: Sun, 16 Aug 2026 18:23:25 +0500 [thread overview]
Message-ID: <20260816132325.23007-1-mikhail.v.gavrilov@gmail.com> (raw)
In-Reply-To: <CAMyXUJmh=WfwC4_KHupNxYR5e2Gy5QhBDL5TSG6XEW-XLa+X4Q@mail.gmail.com>
This patch is in linux-next as 9417c5818a01, and on current shipping
firmware it stops mt7921e from probing at all.
An unknown clc->idx is treated as fatal:
if (clc_len < sizeof(*clc) || clc_len > len - offset ||
clc->idx >= ARRAY_SIZE(phy->clc)) {
ret = -EINVAL;
goto out;
}
but linux-firmware 20260810 ships an MT7922 image that legitimately
carries records with idx 3. Dumping the CLC region of
WIFI_RAM_CODE_MT7922_1.bin before and after that firmware update:
20260622, region len 366448:
idx=0 ver=1 nr_country=255 type=0 len=179384
idx=0 ver=1 nr_country=255 type=1 len=187064
20260810, region len 475488:
idx=0 ver=1 nr_country=255 type=0 len=179384
idx=0 ver=1 nr_country=255 type=1 len=187054
idx=3 ver=1 nr_country=0 type=0 len=54520
idx=3 ver=1 nr_country=0 type=1 len=54530
So mt7921_load_clc() returns -EINVAL, mt7921_run_firmware() fails, and
the probe retries the firmware ten times before giving up:
mt7921e 0000:0b:00.0: ASIC revision: 79220010
mt7921e 0000:0b:00.0: HW/SW Version: 0x8a108a10, Build Time: 20260724143257a
mt7921e 0000:0b:00.0: WM Firmware Version: ____000000, Build Time: 20260724143402
[ ... nine more identical pairs ... ]
mt7921e 0000:0b:00.0: hardware init failed
No interface is created. There is no dev_err on this path, so the only
clue is the retry loop. Loading mt7921_common with disable_clc=1, which
makes mt7921_load_clc() return before any of this, brings the device up
normally and the firmware is loaded once rather than ten times.
The rest of the patch is a real improvement - bounds-checking the region
table and each record length also closes an infinite loop on a
zero-length record. Only the handling of an unknown index needs to
change: an index the driver does not know about is not a malformed
image, it is a newer firmware, and the record should be skipped:
if (clc_len < sizeof(*clc) || clc_len > len - offset) {
ret = -EINVAL;
goto out;
}
if (clc->idx >= ARRAY_SIZE(phy->clc))
continue;
I sent an overlapping patch yesterday, "wifi: mt76: mt7921: fix
array-index-out-of-bounds in mt7921_load_clc()", before I found this one
in linux-next; I will mark mine superseded, since this patch is the
broader fix. Happy to send the one-line change above as a follow-up
patch and test it here, or leave it to you to fold in before this
reaches mainline.
Separately, it would be useful to know what CLC index 3 actually
contains - roughly 109 KB of payload in two hw_encap variants that the
driver currently discards either way.
next prev parent reply other threads:[~2026-08-16 13:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 18:54 Laxman Acharya Padhya
2026-08-16 13:23 ` Mikhail Gavrilov [this message]
2026-08-16 17:48 ` [PATCH] wifi: mt76: mt7921: skip unknown " Laxman Acharya Padhya
2026-08-17 20:16 ` Mikhail Gavrilov
2026-09-01 14:27 ` Junjie Cao
2026-09-14 4:39 ` Thorsten Leemhuis
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=20260816132325.23007-1-mikhail.v.gavrilov@gmail.com \
--to=mikhail.v.gavrilov@gmail.com \
--cc=acharyalaxman8848@gmail.com \
--cc=deren.wu@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=mingyen.hsieh@mediatek.com \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@mediatek.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
all inboxes | Powered by JetHome®