Skip to contentSkip to conversation

wifi: mwifiex: fix STA cannot connect to AP

PATCH In review David Lin 4 participants 9 messages Dec 8, 2023 – Dec 14, 2023

Subsystems (2)
lore
Share & tools
lore

David Lin

author
#0 lore raw

PATCH v2 1/1 wifi: mwifiex: fix STA cannot connect to AP

AP BSSID configuration is missing at AP start.
Without this fix, FW returns STA interface MAC address after first init. When hostapd restarts, it gets MAC address from netdev before driver sets STA MAC to netdev again. Now MAC address between hostapd and net interface are different causes STA cannot connect to AP. After that MAC address of uap0 mlan0 become the same. And issue disappears after following hostapd restart (another issue is AP/STA MAC address become the same).
This patch fixes the issue cleanly.

Fixes 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers")

---

v2:
- v1 was a not finished patch that was send to the LKML by mistake

---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++
 drivers/net/wireless/marvell/mwifiex/fw.h       | 1 +
 drivers/net/wireless/marvell/mwifiex/ioctl.h    | 1 +
 drivers/net/wireless/marvell/mwifiex/uap_cmd.c  | 8 ++++++++
 4 files changed, 12 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +2 -0
index 7a15ea8072e6..3604abcbcff9 100644
@@ -2047,6 +2047,8 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
 
 	mwifiex_set_sys_config_invalid_data(bss_cfg);
 
+	memcpy(bss_cfg->mac_addr, priv->curr_addr, ETH_ALEN);
+
 	if (params->beacon_interval)
 		bss_cfg->beacon_period = params->beacon_interval;
 	if (params->dtim_period)
drivers/net/wireless/marvell/mwifiex/fw.h +1 -0
index 8e6db904e5b2..62f3c9a52a1d 100644
@@ -165,6 +165,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
 #define TLV_TYPE_STA_MAC_ADDR       (PROPRIETARY_TLV_BASE_ID + 32)
 #define TLV_TYPE_BSSID              (PROPRIETARY_TLV_BASE_ID + 35)
 #define TLV_TYPE_CHANNELBANDLIST    (PROPRIETARY_TLV_BASE_ID + 42)
+#define TLV_TYPE_UAP_MAC_ADDRESS    (PROPRIETARY_TLV_BASE_ID + 43)
 #define TLV_TYPE_UAP_BEACON_PERIOD  (PROPRIETARY_TLV_BASE_ID + 44)
 #define TLV_TYPE_UAP_DTIM_PERIOD    (PROPRIETARY_TLV_BASE_ID + 45)
 #define TLV_TYPE_UAP_BCAST_SSID     (PROPRIETARY_TLV_BASE_ID + 48)
drivers/net/wireless/marvell/mwifiex/ioctl.h +1 -0
index 091e7ca79376..e8825f302de8 100644
@@ -107,6 +107,7 @@ struct mwifiex_uap_bss_param {
 	u8 qos_info;
 	u8 power_constraint;
 	struct mwifiex_types_wmm_info wmm_info;
+	u8 mac_addr[ETH_ALEN];
 };
 
 enum {
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +8 -0
index e78a201cd150..491e36611909 100644
@@ -468,6 +468,7 @@ void mwifiex_config_uap_11d(struct mwifiex_private *priv,
 static int
 mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
 {
+	struct host_cmd_tlv_mac_addr *mac_tlv;
 	struct host_cmd_tlv_dtim_period *dtim_period;
 	struct host_cmd_tlv_beacon_period *beacon_period;
 	struct host_cmd_tlv_ssid *ssid;
@@ -487,6 +488,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
 	int i;
 	u16 cmd_size = *param_size;
 
+	mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv;
+	mac_tlv->header.type = cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS);
+	mac_tlv->header.len = cpu_to_le16(ETH_ALEN);
+	memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN);
+	cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
+	tlv += sizeof(struct host_cmd_tlv_mac_addr);
+
 	if (bss_cfg->ssid.ssid_len) {
 		ssid = (struct host_cmd_tlv_ssid *)tlv;
 		ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID);

base-commit: 783004b6dbda2cfe9a552a4cc9c1d168a2068f6c

Signature · 1 line
2.25.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · David Lin

AP BSSID configuration is missing at AP start.
Without this fix, FW returns STA interface MAC address after first init. When hostapd restarts, it gets MAC address from netdev before driver sets STA MAC to netdev again. Now MAC address between hostapd and net interface are different causes STA cannot connect to AP. After that MAC address of uap0 mlan0 become the same. And issue disappears after following hostapd restart (another issue is AP/STA MAC address become the same).
This patch fixes the issue cleanly.

Quoted 3 lines
Fixes 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers")

Francesco

Tested-by on v2 1/1
#2 lore raw
In reply to David Lin
Quoted 89 lines · David Lin

AP BSSID configuration is missing at AP start.
Without this fix, FW returns STA interface MAC address after first init. When hostapd restarts, it gets MAC address from netdev before driver sets STA MAC to netdev again. Now MAC address between hostapd and net interface are different causes STA cannot connect to AP. After that MAC address of uap0 mlan0 become the same. And issue disappears after following hostapd restart (another issue is AP/STA MAC address become the same).
This patch fixes the issue cleanly.

Fixes 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers")

---

v2:
- v1 was a not finished patch that was send to the LKML by mistake

---
  drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++
  drivers/net/wireless/marvell/mwifiex/fw.h       | 1 +
  drivers/net/wireless/marvell/mwifiex/ioctl.h    | 1 +
  drivers/net/wireless/marvell/mwifiex/uap_cmd.c  | 8 ++++++++
  4 files changed, 12 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +2 -0
index 7a15ea8072e6..3604abcbcff9 100644
@@ -2047,6 +2047,8 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
 
  	mwifiex_set_sys_config_invalid_data(bss_cfg);
 
+	memcpy(bss_cfg->mac_addr, priv->curr_addr, ETH_ALEN);
+
  	if (params->beacon_interval)
  		bss_cfg->beacon_period = params->beacon_interval;
  	if (params->dtim_period)
drivers/net/wireless/marvell/mwifiex/fw.h +1 -0
index 8e6db904e5b2..62f3c9a52a1d 100644
@@ -165,6 +165,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
  #define TLV_TYPE_STA_MAC_ADDR       (PROPRIETARY_TLV_BASE_ID + 32)
  #define TLV_TYPE_BSSID              (PROPRIETARY_TLV_BASE_ID + 35)
  #define TLV_TYPE_CHANNELBANDLIST    (PROPRIETARY_TLV_BASE_ID + 42)
+#define TLV_TYPE_UAP_MAC_ADDRESS    (PROPRIETARY_TLV_BASE_ID + 43)
  #define TLV_TYPE_UAP_BEACON_PERIOD  (PROPRIETARY_TLV_BASE_ID + 44)
  #define TLV_TYPE_UAP_DTIM_PERIOD    (PROPRIETARY_TLV_BASE_ID + 45)
  #define TLV_TYPE_UAP_BCAST_SSID     (PROPRIETARY_TLV_BASE_ID + 48)
drivers/net/wireless/marvell/mwifiex/ioctl.h +1 -0
index 091e7ca79376..e8825f302de8 100644
@@ -107,6 +107,7 @@ struct mwifiex_uap_bss_param {
  	u8 qos_info;
  	u8 power_constraint;
  	struct mwifiex_types_wmm_info wmm_info;
+	u8 mac_addr[ETH_ALEN];
  };
 
  enum {
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +8 -0
index e78a201cd150..491e36611909 100644
@@ -468,6 +468,7 @@ void mwifiex_config_uap_11d(struct mwifiex_private *priv,
  static int
  mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
  {
+	struct host_cmd_tlv_mac_addr *mac_tlv;
  	struct host_cmd_tlv_dtim_period *dtim_period;
  	struct host_cmd_tlv_beacon_period *beacon_period;
  	struct host_cmd_tlv_ssid *ssid;
@@ -487,6 +488,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
  	int i;
  	u16 cmd_size = *param_size;
 
+	mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv;
+	mac_tlv->header.type = cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS);
+	mac_tlv->header.len = cpu_to_le16(ETH_ALEN);
+	memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN);
+	cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
+	tlv += sizeof(struct host_cmd_tlv_mac_addr);
+
  	if (bss_cfg->ssid.ssid_len) {
  		ssid = (struct host_cmd_tlv_ssid *)tlv;
  		ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID);
Quoted 1 line

base-commit: 783004b6dbda2cfe9a552a4cc9c1d168a2068f6c

Rafael

maintainer Acked-by on v2 1/1
#3 lore raw
In reply to David Lin

Hi,

Nitpick: "fix STA cannot connect to AP" isn't the best commit message; that could describe an enormous number of fixes. Maybe something more like "Configure BSSID consistently when starting AP"?

Quoted 10 lines · David Lin

AP BSSID configuration is missing at AP start.
Without this fix, FW returns STA interface MAC address after first init. When hostapd restarts, it gets MAC address from netdev before driver sets STA MAC to netdev again. Now MAC address between hostapd and net interface are different causes STA cannot connect to AP. After that MAC address of uap0 mlan0 become the same. And issue disappears after following hostapd restart (another issue is AP/STA MAC address become the same).
This patch fixes the issue cleanly.

Quoted 8 lines
Fixes 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers")

---

v2:
- v1 was a not finished patch that was send to the LKML by mistake

Looks fine to me:

Quoted 10 lines
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++
 drivers/net/wireless/marvell/mwifiex/fw.h       | 1 +
 drivers/net/wireless/marvell/mwifiex/ioctl.h    | 1 +
 drivers/net/wireless/marvell/mwifiex/uap_cmd.c  | 8 ++++++++
 4 files changed, 12 insertions(+)

drivers/net/wireless/marvell/mwifiex/uap_cmd.c mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) · line 491

Quoted 4 lines
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +1 -0
@@ -487,6 +488,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
 	int i;
 	u16 cmd_size = *param_size;
 
+	mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv;

Not directly related to this patch, but while you're expanding the size of this command buffer: it always felt like a security-hole-in-waiting that none of these command producers do any kinds of bounds checking. We're just "lucky" that these function only generate contents of ~100 bytes at max, while MWIFIEX_SIZE_OF_CMD_BUFFER=2048. But, just add a few more user-space controlled TLV params, and boom, we'll have ourselves a nice little CVE.

It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

	cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
	if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
		return -1;
	// Only touch tlv *after* the bounds check.

That doesn't need to block this patch, of course.

Brian

Quoted 14 lines
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +6 -0
+	mac_tlv->header.type = cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS);
+	mac_tlv->header.len = cpu_to_le16(ETH_ALEN);
+	memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN);
+	cmd_size += sizeof(struct host_cmd_tlyyv_mac_addr);
+	tlv += sizeof(struct host_cmd_tlv_mac_addr);
+
 	if (bss_cfg->ssid.ssid_len) {
 		ssid = (struct host_cmd_tlv_ssid *)tlv;
 		ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID);

