Commit 9ed4f916 authored by Ryan Hsu's avatar Ryan Hsu Committed by Kalle Valo

ath10k: add sanity check to ie_len before parsing fw/board ie

Validate ie_len after the alignment padding before access the buffer
to avoid potential overflow.
Signed-off-by: default avatarRyan Hsu <ryanhsu@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 3153b68e
...@@ -1276,7 +1276,10 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, ...@@ -1276,7 +1276,10 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
len -= sizeof(*hdr); len -= sizeof(*hdr);
data = hdr->data; data = hdr->data;
if (len < ALIGN(ie_len, 4)) { /* jump over the padding */
ie_len = ALIGN(ie_len, 4);
if (len < ie_len) {
ath10k_err(ar, "invalid length for board ie_id %d ie_len %zu len %zu\n", ath10k_err(ar, "invalid length for board ie_id %d ie_len %zu len %zu\n",
ie_id, ie_len, len); ie_id, ie_len, len);
ret = -EINVAL; ret = -EINVAL;
...@@ -1315,8 +1318,6 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar, ...@@ -1315,8 +1318,6 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
goto out; goto out;
} }
/* jump over the padding */
ie_len = ALIGN(ie_len, 4);
len -= ie_len; len -= ie_len;
data += ie_len; data += ie_len;
...@@ -1448,6 +1449,9 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, ...@@ -1448,6 +1449,9 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
len -= sizeof(*hdr); len -= sizeof(*hdr);
data += sizeof(*hdr); data += sizeof(*hdr);
/* jump over the padding */
ie_len = ALIGN(ie_len, 4);
if (len < ie_len) { if (len < ie_len) {
ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n", ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n",
ie_id, len, ie_len); ie_id, len, ie_len);
...@@ -1553,9 +1557,6 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, ...@@ -1553,9 +1557,6 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
break; break;
} }
/* jump over the padding */
ie_len = ALIGN(ie_len, 4);
len -= ie_len; len -= ie_len;
data += ie_len; data += ie_len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment