FAILED: patch "[PATCH] wifi: mt76: mt7915: bound the device EEPROM address before" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-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-6.1.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 '2026090457-rental-precise-67a9@gregkh' --subject-prefix 'PATCH 6.1.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: set correct background radar capability
From: StanleyYP Wang <[email protected]>
[ Upstream commit 888208d1ccc41bebe97744445787183b17bb3ea4 ]
Some of the variants do not support background radar, so add a helper to report background radar capability.
For mt7916, only the variant of 5G 2T2R + 1R supports background radar.
Stable-dep-of: 44b5adfe4949 ("wifi: mt76: mt7915: bound the device EEPROM address before the EFUSE copy")
--- .../wireless/mediatek/mt76/mt7915/debugfs.c | 5 +++ .../wireless/mediatek/mt76/mt7915/eeprom.c | 33 ++++++++++++++++++- .../wireless/mediatek/mt76/mt7915/eeprom.h | 1 + .../net/wireless/mediatek/mt76/mt7915/init.c | 7 ++-- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 8 +++-- .../wireless/mediatek/mt76/mt7915/mt7915.h | 3 +- 6 files changed, 49 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +5 -0
@@ -396,6 +396,11 @@ mt7915_rdd_monitor(struct seq_file *s, void *data)mutex_lock (&dev->mt76.mutex); +if (!mt7915_eeprom_has_background_radar (dev)) { +seq_puts (s,"no background radar capability\n" ); + goto out; + } +if (!cfg80211_chandef_valid (chandef)) { ret = -EINVAL ; goto out;
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +32 -1
@@ -123,7 +123,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)/* read eeprom data from efuse */ block_num =DIV_ROUND_UP (eeprom_size, eeprom_blk_size);for (i =0 ; i < block_num; i++) { - ret =mt7915_mcu_get_eeprom (dev, i * eeprom_blk_size); + ret =mt7915_mcu_get_eeprom (dev, i * eeprom_blk_size,NULL );if (ret <0 )return ret; }
@@ -326,6 +326,37 @@ s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band)return val &MT_EE_RATE_DELTA_SIGN ? delta : -delta; } +bool +mt7915_eeprom_has_background_radar (struct mt7915_dev *dev) +{ +u8 val, buf[MT7915_EEPROM_BLOCK_SIZE ]; +u8 band_sel, tx_path, rx_path; +int offs =MT_EE_WIFI_CONF +1 ; + +switch (mt76_chip (&dev->mt76)) { +case 0x7915 : +return true; +case 0x7906 : +/* read efuse to check background radar capability */ +if (mt7915_mcu_get_eeprom (dev, offs, buf)) +break ; + + val = buf[offs %MT7915_EEPROM_BLOCK_SIZE ]; + band_sel =u8_get_bits (val,MT_EE_WIFI_CONF0_BAND_SEL ); + tx_path =u8_get_bits (val,MT_EE_WIFI_CONF0_TX_PATH ); + rx_path =u8_get_bits (val,MT_EE_WIFI_CONF0_RX_PATH ); + +return (band_sel ==MT_EE_V2_BAND_SEL_5GHZ && + tx_path == rx_path && rx_path ==2 ); +case 0x7981 : +case 0x7986 : +default : +break ; + } + +return false; +} +const u8 mt7915_sku_group_len[] = { [SKU_CCK ] =4 , [SKU_OFDM ] =8 ,
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h +1 -0
@@ -45,6 +45,7 @@ enum mt7915_eeprom_field {#define MT_EE_CAL_DPD_SIZE (54 * MT_EE_CAL_UNIT)#define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0) +#define MT_EE_WIFI_CONF0_RX_PATH GENMASK(5, 3)#define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)#define MT_EE_WIFI_CONF1_BAND_SEL GENMASK(7, 6)#define MT_EE_WIFI_CONF_STREAM_NUM GENMASK(7, 5)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +4 -3
@@ -353,9 +353,10 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP );wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_FILS_DISCOVERY ); -if (!mdev->dev->of_node || - !of_property_read_bool (mdev->dev->of_node, -"mediatek,disable-radar-background" )) +if (mt7915_eeprom_has_background_radar (phy->dev) && + (!mdev->dev->of_node || + !of_property_read_bool (mdev->dev->of_node, +"mediatek,disable-radar-background" )))wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_RADAR_BACKGROUND );
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +5 -3
@@ -2745,7 +2745,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,
@@ -2753,8 +2753,8 @@ 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),
@@ -2763,8 +2763,10 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)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 +2 -1
@@ -439,6 +439,7 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev,struct ieee80211_channel *chan, u8 chain_idx);s8 mt7915_eeprom_get_power_delta (struct mt7915_dev *dev,int band); +bool mt7915_eeprom_has_background_radar (struct mt7915_dev *dev);int mt7915_dma_init (struct mt7915_dev *dev,struct mt7915_phy *phy2);void mt7915_dma_prefetch (struct mt7915_dev *dev);void mt7915_dma_cleanup (struct mt7915_dev *dev);
@@ -478,7 +479,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,struct ieee80211_sta *sta, void *data, u32 field);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_get_eeprom_free_block (struct mt7915_dev *dev,u8 *block_num);int mt7915_mcu_set_mac (struct mt7915_dev *dev,int band,bool enable,bool hdr_trans);
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
@@ -2763,8 +2763,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