@@ -1305,6 +1305,9 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
1305
1305
{
1306
1306
struct discovery_state * d = & hdev -> discovery ;
1307
1307
1308
+ if (len > HCI_MAX_AD_LENGTH )
1309
+ return ;
1310
+
1308
1311
bacpy (& d -> last_adv_addr , bdaddr );
1309
1312
d -> last_adv_addr_type = bdaddr_type ;
1310
1313
d -> last_adv_rssi = rssi ;
@@ -5317,7 +5320,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
5317
5320
5318
5321
static void process_adv_report (struct hci_dev * hdev , u8 type , bdaddr_t * bdaddr ,
5319
5322
u8 bdaddr_type , bdaddr_t * direct_addr ,
5320
- u8 direct_addr_type , s8 rssi , u8 * data , u8 len )
5323
+ u8 direct_addr_type , s8 rssi , u8 * data , u8 len ,
5324
+ bool ext_adv )
5321
5325
{
5322
5326
struct discovery_state * d = & hdev -> discovery ;
5323
5327
struct smp_irk * irk ;
@@ -5339,6 +5343,11 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5339
5343
return ;
5340
5344
}
5341
5345
5346
+ if (!ext_adv && len > HCI_MAX_AD_LENGTH ) {
5347
+ bt_dev_err_ratelimited (hdev , "legacy adv larger than 31 bytes" );
5348
+ return ;
5349
+ }
5350
+
5342
5351
/* Find the end of the data in case the report contains padded zero
5343
5352
* bytes at the end causing an invalid length value.
5344
5353
*
@@ -5398,7 +5407,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5398
5407
*/
5399
5408
conn = check_pending_le_conn (hdev , bdaddr , bdaddr_type , type ,
5400
5409
direct_addr );
5401
- if (conn && type == LE_ADV_IND ) {
5410
+ if (! ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH ) {
5402
5411
/* Store report for later inclusion by
5403
5412
* mgmt_device_connected
5404
5413
*/
@@ -5452,7 +5461,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5452
5461
* event or send an immediate device found event if the data
5453
5462
* should not be stored for later.
5454
5463
*/
5455
- if (!has_pending_adv_report (hdev )) {
5464
+ if (!ext_adv && ! has_pending_adv_report (hdev )) {
5456
5465
/* If the report will trigger a SCAN_REQ store it for
5457
5466
* later merging.
5458
5467
*/
@@ -5487,7 +5496,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5487
5496
/* If the new report will trigger a SCAN_REQ store it for
5488
5497
* later merging.
5489
5498
*/
5490
- if (type == LE_ADV_IND || type == LE_ADV_SCAN_IND ) {
5499
+ if (!ext_adv && (type == LE_ADV_IND ||
5500
+ type == LE_ADV_SCAN_IND )) {
5491
5501
store_pending_adv_report (hdev , bdaddr , bdaddr_type ,
5492
5502
rssi , flags , data , len );
5493
5503
return ;
@@ -5527,7 +5537,7 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5527
5537
rssi = ev -> data [ev -> length ];
5528
5538
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5529
5539
ev -> bdaddr_type , NULL , 0 , rssi ,
5530
- ev -> data , ev -> length );
5540
+ ev -> data , ev -> length , false );
5531
5541
} else {
5532
5542
bt_dev_err (hdev , "Dropping invalid advertising data" );
5533
5543
}
@@ -5599,7 +5609,8 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5599
5609
if (legacy_evt_type != LE_ADV_INVALID ) {
5600
5610
process_adv_report (hdev , legacy_evt_type , & ev -> bdaddr ,
5601
5611
ev -> bdaddr_type , NULL , 0 , ev -> rssi ,
5602
- ev -> data , ev -> length );
5612
+ ev -> data , ev -> length ,
5613
+ !(evt_type & LE_EXT_ADV_LEGACY_PDU ));
5603
5614
}
5604
5615
5605
5616
ptr += sizeof (* ev ) + ev -> length ;
@@ -5797,7 +5808,8 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
5797
5808
5798
5809
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5799
5810
ev -> bdaddr_type , & ev -> direct_addr ,
5800
- ev -> direct_addr_type , ev -> rssi , NULL , 0 );
5811
+ ev -> direct_addr_type , ev -> rssi , NULL , 0 ,
5812
+ false);
5801
5813
5802
5814
ptr += sizeof (* ev );
5803
5815
}
0 commit comments