Skip to contentSkip to conversation

wifi: wlcore/wl18xx: firmware trust boundary hardening

PATCH In review Tristan Madani 1 participant 5 messages Apr 21 – May 4 1 message not in the archive TI wilink wireless drivers

lore
Share & tools
lore
#0 lore raw

v3 cover wifi: wlcore/wl18xx: firmware trust boundary hardening

From: Tristan Madani <[email protected]>

This series adds missing bounds checks for firmware-controlled fields in the TI wlcore and wl18xx drivers.

Patches cover: BA event link_id, logger max_buff_size, and smart config SSID/password lengths.

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

Changes in v2:
- No code changes from v1.

Tristan Madani (3):
wifi: wl18xx: fix OOB read from firmware rx_ba_link_id in BA event
handler
wifi: wlcore: fix OOB read from firmware max_buff_size in logger
handler
wifi: wl18xx: fix OOB read from firmware SSID/password lengths in
smart config event

 drivers/net/wireless/ti/wl18xx/event.c | 9 +++++++++
 drivers/net/wireless/ti/wlcore/event.c | 7 +++++++
 2 files changed, 16 insertions(+)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/3 wifi: wl18xx: fix OOB read from firmware rx_ba_link_id in BA event handler

From: Tristan Madani <[email protected]>

The firmware-controlled rx_ba_link_id (u8) is used to index the 16-entry wl->links[] array without bounds checking in the BA window size change event handler. An out-of-range value causes OOB reads and an immediate pointer dereference of the OOB wlvif field.

Add bounds validation consistent with all other HLID consumers in the driver.

Fixes d4392269f7ce ("wlcore: Add RX_BA_WIN_SIZE_CHANGE_EVENT event")

---
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/ti/wl18xx/event.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/wireless/ti/wl18xx/event.c +6 -0
index a9f090e15cbbe..fac12a8590355 100644
@@ -212,6 +212,12 @@ int wl18xx_process_mailbox_events(struct wl1271 *wl)
 		u8 win_size = mbox->rx_ba_win_size;
 		const u8 *addr;
 
+		if (link_id >= WLCORE_MAX_LINKS) {
+			wl1271_error("BA event: invalid link_id %u\n",
+				     link_id);
+			goto out;
+		}
+
 		wlvif = wl->links[link_id].wlvif;
 		vif = wl12xx_wlvif_to_vif(wlvif);
 
Signature · 1 line
2.47.3
#2 lore raw

PATCH v3 2/3 wifi: wlcore: fix OOB read from firmware max_buff_size in logger handler

In reply to Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled max_buff_size field is used to compute buffer offsets in wlcore_event_fw_logger() without validation against the 4128-byte kernel allocation. An inflated value causes out-of-bounds reads from kernel heap, with the data written to the debugfs-accessible fwlog ring buffer.

Cap max_buff_size at the allocation size minus the header offset.

Fixes 3719c17e1816 ("wlcore/wl18xx: fw logger over sdio")

---
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/ti/wlcore/event.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/wireless/ti/wlcore/event.c +7 -0
index 6c3a8ea9613e9..26c74dfcaeeff 100644
@@ -61,6 +61,13 @@ int wlcore_event_fw_logger(struct wl1271 *wl)
 	if (actual_len == 0)
 		goto free_out;
 
+	if (le32_to_cpu(fw_log.max_buff_size) >
+	    WL18XX_LOGGER_SDIO_BUFF_MAX - WL18XX_LOGGER_BUFF_OFFSET) {
+		wl1271_error("fw logger: max_buff_size %u exceeds buffer\n",
+			     le32_to_cpu(fw_log.max_buff_size));
+		goto free_out;
+	}
+
 	/* Calculate the internal pointer to the fwlog structure */
 	addr_ptr = internal_fw_addrbase + addr;
 
Signature · 1 line
2.47.3
#3 lore raw

PATCH v3 3/3 wifi: wl18xx: fix OOB read from firmware SSID/password lengths in smart config event

In reply to Tristan Madani

From: Tristan Madani <[email protected]>

The firmware-controlled sc_ssid_len and sc_pwd_len values are used as nla_put sizes from fixed-size mailbox buffers (32 and 64 bytes) without bounds checking. Values exceeding the buffer sizes cause out-of-bounds reads delivered to userspace via nl80211 vendor events.

Clamp the lengths to the mailbox buffer sizes before use.

Fixes e93e15fb47e5 ("wlcore/wl18xx: handle smart config events")

---
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/ti/wl18xx/event.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/ti/wl18xx/event.c +3 -0
index fac12a8590355..19c7f5bdada5e 100644
@@ -82,6 +82,9 @@ static int wlcore_smart_config_decode_event(struct wl1271 *wl,
 {
 	struct sk_buff *skb;
 
+	ssid_len = min_t(u8, ssid_len, 32);
+	pwd_len = min_t(u8, pwd_len, 64);
+
 	wl1271_debug(DEBUG_EVENT, "SMART_CONFIG_DECODE_EVENT_ID");
 	wl1271_dump_ascii(DEBUG_EVENT, "SSID:", ssid, ssid_len);
 
Signature · 1 line
2.47.3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Hi Peter,

Thanks for the pointer. I took a look at the TI forum thread -- the TSF instability and kernel oops on debugfs read look like a different class of issue from what this series addresses. These patches specifically guard against out-of-bounds access from firmware-supplied index/length fields (BA link_id, logger buffer size, smart config strings), so they would not directly help with a TSF read race or firmware timing problem.

That said, the oops trace from the forum post might be worth a separate look if it is still reproducible on a current kernel.

Thanks,
Best,
Tristan