Skip to content

Commit 6063490

Browse files
committed
Bluetooth: controller: Check minimum sizes of adv PDUs
While the maximum sizes were already correctly checked by the code, the minimum sizes of the PDUs were not. This meant that PDUs smaller than the minimum required length (typically 6 bytes for AdvA) were incorrectly forwarded up to the Host. Signed-off-by: Carles Cufi <[email protected]> (cherry picked from commit 3f0d701)
1 parent 5e02c0b commit 6063490

File tree

1 file changed

+4
-0
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+4
-0
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
12731273
/* Active scanner */
12741274
} else if (((pdu_adv_rx->type == PDU_ADV_TYPE_ADV_IND) ||
12751275
(pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_IND)) &&
1276+
(pdu_adv_rx->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
12761277
(pdu_adv_rx->len <= sizeof(struct pdu_adv_adv_ind)) &&
12771278
lll->type && !lll->state &&
12781279
#if defined(CONFIG_BT_CENTRAL)
@@ -1365,6 +1366,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
13651366
else if (((((pdu_adv_rx->type == PDU_ADV_TYPE_ADV_IND) ||
13661367
(pdu_adv_rx->type == PDU_ADV_TYPE_NONCONN_IND) ||
13671368
(pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_IND)) &&
1369+
(pdu_adv_rx->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
13681370
(pdu_adv_rx->len <= sizeof(struct pdu_adv_adv_ind))) ||
13691371
((pdu_adv_rx->type == PDU_ADV_TYPE_DIRECT_IND) &&
13701372
(pdu_adv_rx->len == sizeof(struct pdu_adv_direct_ind)) &&
@@ -1379,6 +1381,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
13791381
&dir_report)) ||
13801382
#endif /* CONFIG_BT_CTLR_ADV_EXT */
13811383
((pdu_adv_rx->type == PDU_ADV_TYPE_SCAN_RSP) &&
1384+
(pdu_adv_rx->len >= offsetof(struct pdu_adv_scan_rsp, data)) &&
13821385
(pdu_adv_rx->len <= sizeof(struct pdu_adv_scan_rsp)) &&
13831386
(lll->state != 0U) &&
13841387
isr_scan_rsp_adva_matches(pdu_adv_rx))) &&
@@ -1429,6 +1432,7 @@ static inline bool isr_scan_init_check(const struct lll_scan *lll,
14291432
lll_scan_adva_check(lll, pdu->tx_addr, pdu->adv_ind.addr,
14301433
rl_idx)) &&
14311434
(((pdu->type == PDU_ADV_TYPE_ADV_IND) &&
1435+
(pdu->len >= offsetof(struct pdu_adv_adv_ind, data)) &&
14321436
(pdu->len <= sizeof(struct pdu_adv_adv_ind))) ||
14331437
((pdu->type == PDU_ADV_TYPE_DIRECT_IND) &&
14341438
(pdu->len == sizeof(struct pdu_adv_direct_ind)) &&

0 commit comments

Comments
 (0)