base-commit: 783004b6dbda2cfe9a552a4cc9c1d168a2068f6c

Signature · 1 line
2.25.1
author
#4 lore raw
Quoted 14 lines

From: Brian Norris <[email protected]>
Sent: Thursday, December 14, 2023 10:08 AM
To: David Lin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Pete Hsieh <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v2] wifi: mwifiex: fix STA cannot connect to AP

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 5 lines

Hi,

Nitpick: "fix STA cannot connect to AP" isn't the best commit message; that could describe an enormous number of fixes. Maybe something more like "Configure BSSID consistently when starting AP"?

Thanks for your suggestion. I will change commit message as you suggested. Does it mean I should create another patch from v1?

Quoted 54 lines · David Lin
Quoted 4 lines

AP BSSID configuration is missing at AP start.
Without this fix, FW returns STA interface MAC address after first init. When hostapd restarts, it gets MAC address from netdev before driver sets STA MAC to netdev again. Now MAC address between hostapd and

net

Quoted 8 lines

interface are different causes STA cannot connect to AP. After that MAC address of uap0 mlan0 become the same. And issue disappears after following hostapd restart (another issue is AP/STA MAC address become the same).
This patch fixes the issue cleanly.

Fixes 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap
Quoted 7 lines

handlers")
Cc: [email protected]

---

v2:
- v1 was a not finished patch that was send to the LKML by mistake

Looks fine to me:

drivers/net/wireless/marvell/mwifiex/uap_cmd.c mwifiex_uap_bss_param_prepare(u8 *tlv, void

Quoted 10 lines
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++
 drivers/net/wireless/marvell/mwifiex/fw.h       | 1 +
 drivers/net/wireless/marvell/mwifiex/ioctl.h    | 1 +
 drivers/net/wireless/marvell/mwifiex/uap_cmd.c  | 8 ++++++++
 4 files changed, 12 insertions(+)
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +0 -0
@@ -487,6 +488,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void

*cmd_buf, u16 *param_size)

drivers/net/wireless/marvell/mwifiex/uap_cmd.c mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) · line 491

Quoted 4 lines
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +1 -0
      int i;
      u16 cmd_size = *param_size;
 
+     mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv;

Not directly related to this patch, but while you're expanding the size of this command buffer: it always felt like a security-hole-in-waiting that none of these command producers do any kinds of bounds checking.
We're just "lucky" that these function only generate contents of ~100 bytes at max, while MWIFIEX_SIZE_OF_CMD_BUFFER=2048. But, just add a few more user-space controlled TLV params, and boom, we'll have ourselves a nice little CVE.

It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

Quoted 9 lines
        cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
        if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
                return -1;
        // Only touch tlv *after* the bounds check.

That doesn't need to block this patch, of course.

Brian

I will modify the code for next patch.

David

Quoted 15 lines

drivers/net/wireless/marvell/mwifiex/uap_cmd.c mwifiex_uap_bss_param_prepare(u8 *tlv, void · line 492

Quoted 1 line
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +1 -0
+     mac_tlv->header.type =

cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS);

Quoted 13 lines
drivers/net/wireless/marvell/mwifiex/uap_cmd.c +5 -0
+     mac_tlv->header.len = cpu_to_le16(ETH_ALEN);
+     memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN);
+     cmd_size += sizeof(struct host_cmd_tlyyv_mac_addr);
+     tlv += sizeof(struct host_cmd_tlv_mac_addr);
+
      if (bss_cfg->ssid.ssid_len) {
              ssid = (struct host_cmd_tlv_ssid *)tlv;
              ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID);

base-commit: 783004b6dbda2cfe9a552a4cc9c1d168a2068f6c --
2.25.1

#5 lore raw

Hello David,

Quoted 1 line · David Lin
Quoted 1 line

From: Brian Norris <[email protected]>

...

Quoted 6 lines
Quoted 3 lines

Nitpick: "fix STA cannot connect to AP" isn't the best commit message; that could describe an enormous number of fixes. Maybe something more like "Configure BSSID consistently when starting AP"?

Thanks for your suggestion. I will change commit message as you suggested. Does it mean I should create another patch from v1?

Just create [PATCH v3] wifi: mwifiex: fix STA cannot connect to AP

Add the change suggested by Brian and the tags you received on this v2:

- Reviewed-by: Francesco Dolcini <[email protected]>
- Tested-by: Rafael Beims <[email protected]> # Verdin iMX8MP / SD8997 SD
- Acked-by: Brian Norris <[email protected]>

Quoted 16 lines
Quoted 16 lines

Not directly related to this patch, but while you're expanding the size of this command buffer: it always felt like a security-hole-in-waiting that none of these command producers do any kinds of bounds checking.
We're just "lucky" that these function only generate contents of ~100 bytes at max, while MWIFIEX_SIZE_OF_CMD_BUFFER=2048. But, just add a few more user-space controlled TLV params, and boom, we'll have ourselves a nice little CVE.

It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

        cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
        if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
                return -1;
        // Only touch tlv *after* the bounds check.
Quoted 6 lines
Quoted 4 lines

That doesn't need to block this patch, of course.

Brian

I will modify the code for next patch.

I would suggest not modify this in this patch, we should fix all the code that is subjected to this potential issue.

I would personally do a follow-up patch just to add the check to avoid overflowing the cmd buffer everywhere it is used.

Francesco

author
#6 lore raw
Quoted 26 lines

From: Francesco Dolcini <[email protected]>
Sent: Thursday, December 14, 2023 3:35 PM
To: David Lin <[email protected]>
Cc: Brian Norris <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Pete Hsieh <[email protected]>; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] wifi: mwifiex: fix STA cannot connect to AP

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Hello David,

Quoted 1 line · David Lin
Quoted 1 line

From: Brian Norris <[email protected]>

...

Quoted 6 lines
Quoted 3 lines

Nitpick: "fix STA cannot connect to AP" isn't the best commit message; that could describe an enormous number of fixes. Maybe something more like "Configure BSSID consistently when starting AP"?

Thanks for your suggestion. I will change commit message as you suggested. Does it mean I should create another patch from v1?

Quoted 9 lines

Just create [PATCH v3] wifi: mwifiex: fix STA cannot connect to AP

Add the change suggested by Brian and the tags you received on this v2:

- Reviewed-by: Francesco Dolcini <[email protected]>
- Tested-by: Rafael Beims <[email protected]> # Verdin iMX8MP /
SD8997 SD
- Acked-by: Brian Norris <[email protected]>

O.K. Thanks.

Quoted 24 lines
Quoted 3 lines
Quoted 3 lines

Not directly related to this patch, but while you're expanding the size of this command buffer: it always felt like a security-hole-in-waiting that none of these command producers do any

kinds of bounds checking.

Quoted 13 lines
Quoted 13 lines

We're just "lucky" that these function only generate contents of ~100 bytes at max, while MWIFIEX_SIZE_OF_CMD_BUFFER=2048. But, just add a few more user-space controlled TLV params, and boom, we'll have ourselves a nice little CVE.

It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

        cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
        if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
                return -1;
        // Only touch tlv *after* the bounds check.
Quoted 6 lines
Quoted 4 lines

That doesn't need to block this patch, of course.

Brian

I will modify the code for next patch.

Quoted 7 lines

I would suggest not modify this in this patch, we should fix all the code that is subjected to this potential issue.

I would personally do a follow-up patch just to add the check to avoid overflowing the cmd buffer everywhere it is used.

Francesco

O.K. I will only change commit message. In fact, this TLV command is added as the first one command.

maintainer
#7 lore raw
Quoted 17 lines · David Lin
Quoted 17 lines

From: Francesco Dolcini <[email protected]>

Quoted 14 lines · David Lin
Quoted 13 lines

From: Brian Norris <[email protected]>
It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

        cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
        if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
                return -1;
        // Only touch tlv *after* the bounds check.

That doesn't need to block this patch, of course.

Brian

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

I will modify the code for next patch.

I would suggest not modify this in this patch, we should fix all the code that is subjected to this potential issue.

I would personally do a follow-up patch just to add the check to avoid overflowing the cmd buffer everywhere it is used.

Right, there's tons of code that could potentially be affected, and this is definitely a separate patch. (Your feature only adds on to the existing issue, so these are separate logical changes.)

Quoted 1 line

O.K. I will only change commit message. In fact, this TLV command is added as the first one command.

Well, it doesn't really matter than your TLV is "first" -- if there's an overflow, there's an overflow. Maybe the 8 bytes you're adding here are the necessary tipping point. I don't know without doing some kind of informal mathematics/proof.

Brian

author
#8 lore raw
Quoted 44 lines

From: Brian Norris <[email protected]>
Sent: Friday, December 15, 2023 2:52 AM
To: David Lin <[email protected]>
Cc: Francesco Dolcini <[email protected]>; [email protected]; [email protected]; [email protected]; Pete Hsieh <[email protected]>; [email protected]
Subject: Re: [EXT] Re: [PATCH v2] wifi: mwifiex: fix STA cannot connect to AP

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 17 lines · David Lin
Quoted 17 lines

From: Francesco Dolcini <[email protected]>

Quoted 14 lines · David Lin
Quoted 13 lines

From: Brian Norris <[email protected]> It probably wouldn't hurt to significantly write much of this driver, but at a minimum, we could probably use a few checks like this:

        cmd_size += sizeof(struct host_cmd_tlv_mac_addr);
        if (cmd_size > MWIFIEX_SIZE_OF_CMD_BUFFER)
                return -1;
        // Only touch tlv *after* the bounds check.

That doesn't need to block this patch, of course.

Brian

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

I will modify the code for next patch.

I would suggest not modify this in this patch, we should fix all the code that is subjected to this potential issue.

I would personally do a follow-up patch just to add the check to avoid overflowing the cmd buffer everywhere it is used.

Right, there's tons of code that could potentially be affected, and this is definitely a separate patch. (Your feature only adds on to the existing issue, so these are separate logical changes.)

Quoted 1 line

O.K. I will only change commit message. In fact, this TLV command is added

Quoted 8 lines

as the first one command.

Well, it doesn't really matter than your TLV is "first" -- if there's an overflow, there's an overflow. Maybe the 8 bytes you're adding here are the necessary tipping point. I don't know without doing some kind of informal mathematics/proof.

Brian

Understood. Thanks.