Skip to content

Commit 16d748b

Browse files
PavelVPVcarlescufi
authored andcommitted
[nrf fromtree] 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]> (cherry picked from commit 6da559f56544aa2ed1c93071ffad203a523d432c)
1 parent 52a2bce commit 16d748b

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
@@ -1566,13 +1566,16 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
15661566
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
15671567
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
15681568
(!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED) ||
1569-
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED))) {
1569+
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED) ||
1570+
!atomic_test_bit(adv->flags, BT_ADV_RPA_VALID))) {
15701571
bt_id_set_adv_private_addr(adv);
15711572
}
15721573
} else {
15731574
if (!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY) &&
15741575
(!atomic_test_and_clear_bit(adv->flags, BT_ADV_RANDOM_ADDR_UPDATED) ||
1575-
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED))) {
1576+
atomic_test_bit(adv->flags, BT_PER_ADV_ENABLED) ||
1577+
(IS_ENABLED(CONFIG_BT_PRIVACY) &&
1578+
!atomic_test_bit(adv->flags, BT_ADV_RPA_VALID)))) {
15761579
bt_id_set_adv_private_addr(adv);
15771580
}
15781581
}

0 commit comments

Comments
 (0)