aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZekun Shen <bruceshenzk@gmail.com>2021-06-19 09:29:14 -0400
committerKalle Valo <kvalo@codeaurora.org>2021-08-29 10:12:09 +0300
commit23151b9ae79e3bc4f6a0c4cd3a7f355f68dad128 (patch)
treee381bd1b126751a422561adc2157ecf40cc628e6
parent8678fd31f2d3eb14f2b8b39c9bc266f16fa24b22 (diff)
downloadlinux-23151b9ae79e3bc4f6a0c4cd3a7f355f68dad128.tar.gz
ath9k: fix OOB read ar9300_eeprom_restore_internal
Bad header can have large length field which can cause OOB. cptr is the last bytes for read, and the eeprom is parsed from high to low address. The OOB, triggered by the condition length > cptr could cause memory error with a read on negative index. There are some sanity check around length, but it is not compared with cptr (the remaining bytes). Here, the corrupted/bad EEPROM can cause panic. I was able to reproduce the crash, but I cannot find the log and the reproducer now. After I applied the patch, the bug is no longer reproducible. Signed-off-by: Zekun Shen <bruceshenzk@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/YM3xKsQJ0Hw2hjrc@Zekuns-MBP-16.fios-router.home
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index b4885a700296e4..b0a4ca3559fd8c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3351,7 +3351,8 @@ found:
"Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
cptr, code, reference, length, major, minor);
if ((!AR_SREV_9485(ah) && length >= 1024) ||
- (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
+ (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485) ||
+ (length > cptr)) {
ath_dbg(common, EEPROM, "Skipping bad header\n");
cptr -= COMP_HDR_LEN;
continue;