* [PATCH BlueZ v2 1/2] device: Fix privacy
@ 2025-10-01 14:27 Luiz Augusto von Dentz
2025-10-01 14:27 ` [PATCH BlueZ v2 2/2] core: Fix not resolving addresses Luiz Augusto von Dentz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-01 14:27 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In order for devices to properly be programmed into the adapter
resolving list they need to set the flag DEVICE_FLAG_ADDRESS_RESOLUTION
but that is only done if device_address_is_private return true but
currently it doesn't check the rpa flag which indicates that the address
has been updated to its identity.
While at it this also update the rpa flag to privacy to better indicate
the feature rather than just the address type and then introduces
device_set_privacy/device_get_privacy and replaces the usage of
device_address_is_private with device_get_privacy whenever the features
itself needs to be checked, rather than the current address type in use.
Fixes: https://github.com/bluez/bluez/issues/1079
---
src/adapter.c | 4 ++--
src/device.c | 16 ++++++++++++----
src/device.h | 3 ++-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index dc5ba65d73fa..3afcb9277129 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5091,7 +5091,7 @@ static void load_devices(struct btd_adapter *adapter)
goto free;
if (irk_info)
- device_set_rpa(device, true);
+ device_set_privacy(device, true);
btd_device_set_temporary(device, false);
adapter_add_device(adapter, device);
@@ -5752,7 +5752,7 @@ void adapter_set_device_flags(struct btd_adapter *adapter,
/* Set Address Resolution if it has not been set the flag yet. */
if (ll_privacy && btd_opts.defaults.le.addr_resolution &&
- device_address_is_private(device) &&
+ device_get_privacy(device) &&
!(flags & DEVICE_FLAG_ADDRESS_RESOLUTION))
flags |= DEVICE_FLAG_ADDRESS_RESOLUTION & supported & ~pending;
diff --git a/src/device.c b/src/device.c
index 8b3e78995881..9f0e8e673529 100644
--- a/src/device.c
+++ b/src/device.c
@@ -204,7 +204,7 @@ struct btd_device {
uint8_t conn_bdaddr_type;
bdaddr_t bdaddr;
uint8_t bdaddr_type;
- bool rpa;
+ bool privacy;
char *path;
struct btd_bearer *bredr;
struct btd_bearer *le;
@@ -4995,9 +4995,17 @@ void device_set_class(struct btd_device *device, uint32_t class)
DEVICE_INTERFACE, "Icon");
}
-void device_set_rpa(struct btd_device *device, bool value)
+void device_set_privacy(struct btd_device *device, bool value)
{
- device->rpa = value;
+ device->privacy = value;
+}
+
+bool device_get_privacy(struct btd_device *device)
+{
+ if (device->privacy)
+ return true;
+
+ return device_address_is_private(device);
}
void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
@@ -5005,7 +5013,7 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
{
bool auto_connect = device->auto_connect;
- device_set_rpa(device, true);
+ device_set_privacy(device, true);
if (!bacmp(bdaddr, &device->bdaddr) &&
bdaddr_type == device->bdaddr_type)
diff --git a/src/device.h b/src/device.h
index 9e7c30ad7186..6fbbdb1f2d28 100644
--- a/src/device.h
+++ b/src/device.h
@@ -29,7 +29,8 @@ bool device_is_name_resolve_allowed(struct btd_device *device);
void device_name_resolve_fail(struct btd_device *device);
void device_set_class(struct btd_device *device, uint32_t class);
bool device_address_is_private(struct btd_device *dev);
-void device_set_rpa(struct btd_device *device, bool value);
+void device_set_privacy(struct btd_device *device, bool value);
+bool device_get_privacy(struct btd_device *device);
void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
uint8_t bdaddr_type);
void device_set_bredr_support(struct btd_device *device);
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ v2 2/2] core: Fix not resolving addresses
2025-10-01 14:27 [PATCH BlueZ v2 1/2] device: Fix privacy Luiz Augusto von Dentz
@ 2025-10-01 14:27 ` Luiz Augusto von Dentz
2025-10-01 15:52 ` [BlueZ,v2,1/2] device: Fix privacy bluez.test.bot
2025-10-02 19:40 ` [PATCH BlueZ v2 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-01 14:27 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When using the likes of btd_adapter_get_device the address can sometimes
be the so called RPA which needs to be resolved in order to avoid
creating duplicated objects of the same device.
Note that normally the RPA are resolved in the kernel but there are
instances like BASS Add Source that may attempt to add a device direcly,
bypassing the GAP layer.
---
src/adapter.c | 4 ++--
src/device.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++---
src/device.h | 5 +++--
3 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 3afcb9277129..1ee2f3a08164 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5091,7 +5091,7 @@ static void load_devices(struct btd_adapter *adapter)
goto free;
if (irk_info)
- device_set_privacy(device, true);
+ device_set_privacy(device, true, irk_info->val);
btd_device_set_temporary(device, false);
adapter_add_device(adapter, device);
@@ -9024,7 +9024,7 @@ static void new_irk_callback(uint16_t index, uint16_t length,
return;
}
- device_update_addr(device, &addr->bdaddr, addr->type);
+ device_update_addr(device, &addr->bdaddr, addr->type, irk->val);
if (duplicate)
device_merge_duplicate(device, duplicate);
diff --git a/src/device.c b/src/device.c
index 9f0e8e673529..8d74ae0ea0ff 100644
--- a/src/device.c
+++ b/src/device.c
@@ -205,6 +205,7 @@ struct btd_device {
bdaddr_t bdaddr;
uint8_t bdaddr_type;
bool privacy;
+ uint8_t *irk;
char *path;
struct btd_bearer *bredr;
struct btd_bearer *le;
@@ -4995,9 +4996,17 @@ void device_set_class(struct btd_device *device, uint32_t class)
DEVICE_INTERFACE, "Icon");
}
-void device_set_privacy(struct btd_device *device, bool value)
+void device_set_privacy(struct btd_device *device, bool value,
+ const uint8_t *irk)
{
device->privacy = value;
+
+ free(device->irk);
+
+ if (irk)
+ device->irk = util_memdup(irk, 16);
+ else
+ device->irk = NULL;
}
bool device_get_privacy(struct btd_device *device)
@@ -5009,11 +5018,11 @@ bool device_get_privacy(struct btd_device *device)
}
void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
- uint8_t bdaddr_type)
+ uint8_t bdaddr_type, const uint8_t *irk)
{
bool auto_connect = device->auto_connect;
- device_set_privacy(device, true);
+ device_set_privacy(device, true, irk);
if (!bacmp(bdaddr, &device->bdaddr) &&
bdaddr_type == device->bdaddr_type)
@@ -5347,6 +5356,39 @@ static bool addr_is_public(uint8_t addr_type)
return false;
}
+static bool addr_is_resolvable(const bdaddr_t *bdaddr, uint8_t addr_type)
+{
+ if (addr_type != BDADDR_LE_RANDOM)
+ return false;
+
+ switch (bdaddr->b[5] >> 6) {
+ case 0x01: /* Private resolvable */
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool device_irk_cmp(const struct btd_device *device,
+ const struct device_addr_type *addr)
+{
+ struct bt_crypto *crypto;
+ uint8_t hash[3];
+
+ if (!device->irk)
+ return false;
+
+ crypto = bt_crypto_new();
+ if (!crypto)
+ return false;
+
+ bt_crypto_ah(crypto, device->irk, addr->bdaddr.b + 3, hash);
+
+ bt_crypto_unref(crypto);
+
+ return !memcmp(addr, hash, 3);
+}
+
int device_addr_type_cmp(gconstpointer a, gconstpointer b)
{
const struct btd_device *dev = a;
@@ -5375,8 +5417,13 @@ int device_addr_type_cmp(gconstpointer a, gconstpointer b)
return -1;
if (addr->bdaddr_type != dev->bdaddr_type) {
+ if (dev->privacy && addr_is_resolvable(&addr->bdaddr,
+ addr->bdaddr_type))
+ return device_irk_cmp(dev, addr);
+
if (addr->bdaddr_type == dev->conn_bdaddr_type)
return bacmp(&dev->conn_bdaddr, &addr->bdaddr);
+
return -1;
}
diff --git a/src/device.h b/src/device.h
index 6fbbdb1f2d28..9ff9cdfefc28 100644
--- a/src/device.h
+++ b/src/device.h
@@ -29,10 +29,11 @@ bool device_is_name_resolve_allowed(struct btd_device *device);
void device_name_resolve_fail(struct btd_device *device);
void device_set_class(struct btd_device *device, uint32_t class);
bool device_address_is_private(struct btd_device *dev);
-void device_set_privacy(struct btd_device *device, bool value);
+void device_set_privacy(struct btd_device *device, bool value,
+ const uint8_t *irk);
bool device_get_privacy(struct btd_device *device);
void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
- uint8_t bdaddr_type);
+ uint8_t bdaddr_type, const uint8_t *irk);
void device_set_bredr_support(struct btd_device *device);
void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type);
void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [BlueZ,v2,1/2] device: Fix privacy
2025-10-01 14:27 [PATCH BlueZ v2 1/2] device: Fix privacy Luiz Augusto von Dentz
2025-10-01 14:27 ` [PATCH BlueZ v2 2/2] core: Fix not resolving addresses Luiz Augusto von Dentz
@ 2025-10-01 15:52 ` bluez.test.bot
2025-10-02 19:40 ` [PATCH BlueZ v2 1/2] " patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-10-01 15:52 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1262 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=1007714
---Test result---
Test Summary:
CheckPatch PENDING 0.28 seconds
GitLint PENDING 0.37 seconds
BuildEll PASS 20.25 seconds
BluezMake PASS 2698.94 seconds
MakeCheck PASS 20.72 seconds
MakeDistcheck PASS 186.51 seconds
CheckValgrind PASS 238.73 seconds
CheckSmatch PASS 309.40 seconds
bluezmakeextell PASS 129.61 seconds
IncrementalBuild PENDING 0.33 seconds
ScanBuild PASS 919.45 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v2 1/2] device: Fix privacy
2025-10-01 14:27 [PATCH BlueZ v2 1/2] device: Fix privacy Luiz Augusto von Dentz
2025-10-01 14:27 ` [PATCH BlueZ v2 2/2] core: Fix not resolving addresses Luiz Augusto von Dentz
2025-10-01 15:52 ` [BlueZ,v2,1/2] device: Fix privacy bluez.test.bot
@ 2025-10-02 19:40 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-02 19:40 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 1 Oct 2025 10:27:37 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> In order for devices to properly be programmed into the adapter
> resolving list they need to set the flag DEVICE_FLAG_ADDRESS_RESOLUTION
> but that is only done if device_address_is_private return true but
> currently it doesn't check the rpa flag which indicates that the address
> has been updated to its identity.
>
> [...]
Here is the summary with links:
- [BlueZ,v2,1/2] device: Fix privacy
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e3a16c28e479
- [BlueZ,v2,2/2] core: Fix not resolving addresses
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f1fb4f95f49e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-02 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 14:27 [PATCH BlueZ v2 1/2] device: Fix privacy Luiz Augusto von Dentz
2025-10-01 14:27 ` [PATCH BlueZ v2 2/2] core: Fix not resolving addresses Luiz Augusto von Dentz
2025-10-01 15:52 ` [BlueZ,v2,1/2] device: Fix privacy bluez.test.bot
2025-10-02 19:40 ` [PATCH BlueZ v2 1/2] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox