Skip to contentSkip to conversation

wifi: ath6kl: firmware trust boundary hardening

PATCH Applied Tristan Madani 3 participants 9 messages Apr 21 – Jul 26 1 message not in the archive

Subsystems (2)

v3 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover wifi: ath6kl: firmware trust boundary hardening

From: Tristan Madani <[email protected]>

This series adds missing bounds checks for firmware-controlled fields in the Qualcomm ath6kl driver.

Patch 1 returns early on invalid ADDBA window size. Patch 2 validates connect event IE lengths. Patch 3 checks TX complete handler num_msg.

Changes in v3:
- Regenerated from wireless-next with proper git format-patch.

Changes in v2:
- No code changes from v1.

Tristan Madani (3):
wifi: ath6kl: fix OOB access from firmware ADDBA window size
wifi: ath6kl: fix OOB read from firmware IE lengths in connect event
wifi: ath6kl: fix OOB read from firmware num_msg in TX complete
handler

 drivers/net/wireless/ath/ath6kl/txrx.c |  4 +++-
 drivers/net/wireless/ath/ath6kl/wmi.c  | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/3 wifi: ath6kl: fix OOB access from firmware ADDBA window size

From: Tristan Madani <[email protected]>

aggr_recv_addba_req_evt() logs a debug message when the firmware-supplied win_sz is outside [AGGR_WIN_SZ_MIN, AGGR_WIN_SZ_MAX] but does not return. The out-of-range win_sz is then used in TID_WINDOW_SZ() to compute a kzalloc size and stored in rxtid->hold_q_sz, leading to zero-size or overflowed allocations and subsequent OOB access.

Return early when win_sz is out of the valid range.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

 drivers/net/wireless/ath/ath6kl/txrx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/txrx.c +3 -1
index 97fdac7237e26..5575b535f94cd 100644
@@ -1723,9 +1723,11 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no,
 
 	rxtid = &aggr_conn->rx_tid[tid];
 
-	if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX)
+	if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) {
 		ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n",
 			   __func__, win_sz, tid);
+		return;
+	}
 
 	if (rxtid->aggr)
 		aggr_delete_tid_state(aggr_conn, tid);
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH v3 1/3] wifi: ath6kl: fix OOB access from firmware ADDBA window size

Quoted 28 lines · Tristan Madani

From: Tristan Madani <[email protected]>

aggr_recv_addba_req_evt() logs a debug message when the firmware-supplied win_sz is outside [AGGR_WIN_SZ_MIN, AGGR_WIN_SZ_MAX] but does not return. The out-of-range win_sz is then used in TID_WINDOW_SZ() to compute a kzalloc size and stored in rxtid->hold_q_sz, leading to zero-size or overflowed allocations and subsequent OOB access.

Return early when win_sz is out of the valid range.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

  drivers/net/wireless/ath/ath6kl/txrx.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/txrx.c +0 -0
index 97fdac7237e26..5575b535f94cd 100644

drivers/net/wireless/ath/ath6kl/txrx.c void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, · line 1730

Quoted 9 lines
drivers/net/wireless/ath/ath6kl/txrx.c +3 -1
@@ -1723,9 +1723,11 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no,
 
  	rxtid = &aggr_conn->rx_tid[tid];
 
-	if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX)
+	if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) {
  		ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n",
  			   __func__, win_sz, tid);
+		return;
+	}

I think, before returning, it makes sense to clean up the previously active session also upon an event with unexpected aggregation window size for the tid.

Vasanth

#3 lore raw

PATCH v3 2/3 wifi: ath6kl: fix OOB read from firmware IE lengths in connect event

In reply to Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled beacon_ie_len, assoc_req_len, and assoc_resp_len fields in ath6kl_wmi_connect_event_rx() are not validated against the buffer length. Their sum (up to 765) can exceed the actual WMI event data, causing out-of-bounds reads during IE parsing and state corruption of wmi->is_wmm_enabled.

Add a check that the total IE length fits within the buffer.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

 drivers/net/wireless/ath/ath6kl/wmi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +8 -0
index 72611a2ceb9d8..1cafbac2938fe 100644
@@ -862,6 +862,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
 
 	ev = (struct wmi_connect_event *) datap;
 
+	if (len < sizeof(*ev) + ev->beacon_ie_len +
+	    ev->assoc_req_len + ev->assoc_resp_len) {
+		ath6kl_dbg(ATH6KL_DBG_WMI,
+			   "connect event: IE lengths %u+%u+%u exceed buffer %d\n",
+			   ev->beacon_ie_len, ev->assoc_req_len,
+			   ev->assoc_resp_len, len);
+		return -EINVAL;
+	}
 	if (vif->nw_type == AP_NETWORK) {
 		/* AP mode start/STA connected event */
 		struct net_device *dev = vif->ndev;
Signature · 1 line
2.47.3
Reviewed-by on v3 2/3
#4 lore raw

Re: [PATCH v3 2/3] wifi: ath6kl: fix OOB read from firmware IE lengths in connect event

Quoted 32 lines · Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled beacon_ie_len, assoc_req_len, and assoc_resp_len fields in ath6kl_wmi_connect_event_rx() are not validated against the buffer length. Their sum (up to 765) can exceed the actual WMI event data, causing out-of-bounds reads during IE parsing and state corruption of wmi->is_wmm_enabled.

Add a check that the total IE length fits within the buffer.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

  drivers/net/wireless/ath/ath6kl/wmi.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +1 -0
index 72611a2ceb9d8..1cafbac2938fe 100644
@@ -862,6 +862,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
 
  	ev = (struct wmi_connect_event *) datap;
 
+	if (len < sizeof(*ev) + ev->beacon_ie_len +

drivers/net/wireless/ath/ath6kl/wmi.c static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, · line 875

Quoted 10 lines
drivers/net/wireless/ath/ath6kl/wmi.c +7 -0
+	    ev->assoc_req_len + ev->assoc_resp_len) {
+		ath6kl_dbg(ATH6KL_DBG_WMI,
+			   "connect event: IE lengths %u+%u+%u exceed buffer %d\n",
+			   ev->beacon_ie_len, ev->assoc_req_len,
+			   ev->assoc_resp_len, len);
+		return -EINVAL;
+	}
  	if (vif->nw_type == AP_NETWORK) {
  		/* AP mode start/STA connected event */
  		struct net_device *dev = vif->ndev;

A message that is not in the archive (sent off-list or not yet received): 2714a585c88febf28ef49cbc39f2c14dbcc15183.1785006304.git.peak@peaktwilight.com

#6 lore raw

Re: [PATCH] wifi: ath6kl: prevent assoc info length underflow

Quoted 21 lines · Doruk Tan Ozturk

The WMI connect event carries association request and response lengths as u8. ath6kl_cfg80211_connect_event() subtracts their 4- and 6-byte fixed headers without a lower-bound check. A shorter frame wraps the resulting IE length and lets cfg80211 copy beyond assoc_info.

Clamp both lengths to their respective fixed header sizes before subtracting, so short frames provide no IEs.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath6kl/cfg80211.c +0 -0
index cc0f2c45fc..62f663c0da 100644
@@ -754,6 +754,11 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
 	u8 *assoc_resp_ie = assoc_info + beacon_ie_len + assoc_req_len +

drivers/net/wireless/ath/ath6kl/cfg80211.c void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, · line 764

Quoted 10 lines
drivers/net/wireless/ath/ath6kl/cfg80211.c +5 -0
 	    assoc_resp_ie_offset;
 
+	if (assoc_req_len < assoc_req_ie_offset)
+		assoc_req_len = assoc_req_ie_offset;
+	if (assoc_resp_len < assoc_resp_ie_offset)
+		assoc_resp_len = assoc_resp_ie_offset;
+
 	assoc_req_len -= assoc_req_ie_offset;
 	assoc_resp_len -= assoc_resp_ie_offset;
 

The actual patch looks identical to
https://lore.kernel.org/linux-wireless/[email protected]/

Why repost with different commit text? Should I drop the former one and pick this one up?

/jeff

#7 lore raw

PATCH v3 3/3 wifi: ath6kl: fix OOB read from firmware num_msg in TX complete handler

In reply to Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled num_msg field (u8, 0-255) drives the loop in ath6kl_wmi_tx_complete_event_rx() without validation against the buffer length. This allows out-of-bounds reads of up to 1020 bytes past the WMI event buffer when the firmware sends an inflated num_msg.

Add a check that the buffer is large enough to hold num_msg entries.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

 drivers/net/wireless/ath/ath6kl/wmi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +6 -0
index 1cafbac2938fe..f56722c5ef5f1 100644
@@ -484,6 +484,12 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
 
 	evt = (struct wmi_tx_complete_event *) datap;
 
+	if (len < sizeof(*evt) ||
+	    len < sizeof(*evt) + evt->num_msg * sizeof(struct tx_complete_msg_v1)) {
+		ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d for %u msgs\n",
+			   len, evt->num_msg);
+		return -EINVAL;
+	}
 	ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
 		   evt->num_msg, evt->msg_len, evt->msg_type);
 
