Skip to contentSkip to conversation

wifi: ath10k: validate skb length for WMI mgmt rx ext_info

PATCH New Tanuj Sharma 1 participant 1 message Nov 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: ath10k: validate skb length for WMI mgmt rx ext_info

When the WMI_RX_STATUS_EXT_INFO flag is set in a management frame rx event, ath10k reads sizeof(struct wmi_mgmt_rx_ext_info) (8 bytes) starting at ALIGN(msdu_len, 4) from the skb. However, the bounds check only validates that skb->len >= msdu_len, not that the skb is large enough for the aligned offset plus the ext_info struct.

If msdu_len is close to skb->len (e.g., msdu_len=99, skb->len=99), ALIGN(99, 4)=100, and the 8-byte ext_info read accesses bytes [100..107], up to 9 bytes past the validated region.

Add a bounds check ensuring skb->len is large enough for the aligned buffer length plus the ext_info struct before accessing it. Both ath10k_wmi_op_pull_mgmt_rx_ev() and ath10k_wmi_10_4_op_pull_mgmt_rx_ev() are fixed.

Fixes 7d5efd088833 ("ath10k: parse Rx MAC timestamp in mgmt frame for FW 10.4")
---
 drivers/net/wireless/ath/ath10k/wmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +4 -0
index e57588c..91142ab 100644
@@ -2346,6 +2346,8 @@ static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
 
 	if (le32_to_cpu(arg->status) & WMI_RX_STATUS_EXT_INFO) {
 		len = ALIGN(le32_to_cpu(arg->buf_len), 4);
+		if (skb->len < len + sizeof(struct wmi_mgmt_rx_ext_info))
+			return -EPROTO;
 		ext_info = (struct wmi_mgmt_rx_ext_info *)(skb->data + len);
 		memcpy(&arg->ext_info, ext_info,
 		       sizeof(struct wmi_mgmt_rx_ext_info));
@@ -2390,6 +2392,8 @@ static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
 
 	if (le32_to_cpu(arg->status) & WMI_RX_STATUS_EXT_INFO) {
 		len = ALIGN(le32_to_cpu(arg->buf_len), 4);
+		if (skb->len < len + sizeof(struct wmi_mgmt_rx_ext_info))
+			return -EPROTO;
 		ext_info = (struct wmi_mgmt_rx_ext_info *)(skb->data + len);
 		memcpy(&arg->ext_info, ext_info,
 		       sizeof(struct wmi_mgmt_rx_ext_info));
Signature · 1 line
2.43.0