linux-stable/net/bluetooth
Chris Down 9d5aecb57e Bluetooth: hci_event: Mask data status from LE ext adv reports
[ Upstream commit 0cadf8534f ]

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: b2cc9761f1 ("Bluetooth: Handle extended ADV PDU types")
Signed-off-by: Chris Down <chris@chrisdown.name>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-08-15 12:08:49 +02:00
..
bnep
cmtp
hidp
rfcomm
6lowpan.c
af_bluetooth.c
aosp.c
aosp.h
coredump.c
ecdh_helper.c
ecdh_helper.h
eir.c
eir.h
hci_codec.c
hci_codec.h
hci_conn.c
hci_core.c Bluetooth: hci_core: Fix use-after-free in vhci_flush() 2025-07-10 16:03:13 +02:00
hci_debugfs.c
hci_debugfs.h
hci_event.c Bluetooth: hci_event: Mask data status from LE ext adv reports 2025-08-15 12:08:49 +02:00
hci_request.c
hci_request.h
hci_sock.c
hci_sync.c Bluetooth: hci_sync: fix connectable extended advertising when using static random address 2025-07-24 08:53:18 +02:00
hci_sysfs.c
iso.c
Kconfig
l2cap_core.c Bluetooth: L2CAP: Fix attempting to adjust outgoing MTU 2025-07-24 08:53:19 +02:00
l2cap_sock.c Bluetooth: Fix null-ptr-deref in l2cap_sock_resume_cb() 2025-07-24 08:53:18 +02:00
leds.c
leds.h
lib.c
Makefile
mgmt_config.c
mgmt_config.h
mgmt_util.c
mgmt_util.h
mgmt.c
msft.c
msft.h
sco.c
selftest.c
selftest.h
smp.c Bluetooth: SMP: Fix using HCI_ERROR_REMOTE_USER_TERM on timeout 2025-07-24 08:53:18 +02:00
smp.h Bluetooth: SMP: If an unallowed command is received consider it a failure 2025-07-24 08:53:18 +02:00