Skip to content

Commit

Permalink
ath10k: add sanity check to ie_len before parsing fw/board ie
Browse files Browse the repository at this point in the history
Validate ie_len after the alignment padding before access the buffer
to avoid potential overflow.

Signed-off-by: Ryan Hsu <ryanhsu@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Ryan Hsu authored and Kalle Valo committed Jan 16, 2018
1 parent 3153b68 commit 9ed4f91
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/net/wireless/ath/ath10k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,10 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
len -= sizeof(*hdr);
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",
ie_id, ie_len, len);
ret = -EINVAL;
Expand Down Expand Up @@ -1315,8 +1318,6 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
goto out;
}

/* jump over the padding */
ie_len = ALIGN(ie_len, 4);

len -= ie_len;
data += ie_len;
Expand Down Expand Up @@ -1448,6 +1449,9 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
len -= sizeof(*hdr);
data += sizeof(*hdr);

/* jump over the padding */
ie_len = ALIGN(ie_len, 4);

if (len < ie_len) {
ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n",
ie_id, len, ie_len);
Expand Down Expand Up @@ -1553,9 +1557,6 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
break;
}

/* jump over the padding */
ie_len = ALIGN(ie_len, 4);

len -= ie_len;
data += ie_len;
}
Expand Down

0 comments on commit 9ed4f91

Please sign in to comment.