Skip to content

Commit 9ed4f91

Browse files
Ryan HsuKalle Valo
authored andcommitted
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: Ryan Hsu <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 3153b68 commit 9ed4f91

File tree

1 file changed

+7
-6
lines changed
  • drivers/net/wireless/ath/ath10k

1 file changed

+7
-6
lines changed

drivers/net/wireless/ath/ath10k/core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,10 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
12761276
len -= sizeof(*hdr);
12771277
data = hdr->data;
12781278

1279-
if (len < ALIGN(ie_len, 4)) {
1279+
/* jump over the padding */
1280+
ie_len = ALIGN(ie_len, 4);
1281+
1282+
if (len < ie_len) {
12801283
ath10k_err(ar, "invalid length for board ie_id %d ie_len %zu len %zu\n",
12811284
ie_id, ie_len, len);
12821285
ret = -EINVAL;
@@ -1315,8 +1318,6 @@ static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
13151318
goto out;
13161319
}
13171320

1318-
/* jump over the padding */
1319-
ie_len = ALIGN(ie_len, 4);
13201321

13211322
len -= ie_len;
13221323
data += ie_len;
@@ -1448,6 +1449,9 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
14481449
len -= sizeof(*hdr);
14491450
data += sizeof(*hdr);
14501451

1452+
/* jump over the padding */
1453+
ie_len = ALIGN(ie_len, 4);
1454+
14511455
if (len < ie_len) {
14521456
ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n",
14531457
ie_id, len, ie_len);
@@ -1553,9 +1557,6 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
15531557
break;
15541558
}
15551559

1556-
/* jump over the padding */
1557-
ie_len = ALIGN(ie_len, 4);
1558-
15591560
len -= ie_len;
15601561
data += ie_len;
15611562
}

0 commit comments

Comments
 (0)