Signature · 1 line
2.47.3
#8 lore raw

Re: [PATCH v3 3/3] wifi: ath6kl: fix OOB read from firmware num_msg in TX complete handler

Quoted 27 lines · Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled num_msg field (u8, 0-255) drives the loop in ath6kl_wmi_tx_complete_event_rx() without validation against the buffer length. This allows out-of-bounds reads of up to 1020 bytes past the WMI event buffer when the firmware sends an inflated num_msg.

Add a check that the buffer is large enough to hold num_msg entries.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
Changes in v3:
- Regenerated from wireless-next with proper git format-patch to produce valid index hashes (v2 had post-processed index lines).

Changes in v2:
- No code changes from v1.

 drivers/net/wireless/ath/ath6kl/wmi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +0 -0
index 1cafbac2938fe..f56722c5ef5f1 100644

drivers/net/wireless/ath/ath6kl/wmi.c static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) · line 490

Quoted 7 lines
drivers/net/wireless/ath/ath6kl/wmi.c +4 -0
@@ -484,6 +484,12 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
 
 	evt = (struct wmi_tx_complete_event *) datap;
 
+	if (len < sizeof(*evt) ||
+	    len < sizeof(*evt) + evt->num_msg * sizeof(struct tx_complete_msg_v1)) {
+		ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d for %u msgs\n",
+			   len, evt->num_msg);

In the case where the first test is true, the logging of evt->num_msg will still overread the buffer.

I think the logic would be more clear if it follows the pattern in the 2/3 patch, first validate the fixed portion of the struct is available, and then separately validate the variable portion of the struct is available:

	if (len < sizeof(*evt) {
		ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d\n",
			   len);
		return -EINVAL;
	}
		
	if (len < sizeof(*evt) + evt->num_msg * sizeof(struct tx_complete_msg_v1)) {
		ath6kl_dbg(ATH6KL_DBG_WMI, "tx complete: invalid len %d for %u msgs\n",
			   len, evt->num_msg);
		return -EINVAL;
	}
Quoted 3 lines
drivers/net/wireless/ath/ath6kl/wmi.c +0 -0
 	ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
 		   evt->num_msg, evt->msg_len, evt->msg_type);
 
Applied
#9 lore raw

Re: (subset) [PATCH v3 0/3] wifi: ath6kl: firmware trust boundary hardening

In reply to Tristan Madani
Quoted 9 lines · Tristan Madani

From: Tristan Madani <[email protected]>

This series adds missing bounds checks for firmware-controlled fields in the Qualcomm ath6kl driver.

Patch 1 returns early on invalid ADDBA window size. Patch 2 validates connect event IE lengths. Patch 3 checks TX complete handler num_msg.

[...]

Applied, thanks!

[2/3] wifi: ath6kl: fix OOB read from firmware IE lengths in connect event

      commit: 6b47b29730de3232b919d8362749f6814c5f2a33

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>