FAILED: patch "[PATCH] wifi: mt76: mt7915: bound the device EEPROM address before" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 44b5adfe49499f53002737f5fe81d608c08122fc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090458-regroup-wildfire-fd26@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 44b5adfe49499f53002737f5fe81d608c08122fc Mon Sep 17 00:00:00 2001
From: Bryam Vargas <[email protected]>
Date: Thu, 25 Jun 2026 07:10:26 -0500
Subject: [PATCH] wifi: mt76: mt7915: bound the device EEPROM address before
the EFUSE copy
mt7915_mcu_get_eeprom() copies a fixed EFUSE block into the driver's dev->mt76.eeprom.data buffer at the offset reported by the MCU response (res->addr, a device-controlled __le32) without checking it against the buffer size. A malicious or malfunctioning device can report an arbitrary address and drive a 16-byte out-of-bounds write past eeprom.data.
Reject a response whose address would place the copy outside eeprom.data before deriving the destination pointer. Devices that echo the requested in-bounds offset are unaffected.
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +9 -2
@@ -2917,8 +2917,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)return ret; res = (struct mt7915_mcu_eeprom_info *)skb->data; -if (!buf) - buf = dev->mt76.eeprom.data +le32_to_cpu (res->addr); +if (!buf) { +u32 addr =le32_to_cpu (res->addr); + +if (addr > dev->mt76.eeprom.size -MT7915_EEPROM_BLOCK_SIZE ) { +dev_kfree_skb (skb); +return -EINVAL ; + } + buf = dev->mt76.eeprom.data + addr; + }memcpy (buf, res->data,MT7915_EEPROM_BLOCK_SIZE );dev_kfree_skb (skb);
Sasha Levin
maintainerPATCH 1/2 wifi: mt76: mt7915: check return value before accessing free_block_num
From: Ryder Lee <[email protected]>
[ Upstream commit 59b27a7d472f100ac8998e15a63c47a03cced12a ]
Check return value of mt7915_mcu_get_eeprom_free_block() first before accessing free_block_num.
Backport to 5.15 as a dependency of44b5adfe49499f53002737f5fe81d608c08122fc.
The stable driver has neither the default-calibration fallback nor mt7915_mcu_get_eeprom_free_block(), so omit the free-block query and its formatting hunk. Retain the per-block EEPROM read error checks, using the stable tree's fixed MT7915_EEPROM_SIZE. This also propagates the target's invalid-address error out of EEPROM initialization.
Bring over only the existing EEPROM read function's optional read_buf argument and buffer selection from 888208d1ccc41, updating its declaration and sole caller to pass NULL. This preserves normal EEPROM reads and provides the exact context needed by the target's bounds-check hunk, without adding functions or importing background-radar support.
Stable-dep-of: 44b5adfe4949 ("wifi: mt76: mt7915: bound the device EEPROM address before the EFUSE copy")
--- drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 14 ++++++++------ drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 13 ++++++++----- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +8 -6
@@ -34,12 +34,14 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev) ret =mt7915_eeprom_load_precal (dev); }else {u32 block_num, i; - - block_num =DIV_ROUND_UP (MT7915_EEPROM_SIZE , -MT7915_EEPROM_BLOCK_SIZE ); -for (i =0 ; i < block_num; i++) -mt7915_mcu_get_eeprom (dev, - i *MT7915_EEPROM_BLOCK_SIZE ); +u32 eeprom_blk_size =MT7915_EEPROM_BLOCK_SIZE ; + + block_num =DIV_ROUND_UP (MT7915_EEPROM_SIZE , eeprom_blk_size); +for (i =0 ; i < block_num; i++) { + ret =mt7915_mcu_get_eeprom (dev, i * eeprom_blk_size,NULL ); +if (ret <0 ) +return ret; + } }return ret;
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +8 -5
@@ -3449,7 +3449,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev) &req, sizeof(req), true); } -int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) +int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf) { struct mt7915_mcu_eeprom_info req = { .addr = cpu_to_le32(round_down(offset,
@@ -3457,17 +3457,20 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) };struct mt7915_mcu_eeprom_info *res;struct sk_buff *skb; +u8 *buf = read_buf;int ret; -u8 *buf; - ret =mt76_mcu_send_and_get_msg (&dev->mt76,MCU_EXT_QUERY (EFUSE_ACCESS ), &req, -sizeof (req), true, &skb); + ret =mt76_mcu_send_and_get_msg (&dev->mt76, +MCU_EXT_QUERY (EFUSE_ACCESS ), + &req,sizeof (req), true, &skb);if (ret)return ret; res = (struct mt7915_mcu_eeprom_info *)skb->data; - buf = dev->mt76.eeprom.data +le32_to_cpu (res->addr); +if (!buf) + buf = dev->mt76.eeprom.data +le32_to_cpu (res->addr);memcpy (buf, res->data,MT7915_EEPROM_BLOCK_SIZE ); +dev_kfree_skb (skb);return 0 ;
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -1
@@ -344,7 +344,7 @@ int mt7915_mcu_update_edca(struct mt7915_dev *dev, void *req);int mt7915_mcu_set_fixed_rate (struct mt7915_dev *dev,struct ieee80211_sta *sta,u32 rate);int mt7915_mcu_set_eeprom (struct mt7915_dev *dev); -int mt7915_mcu_get_eeprom (struct mt7915_dev *dev,u32 offset); +int mt7915_mcu_get_eeprom (struct mt7915_dev *dev,u32 offset,u8 *read_buf);int mt7915_mcu_set_mac (struct mt7915_dev *dev,int band,bool enable,bool hdr_trans); int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 wifi: mt76: mt7915: bound the device EEPROM address before the EFUSE copy
From: Bryam Vargas <[email protected]>
[ Upstream commit 44b5adfe49499f53002737f5fe81d608c08122fc ]
mt7915_mcu_get_eeprom() copies a fixed EFUSE block into the driver's dev->mt76.eeprom.data buffer at the offset reported by the MCU response (res->addr, a device-controlled __le32) without checking it against the buffer size. A malicious or malfunctioning device can report an arbitrary address and drive a 16-byte out-of-bounds write past eeprom.data.
Reject a response whose address would place the copy outside eeprom.data before deriving the destination pointer. Devices that echo the requested in-bounds offset are unaffected.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +9 -2
@@ -3467,8 +3467,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)return ret; res = (struct mt7915_mcu_eeprom_info *)skb->data; -if (!buf) - buf = dev->mt76.eeprom.data +le32_to_cpu (res->addr); +if (!buf) { +u32 addr =le32_to_cpu (res->addr); + +if (addr > dev->mt76.eeprom.size -MT7915_EEPROM_BLOCK_SIZE ) { +dev_kfree_skb (skb); +return -EINVAL ; + } + buf = dev->mt76.eeprom.data + addr; + }memcpy (buf, res->data,MT7915_EEPROM_BLOCK_SIZE );dev_kfree_skb (skb);
Signature · 1 line
2.53.0