Skip to content

Commit 0995ed3

Browse files
cdownopsiff
authored andcommitted
Bluetooth: hci_event: Mask data status from LE ext adv reports
[ Upstream commit 0cadf8534f2a727bc3a01e8c583b085d25963ee0 ] The Event_Type field in an LE Extended Advertising Report uses bits 5 and 6 for data status (e.g. truncation or fragmentation), not the PDU type itself. The ext_evt_type_to_legacy() function fails to mask these status bits before evaluation. This causes valid advertisements with status bits set (e.g. a truncated non-connectable advertisement, which ends up showing as PDU type 0x40) to be misclassified as unknown and subsequently dropped. This is okay for most checks which use bitwise AND on the relevant event type bits, but it doesn't work for non-connectable types, which are checked with '== LE_EXT_ADV_NON_CONN_IND' (that is, zero). In terms of behaviour, first the device sends a truncated report: > HCI Event: LE Meta Event (0x3e) plen 26 LE Extended Advertising Report (0x0d) Entry 0 Event type: 0x0040 Data status: Incomplete, data truncated, no more to come Address type: Random (0x01) Address: 1D:12:46:FA:F8:6E (Non-Resolvable) SID: 0x03 RSSI: -98 dBm (0x9e) Data length: 0x00 Then, a few seconds later, it sends the subsequent complete report: > HCI Event: LE Meta Event (0x3e) plen 122 LE Extended Advertising Report (0x0d) Entry 0 Event type: 0x0000 Data status: Complete Address type: Random (0x01) Address: 1D:12:46:FA:F8:6E (Non-Resolvable) SID: 0x03 RSSI: -97 dBm (0x9f) Data length: 0x60 Service Data: Google (0xfef3) Data[92]: ... These devices often send multiple truncated reports per second. This patch introduces a PDU type mask to ensure only the relevant bits are evaluated, allowing for the correct translation of all valid extended advertising packets. Fixes: b2cc976 ("Bluetooth: Handle extended ADV PDU types") Signed-off-by: Chris Down <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 9d5aecb57e938595321e651c7c0c45398d79f731)
1 parent 6d0d8eb commit 0995ed3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/net/bluetooth/hci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,7 @@ struct hci_ev_le_conn_complete {
25802580
#define LE_EXT_ADV_DIRECT_IND 0x0004
25812581
#define LE_EXT_ADV_SCAN_RSP 0x0008
25822582
#define LE_EXT_ADV_LEGACY_PDU 0x0010
2583+
#define LE_EXT_ADV_DATA_STATUS_MASK 0x0060
25832584
#define LE_EXT_ADV_EVT_TYPE_MASK 0x007f
25842585

25852586
#define ADDR_LE_DEV_PUBLIC 0x00

net/bluetooth/hci_event.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6216,6 +6216,11 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data,
62166216

62176217
static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)
62186218
{
6219+
u16 pdu_type = evt_type & ~LE_EXT_ADV_DATA_STATUS_MASK;
6220+
6221+
if (!pdu_type)
6222+
return LE_ADV_NONCONN_IND;
6223+
62196224
if (evt_type & LE_EXT_ADV_LEGACY_PDU) {
62206225
switch (evt_type) {
62216226
case LE_LEGACY_ADV_IND:
@@ -6247,8 +6252,7 @@ static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)
62476252
if (evt_type & LE_EXT_ADV_SCAN_IND)
62486253
return LE_ADV_SCAN_IND;
62496254

6250-
if (evt_type == LE_EXT_ADV_NON_CONN_IND ||
6251-
evt_type & LE_EXT_ADV_DIRECT_IND)
6255+
if (evt_type & LE_EXT_ADV_DIRECT_IND)
62526256
return LE_ADV_NONCONN_IND;
62536257

62546258
invalid:

0 commit comments

Comments
 (0)