From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>,
Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Subject: [PATCH v2] Bluetooth: hci_sync: Don't announce a broadcast from an NRPA
Date: Tue, 24 Nov 2026 12:39:37 +0100 [thread overview]
Message-ID: <20261124113937.1695751-1-simon.mikuda@streamunlimited.com> (raw)
MGMT Add Extended Advertising Parameters sets an advertising set up
before its data is known, and the set becomes periodic only in
hci_start_per_adv_sync(), when a broadcast ISO socket is connected on
it. Until then a set without the connectable flag, on an adapter that is
not connectable and has privacy off, gets a non-resolvable private
address. If its data carries a Broadcast Audio Announcement, the
broadcast is announced from that address, and the set is moved to the
identity address when its periodic advertising starts:
< HCI Command: LE Set Extended Advertising Parameters 3.162678
Handle: 0x02
Properties: 0x0000
Own address type: Random (0x01)
< HCI Command: LE Set Advertising Set Random Address 3.164952
Advertising random address: 21:3E:30:B7:DE:A4 (Non-Resolvable)
< HCI Command: LE Set Extended Advertising Data 4.161538
Service Data: Broadcast Audio Announcement (0x1852)
Broadcast ID: 11645491 (0xb1b233)
< HCI Command: LE Set Extended Advertising Enable 4.164125
Extended advertising: Enabled (0x01)
< HCI Command: LE Set Extended Advertising Enable 11.280146
Extended advertising: Disabled (0x00)
< HCI Command: LE Set Extended Advertising Parameters 11.282026
Own address type: Public (0x00)
< HCI Command: LE Set Extended Advertising Enable 11.284922
Extended advertising: Enabled (0x01)
< HCI Command: LE Set Periodic Advertising Enable 11.291942
Periodic advertising: Enabled (0x01)
The address the broadcast is first announced from never carries the
periodic advertising. A scanner listed Broadcast ID 0xb1b233 under
21:3E:30:B7:DE:A4 before the socket was connected, and under the
controller's public address in a scan started after it.
The commit in Fixes stopped giving a periodic set a non-resolvable
address, but it looks only at adv->periodic. Treat a set whose data
carries a Broadcast Audio Announcement as a broadcast set too, and set
it up again in Add Extended Advertising Data, because its parameters
were sent before the data was known. With this change LE Set Extended
Advertising Parameters is sent a second time, with Own address type
Public, before the set is first enabled, and the scanner lists the
Broadcast ID only under the public address.
The address of other sets does not change: an NRPA is only asked for
when neither the set's flag nor the adapter's setting makes it
connectable, and a set that uses a resolvable private address gets that
first.
Steps to reproduce, on an nRF54L15 with Zephyr 4.5.0's open link layer
as hci1 (public address F4:26:7C:31:12:69) and BlueZ 5.87, with privacy
off and the adapter not connectable ("btmgmt info" lists neither):
1. btmon -i hci1 -w FILE
2. In one "btmgmt --index 1" session, a second apart:
add-ext-adv-params -r 0xa0 -x 0xf0 -P 2M 2
add-ext-adv-data -d 0616521833b2b1 2
3. About 7 s later, a broadcast ISO socket on advertising set 2:
isotest -i hci1 -q -s 00:00:00:00:00:00 -B 16_2_1 -G 0 -T 2
A Realtek RTL8763EFL next to it scanned for broadcast sources, 10 s from
before step 2 and again from 2 s after step 3.
Fixes: 03ddb4ac2514 ("Bluetooth: hci_sync: Fix using random address for BIG/PA advertisements")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
Changes in v2:
- no code change
- reworded git description
- steps to reproduce added
net/bluetooth/hci_sync.c | 12 ++++++++++--
net/bluetooth/mgmt.c | 14 ++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 25ab26c2fbf8..de6b479a7cd4 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1487,7 +1487,7 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
{
struct hci_cp_le_set_ext_adv_params cp;
struct hci_rp_le_set_ext_adv_params rp;
- bool connectable, require_privacy;
+ bool connectable, periodic, require_privacy;
u32 flags;
bdaddr_t random_addr;
u8 own_addr_type;
@@ -1522,6 +1522,14 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
flags = hci_adv_instance_flags(hdev, instance);
+ /* A set with a Broadcast Audio Announcement is a broadcast source even
+ * before its PA starts.
+ */
+ periodic = adv && (adv->periodic ||
+ eir_get_service_data(adv->adv_data,
+ adv->adv_data_len, 0x1852,
+ NULL));
+
/* If the "connectable" instance flag was not set, then choose between
* ADV_IND and ADV_NONCONN_IND based on the global connectable setting,
* unless the instance carries periodic advertising, which can only be
@@ -1540,7 +1548,7 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
* advertising is used and it is not periodic.
* In that case it is fine to use a non-resolvable private address.
*/
- require_privacy = !connectable && !(adv && adv->periodic);
+ require_privacy = !connectable && !periodic;
err = hci_get_random_address(hdev, require_privacy,
adv_use_rpa(hdev, flags), adv,
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f5f32860782d..edfbdf2942f7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -9646,6 +9646,20 @@ static int add_ext_adv_data_sync(struct hci_dev *hdev, void *data)
int err;
if (ext_adv_capable(hdev)) {
+ struct adv_info *adv;
+ bool bcast;
+
+ /* The parameters were set before the data was known */
+ hci_dev_lock(hdev);
+ adv = hci_find_adv_instance(hdev, cp->instance);
+ bcast = adv && !adv->periodic &&
+ eir_get_service_data(adv->adv_data, adv->adv_data_len,
+ 0x1852, NULL);
+ hci_dev_unlock(hdev);
+
+ if (bcast)
+ return hci_start_ext_adv_sync(hdev, cp->instance);
+
err = hci_update_adv_data_sync(hdev, cp->instance);
if (err)
return err;
base-commit: 62fd917f6d2df1a399a453138c2b7cbd563f8f95
--
2.43.0
next reply other threads:[~2026-11-24 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:39 Simon Mikuda [this message]
2026-11-24 18:49 ` [v2] Bluetooth: hci_sync: Don't announce a broadcast from an NRPA bluez.test.bot
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=20261124113937.1695751-1-simon.mikuda@streamunlimited.com \
--to=simon.mikuda@streamunlimited.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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