From: Chris Down <chris@chrisdown.name>
To: linux-bluetooth@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
Jaganath Kanakkassery <jaganath.k.os@gmail.com>
Subject: [PATCH] Bluetooth: hci_event: Mask data status from LE ext adv reports
Date: Thu, 17 Jul 2025 01:14:36 +0800 [thread overview]
Message-ID: <aHfd_H6c9MheDoQP@chrisdown.name> (raw)
The Event_Type field in an LE Extended Advertising Report uses bits 5
and 6 for data status (e.g. 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 fragmented 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).
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.
Signed-off-by: Chris Down <chris@chrisdown.name>
Cc: linux-bluetooth@vger.kernel.org
---
net/bluetooth/hci_event.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c0eb03e5cbf8..077c93b5fae0 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -6237,10 +6237,14 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data,
hci_dev_unlock(hdev);
}
+#define LE_EXT_ADV_DATA_STATUS_MASK GENMASK(6, 5)
+
static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)
{
- if (evt_type & LE_EXT_ADV_LEGACY_PDU) {
- switch (evt_type) {
+ u16 pdu_type = evt_type & ~LE_EXT_ADV_DATA_STATUS_MASK;
+
+ if (pdu_type & LE_EXT_ADV_LEGACY_PDU) {
+ switch (pdu_type) {
case LE_LEGACY_ADV_IND:
return LE_ADV_IND;
case LE_LEGACY_ADV_DIRECT_IND:
@@ -6257,21 +6261,21 @@ static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)
goto invalid;
}
- if (evt_type & LE_EXT_ADV_CONN_IND) {
- if (evt_type & LE_EXT_ADV_DIRECT_IND)
+ if (pdu_type & LE_EXT_ADV_CONN_IND) {
+ if (pdu_type & LE_EXT_ADV_DIRECT_IND)
return LE_ADV_DIRECT_IND;
return LE_ADV_IND;
}
- if (evt_type & LE_EXT_ADV_SCAN_RSP)
+ if (pdu_type & LE_EXT_ADV_SCAN_RSP)
return LE_ADV_SCAN_RSP;
- if (evt_type & LE_EXT_ADV_SCAN_IND)
+ if (pdu_type & LE_EXT_ADV_SCAN_IND)
return LE_ADV_SCAN_IND;
- if (evt_type == LE_EXT_ADV_NON_CONN_IND ||
- evt_type & LE_EXT_ADV_DIRECT_IND)
+ if (pdu_type == LE_EXT_ADV_NON_CONN_IND ||
+ pdu_type & LE_EXT_ADV_DIRECT_IND)
return LE_ADV_NONCONN_IND;
invalid:
--
2.49.0
next reply other threads:[~2025-07-16 17:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 17:14 Chris Down [this message]
2025-07-16 17:36 ` Bluetooth: hci_event: Mask data status from LE ext adv reports bluez.test.bot
2025-07-17 19:12 ` [PATCH] " Luiz Augusto von Dentz
2025-07-18 8:13 ` Chris Down
2025-07-18 16:05 ` Luiz Augusto von Dentz
2025-07-19 16:04 ` Chris Down
2025-07-21 13:34 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aHfd_H6c9MheDoQP@chrisdown.name \
--to=chris@chrisdown.name \
--cc=jaganath.k.os@gmail.com \
--cc=kernel-team@fb.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox