@@ -1274,6 +1274,9 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
1274
1274
{
1275
1275
struct discovery_state * d = & hdev -> discovery ;
1276
1276
1277
+ if (len > HCI_MAX_AD_LENGTH )
1278
+ return ;
1279
+
1277
1280
bacpy (& d -> last_adv_addr , bdaddr );
1278
1281
d -> last_adv_addr_type = bdaddr_type ;
1279
1282
d -> last_adv_rssi = rssi ;
@@ -5231,7 +5234,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
5231
5234
5232
5235
static void process_adv_report (struct hci_dev * hdev , u8 type , bdaddr_t * bdaddr ,
5233
5236
u8 bdaddr_type , bdaddr_t * direct_addr ,
5234
- u8 direct_addr_type , s8 rssi , u8 * data , u8 len )
5237
+ u8 direct_addr_type , s8 rssi , u8 * data , u8 len ,
5238
+ bool ext_adv )
5235
5239
{
5236
5240
struct discovery_state * d = & hdev -> discovery ;
5237
5241
struct smp_irk * irk ;
@@ -5253,6 +5257,11 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5253
5257
return ;
5254
5258
}
5255
5259
5260
+ if (!ext_adv && len > HCI_MAX_AD_LENGTH ) {
5261
+ bt_dev_err_ratelimited (hdev , "legacy adv larger than 31 bytes" );
5262
+ return ;
5263
+ }
5264
+
5256
5265
/* Find the end of the data in case the report contains padded zero
5257
5266
* bytes at the end causing an invalid length value.
5258
5267
*
@@ -5312,7 +5321,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5312
5321
*/
5313
5322
conn = check_pending_le_conn (hdev , bdaddr , bdaddr_type , type ,
5314
5323
direct_addr );
5315
- if (conn && type == LE_ADV_IND ) {
5324
+ if (! ext_adv && conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH ) {
5316
5325
/* Store report for later inclusion by
5317
5326
* mgmt_device_connected
5318
5327
*/
@@ -5366,7 +5375,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5366
5375
* event or send an immediate device found event if the data
5367
5376
* should not be stored for later.
5368
5377
*/
5369
- if (!has_pending_adv_report (hdev )) {
5378
+ if (!ext_adv && ! has_pending_adv_report (hdev )) {
5370
5379
/* If the report will trigger a SCAN_REQ store it for
5371
5380
* later merging.
5372
5381
*/
@@ -5401,7 +5410,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
5401
5410
/* If the new report will trigger a SCAN_REQ store it for
5402
5411
* later merging.
5403
5412
*/
5404
- if (type == LE_ADV_IND || type == LE_ADV_SCAN_IND ) {
5413
+ if (!ext_adv && (type == LE_ADV_IND ||
5414
+ type == LE_ADV_SCAN_IND )) {
5405
5415
store_pending_adv_report (hdev , bdaddr , bdaddr_type ,
5406
5416
rssi , flags , data , len );
5407
5417
return ;
@@ -5441,7 +5451,7 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5441
5451
rssi = ev -> data [ev -> length ];
5442
5452
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5443
5453
ev -> bdaddr_type , NULL , 0 , rssi ,
5444
- ev -> data , ev -> length );
5454
+ ev -> data , ev -> length , false );
5445
5455
} else {
5446
5456
bt_dev_err (hdev , "Dropping invalid advertising data" );
5447
5457
}
@@ -5515,7 +5525,8 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
5515
5525
if (legacy_evt_type != LE_ADV_INVALID ) {
5516
5526
process_adv_report (hdev , legacy_evt_type , & ev -> bdaddr ,
5517
5527
ev -> bdaddr_type , NULL , 0 , ev -> rssi ,
5518
- ev -> data , ev -> length );
5528
+ ev -> data , ev -> length ,
5529
+ !(evt_type & LE_EXT_ADV_LEGACY_PDU ));
5519
5530
}
5520
5531
5521
5532
ptr += sizeof (* ev ) + ev -> length ;
@@ -5713,7 +5724,8 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
5713
5724
5714
5725
process_adv_report (hdev , ev -> evt_type , & ev -> bdaddr ,
5715
5726
ev -> bdaddr_type , & ev -> direct_addr ,
5716
- ev -> direct_addr_type , ev -> rssi , NULL , 0 );
5727
+ ev -> direct_addr_type , ev -> rssi , NULL , 0 ,
5728
+ false);
5717
5729
5718
5730
ptr += sizeof (* ev );
5719
5731
}
0 commit comments