@@ -1338,6 +1338,9 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
1338
1338
{
1339
1339
struct discovery_state * d = & hdev -> discovery ;
1340
1340
1341
+ if (len > HCI_MAX_AD_LENGTH )
1342
+ return ;
1343
+
1341
1344
bacpy (& d -> last_adv_addr , bdaddr );
1342
1345
d -> last_adv_addr_type = bdaddr_type ;
1343
1346
d -> last_adv_rssi = rssi ;
@@ -5355,7 +5358,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
5355
5358
5356
5359
static void process_adv_report (struct hci_dev * hdev , u8 type , bdaddr_t * bdaddr ,
5357
5360
u8 bdaddr_type , bdaddr_t * direct_addr ,
5358
- u8 direct_addr_type , s8 rssi , u8 * data , u8 len )
5361
+ u8 direct_addr_type , s8 rssi , u8 * data , u8 len ,
5362
+ bool ext_adv )
5359
5363
{
5360
5364
struct discovery_state * d = & hdev -> discovery ;
5361
5365
struct smp_irk * irk ;
@@ -5377,6 +5381,11 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5377
5381
return ;
5378
5382
}
5379
5383
5384
+ if (!ext_adv && len > HCI_MAX_AD_LENGTH ) {
5385
+ bt_dev_err_ratelimited (hdev , "legacy adv larger than 31 bytes" );
5386
+ return ;
5387
+ }
5388
+
5380
5389
/* Find the end of the data in case the report contains padded zero
5381
5390
* bytes at the end causing an invalid length value.
5382
5391
*
@@ -5437,7 +5446,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5437
5446
*/
5438
5447
conn = check_pending_le_conn (hdev , bdaddr , bdaddr_type , type ,
5439
5448
direct_addr );
5440
- if (conn && type == LE_ADV_IND ) {
5449
+ if (! ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH ) {
5441
5450
/* Store report for later inclusion by
5442
5451
* mgmt_device_connected
5443
5452
*/
@@ -5491,7 +5500,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5491
5500
* event or send an immediate device found event if the data
5492
5501
* should not be stored for later.
5493
5502
*/
5494
- if (!has_pending_adv_report (hdev )) {
5503
+ if (!ext_adv && ! has_pending_adv_report (hdev )) {
5495
5504
/* If the report will trigger a SCAN_REQ store it for
5496
5505
* later merging.
5497
5506
*/
@@ -5526,7 +5535,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5526
5535
/* If the new report will trigger a SCAN_REQ store it for
5527
5536
* later merging.
5528
5537
*/
5529
- if (type == LE_ADV_IND || type == LE_ADV_SCAN_IND ) {
5538
+ if (!ext_adv && (type == LE_ADV_IND ||
5539
+ type == LE_ADV_SCAN_IND )) {
5530
5540
store_pending_adv_report (hdev , bdaddr , bdaddr_type ,
5531
5541
rssi , flags , data , len );
5532
5542
return ;
@@ -5566,7 +5576,7 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5566
5576
rssi = ev -> data [ev -> length ];
5567
5577
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5568
5578
ev -> bdaddr_type , NULL , 0 , rssi ,
5569
- ev -> data , ev -> length );
5579
+ ev -> data , ev -> length , false );
5570
5580
} else {
5571
5581
bt_dev_err (hdev , "Dropping invalid advertising data" );
5572
5582
}
@@ -5638,7 +5648,8 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5638
5648
if (legacy_evt_type != LE_ADV_INVALID ) {
5639
5649
process_adv_report (hdev , legacy_evt_type , & ev -> bdaddr ,
5640
5650
ev -> bdaddr_type , NULL , 0 , ev -> rssi ,
5641
- ev -> data , ev -> length );
5651
+ ev -> data , ev -> length ,
5652
+ !(evt_type & LE_EXT_ADV_LEGACY_PDU ));
5642
5653
}
5643
5654
5644
5655
ptr += sizeof (* ev ) + ev -> length ;
@@ -5836,7 +5847,8 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
5836
5847
5837
5848
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5838
5849
ev -> bdaddr_type , & ev -> direct_addr ,
5839
- ev -> direct_addr_type , ev -> rssi , NULL , 0 );
5850
+ ev -> direct_addr_type , ev -> rssi , NULL , 0 ,
5851
+ false);
5840
5852
5841
5853
ptr += sizeof (* ev );
5842
5854
}
0 commit comments