Skip to content

Commit a63f51b

Browse files
committed
bluetooth: host: Fix stale RPA usage after invalidation
Add !BT_ADV_RPA_VALID check to force RPA regeneration when re-enabling an advertising set after RPA rotation occurred while disabled. The BT_ADV_RANDOM_ADDR_UPDATED flag was added to prevent unnecessary address regeneration (RPA/NRPA) between bt_le_ext_adv_param_set() and bt_le_ext_adv_start() calls. However, this revealed an issue: When RPA rotation (le_force_rpa_timeout) occurs while an advertiser is disabled, BT_ADV_RPA_VALID is cleared but the RPA is not regenerated. On subsequent bt_le_ext_adv_start() without a new param_set() call: - BT_ADV_RANDOM_ADDR_UPDATED is already cleared (from previous start) - Without BT_PER_ADV_ENABLED, no regeneration occurs - Stale RPA is used, violating privacy requirements Add !BT_ADV_RPA_VALID check for both connectable and non-connectable advertisers to ensure fresh RPA generation when the previous RPA was invalidated while the advertiser was disabled. Fixes regression introduced in #98117. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent d02cdc7 commit a63f51b

File tree

1 file changed

+5
-2
lines changed
  • subsys/bluetooth/host

1 file changed

+5
-2
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,13 +1514,16 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
15141514
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
15151515
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
15161516
(!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED) ||
1517-
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED))) {
1517+
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED) ||
1518+
!atomic_test_bit(adv->flags, BT_ADV_RPA_VALID))) {
15181519
bt_id_set_adv_private_addr(adv);
15191520
}
15201521
} else {
15211522
if (!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
15221523
(!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED) ||
1523-
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED))) {
1524+
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED) ||
1525+
(IS_ENABLED(CONFIG_BT_PRIVACY) &&
1526+
!atomic_test_bit(adv->flags, BT_ADV_RPA_VALID)))) {
15241527
bt_id_set_adv_private_addr(adv);
15251528
}
15261529
}

0 commit comments

Comments
 (0)