* [PATCH v2] Bluetooth: hci_sync: pause advertising for the scan address update
@ 2026-08-17 15:03 Valentin Kindschi
2026-08-17 15:48 ` [v2] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Valentin Kindschi @ 2026-08-17 15:03 UTC (permalink / raw)
To: linux-bluetooth
Cc: marcel, johan.hedberg, luiz.dentz, linux-kernel,
Valentin Kindschi, stable
hci_active_scan_sync() calls hci_update_random_address_sync() with
require_privacy set on every active scan start, which generates a
non-resolvable private address and programs it with LE Set Random
Address.
BLUETOOTH CORE SPECIFICATION Vol 4, Part E, 7.8.4 states the controller
shall return Command Disallowed (0x0C) for LE Set Random Address while
legacy advertising or scanning is enabled.
Advertising is only stopped beforehand when LL privacy is in use.
hci_pause_addr_resolution(), called just above, returns early when
!use_ll_privacy(hdev), so its hci_pause_advertising_sync() never runs.
On a device that advertises while active scanning - a peripheral that is
also a central, such as a gateway - every scan start therefore issues a
command the host can already know will be rejected:
Bluetooth: hci0: Opcode 0x2005 failed: -16
The address write is not retried either: hci_set_random_addr_sync()
defers only when hdev->random_addr is already set, and it never becomes
set because the write keeps failing, so HCI_RPA_EXPIRED is not used here.
Observed on a BCM43455 with Privacy=off, one advertising instance and
continuous active discovery, at the scan restart period (~10 s):
< LE Set Random Address Address: 02:16:91:90:F1:D4 (Non-Resolvable)
> Command Complete LE Set Random Address, Command Disallowed
< LE Set Random Address Address: 26:90:57:96:9A:3E (Non-Resolvable)
> Command Complete LE Set Random Address, Command Disallowed
< LE Set Random Address Address: 16:32:01:BC:B5:CE (Non-Resolvable)
> Command Complete LE Set Random Address, Command Disallowed
Pause advertising for the address update regardless of privacy, and
resume it on every exit path. Previously the resume was guarded by
use_ll_privacy() and only reached on the error path, which matched the
pause being privacy-only.
With the patch, the same scan restart on the same hardware:
< LE Set Advertising Enable Success
< LE Set Random Address Success
< LE Set Scan Parameters Success
< LE Set Scan Enable Success
< LE Set Advertising Parameters Success
< LE Set Advertising Enable Success
Over 35425 records / ~4 min of btmon with continuous active discovery and
advertising enabled there were no Command Disallowed responses of any
kind, against one per scan restart before. A central could still connect
to the device, confirming advertising is restored after the pause.
Tooling disclosure (Documentation/process/generated-content.rst): an AI
coding assistant was used to investigate this and to draft the change;
the patch text and code are its output, reviewed by me. Inputs were btmon
captures and kernel logs from the affected device, with the request to
identify what re-issues LE Set Random Address every ~10 s and to fix it.
Three earlier explanations it proposed were discarded after being checked
against the captures: bluetoothd restarting service discovery; RPA
rotation (excluded, Privacy=off); and the static-address branch of
hci_update_random_address_sync() (excluded, both random_address and
static_address read 00:00:00:00:00:00). The cause was only established
after decoding the command payloads, which showed a freshly generated
non-resolvable address per attempt. Testing is as described above, on the
device, using btmon and a second device to confirm connectability.
Fixes: abfeea476c68 ("Bluetooth: hci_sync: Convert MGMT_OP_START_DISCOVERY")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5 btmon
Signed-off-by: Valentin Kindschi <valentin.kindschi@fiveco.ch>
---
net/bluetooth/hci_sync.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6170,6 +6170,14 @@ static int hci_active_scan_sync(struct hci_dev *hdev, uint16_t interval,
if (err)
goto failed;
+ /* LE Set Random Address is disallowed while advertising is enabled, so
+ * pause it for the address update. hci_pause_addr_resolution() above
+ * only does this when LL privacy is in use.
+ */
+ err = hci_pause_advertising_sync(hdev);
+ if (err)
+ goto failed;
+
/* All active scans will be done with either a resolvable private
* address (when privacy feature has been enabled) or non-resolvable
* private address.
@@ -6201,13 +6209,18 @@ static int hci_active_scan_sync(struct hci_dev *hdev, uint16_t interval,
err = hci_start_scan_sync(hdev, LE_SCAN_ACTIVE, interval,
hdev->le_scan_window_discovery,
own_addr_type, filter_policy, filter_dup);
- if (!err)
+ if (!err) {
+ /* Advertising was paused for the address update above. */
+ hci_resume_advertising_sync(hdev);
return err;
+ }
failed:
- /* Resume advertising if it was paused */
- if (ll_privacy_capable(hdev))
- hci_resume_advertising_sync(hdev);
+ /* Resume advertising if it was paused. hci_resume_advertising_sync()
+ * is a no-op when hdev->advertising_paused is not set, so this covers
+ * both the privacy and the address-update pause.
+ */
+ hci_resume_advertising_sync(hdev);
/* Resume passive scanning */
hci_update_passive_scan_sync(hdev);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [v2] Bluetooth: hci_sync: pause advertising for the scan address update
2026-08-17 15:03 [PATCH v2] Bluetooth: hci_sync: pause advertising for the scan address update Valentin Kindschi
@ 2026-08-17 15:48 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-08-17 15:48 UTC (permalink / raw)
To: linux-bluetooth, valentin.kindschi
[-- Attachment #1: Type: text/plain, Size: 2390 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1147270
---Test result---
Test Summary:
CheckPatch PASS 0.68 seconds
VerifyFixes PASS 0.11 seconds
VerifySignedoff PASS 0.11 seconds
GitLint PASS 0.28 seconds
SubjectPrefix PASS 0.10 seconds
BuildKernel PASS 26.01 seconds
CheckAllWarning PASS 28.50 seconds
CheckSparse PASS 27.04 seconds
BuildKernel32 PASS 25.08 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 470.30 seconds
TestRunner_l2cap-tester PASS 64.83 seconds
TestRunner_iso-tester PASS 102.25 seconds
TestRunner_bnep-tester PASS 19.79 seconds
TestRunner_mgmt-tester FAIL 225.41 seconds
TestRunner_rfcomm-tester PASS 25.36 seconds
TestRunner_sco-tester PASS 32.38 seconds
TestRunner_ioctl-tester PASS 26.29 seconds
TestRunner_mesh-tester FAIL 26.19 seconds
TestRunner_smp-tester PASS 23.48 seconds
TestRunner_userchan-tester PASS 19.88 seconds
TestRunner_6lowpan-tester PASS 25.75 seconds
IncrementalBuild PASS 23.75 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 501, Passed: 496 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.248 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.128 seconds
Mesh - Send cancel - 2 Timed out 1.984 seconds
https://github.com/bluez/bluetooth-next/pull/601
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-17 15:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 15:03 [PATCH v2] Bluetooth: hci_sync: pause advertising for the scan address update Valentin Kindschi
2026-08-17 15:48 ` [v2] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox