wifi: mt76: mt7921: validate CLC indices
Subsystems (3)
PATCH 1/1 wifi: mt76: mt7921: validate CLC indices
mt7921_load_clc() indexes phy->clc[] with the index stored in each CLC record from the firmware image, but does not validate that index before its first array access.
The equivalent mt7925 parser added the same validation for a potential array-index out-of-bounds issue and later corrected the comparison from
Quoted 1 line
to >=. mt7921 never received either change; see the linked commits.
A malformed CLC region can therefore read or write past phy->clc[] while the driver is starting.
Stop parsing the CLC region when a record has an out-of-range index, matching the corrected mt7925 parser.
Fixes 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Assisted-by Codex:gpt-5.6-sol
Signed-off-by Zhao Li <[email protected]>
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +3 -0
@@ -467,6 +467,9 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)for (offset =0 ; offset < len; offset +=le32_to_cpu (clc->len)) { clc = (const struct mt7921_clc *)(clc_base + offset); +if (clc->idx >=ARRAY_SIZE (phy->clc)) +break ; +/* do not init buf again if chip reset triggered */ if (phy->clc[clc->idx])continue ;
base-commit: 4a0bd262df757b25fc4e2a53c947317c119ced4e
Signature · 1 line
2.50.1 (Apple Git-155)