* [PATCH] wifi: mt76: mt7915: validate default EEPROM firmware size
@ 2026-08-28 15:02 Ridham Khurana
0 siblings, 0 replies; only message in thread
From: Ridham Khurana @ 2026-08-28 15:02 UTC (permalink / raw)
To: Felix Fietkau
Cc: Ridham Khurana, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, linux-wireless, linux-mediatek, linux-kernel,
Shuah Khan, Jori Koolstra, Brigham Campbell, linux-kernel-mentees,
stable
mt7915_eeprom_load_default() checks that the default EEPROM firmware was
loaded, but not how big it is. It then copies mt7915_eeprom_size() bytes
out of it, which is 3584 on MT7915 and 4096 on MT7916.
If the file is smaller than that, the copy reads past the end of the
firmware buffer. The extra bytes are whatever happens to follow it in
memory, and they end up in the EEPROM buffer that is later used for band
configuration, chainmask and TX power.
Check the size before copying, the same way
mt7996_eeprom_check_or_use_default() already does.
Fixes: bbc1d4154ec1 ("mt76: mt7915: add default calibrated data support")
Cc: stable@vger.kernel.org
Signed-off-by: Ridham Khurana <khurana.ridham222@gmail.com>
---
Based on next-20260828; applies cleanly to v7.2.
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
index fe7b29ebc0bf..145d14a1012d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
@@ -111,6 +111,12 @@ mt7915_eeprom_load_default(struct mt7915_dev *dev)
goto out;
}
+ if (fw->size < mt7915_eeprom_size(dev)) {
+ dev_err(dev->mt76.dev, "Invalid default bin size\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
memcpy(eeprom, fw->data, mt7915_eeprom_size(dev));
dev->flash_mode = true;
--
2.47.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-28 15:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 15:02 [PATCH] wifi: mt76: mt7915: validate default EEPROM firmware size Ridham Khurana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).