* [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected
@ 2025-03-26 19:31 Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive Luiz Augusto von Dentz
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-26 19:31 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This would make Pair act behave the same as when the device reconnect
and bonding already exists.
---
src/device.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index 9774b5bf1b96..f76c1ec3eabf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3194,10 +3194,13 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
if (!state->connected && btd_le_connect_before_pairing())
err = device_connect_le(device);
- else
+ else if (!state->connected || !bt_att_set_security(device->att,
+ BT_ATT_SECURITY_MEDIUM))
err = adapter_create_bonding(adapter, &device->bdaddr,
device->bdaddr_type,
io_cap);
+ else
+ err = 0;
} else {
err = adapter_create_bonding(adapter, &device->bdaddr,
BDADDR_BREDR, io_cap);
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
@ 2025-03-26 19:31 ` Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message Luiz Augusto von Dentz
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-26 19:31 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes Device.Connect and Device.Pair methods mutually exclusive so
they cannot happen in parallel, so just as Connect:Connect and Pair:Pair
combinations the Connect:Pair and Pair:Connect will now return
org.bluez.Error.InProgress.
---
src/device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index f76c1ec3eabf..6a6c379fcbbf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2629,6 +2629,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
struct btd_device *dev = user_data;
uint8_t bdaddr_type;
+ if (dev->bonding)
+ return btd_error_in_progress(msg);
+
if (dev->bredr_state.connected) {
/*
* Check if services have been resolved and there is at least
@@ -2648,6 +2651,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
if (bdaddr_type != BDADDR_BREDR) {
int err;
+ if (dev->connect)
+ return btd_error_in_progress(msg);
+
if (dev->le_state.connected)
return dbus_message_new_method_return(msg);
@@ -3133,7 +3139,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
- if (device->bonding)
+ if (device->bonding || device->connect)
return btd_error_in_progress(msg);
/* Only use this selection algorithms when device is combo
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive Luiz Augusto von Dentz
@ 2025-03-26 19:31 ` Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 4/5] shared/att: Make bt_att_set_security never downgrade security level Luiz Augusto von Dentz
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-26 19:31 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Device.Connect message is not the only way to initiate a connection as
there is also the likes of Device.Pair which will initiate bonding, so
this incorporate the bonding check into btd_device_is_initiator and
replaces the checks of were Connect message was used to determine if
initiator to use btd_device_is_initiator.
---
src/device.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/device.c b/src/device.c
index 6a6c379fcbbf..034491b59d30 100644
--- a/src/device.c
+++ b/src/device.c
@@ -320,6 +320,8 @@ bool btd_device_is_initiator(struct btd_device *dev)
return dev->le_state.initiator;
else if (dev->bredr_state.connected)
return dev->bredr_state.initiator;
+ else if (dev->bonding)
+ return true;
return dev->att_io ? true : false;
}
@@ -5780,11 +5782,12 @@ static void gatt_client_init(struct btd_device *device)
gatt_client_cleanup(device);
- if (!device->connect && !btd_opts.reverse_discovery) {
+ if (!btd_device_is_initiator(device) && !btd_opts.reverse_discovery) {
DBG("Reverse service discovery disabled: skipping GATT client");
return;
}
- if (!device->connect && !btd_opts.gatt_client) {
+
+ if (!btd_device_is_initiator(device) && !btd_opts.gatt_client) {
DBG("GATT client disabled: skipping GATT client");
return;
}
@@ -5834,7 +5837,7 @@ static void gatt_client_init(struct btd_device *device)
* it shall be triggered only when ready to avoid possible clashes where
* both sides attempt to connection at same time.
*/
- if (device->connect)
+ if (btd_device_is_initiator(device))
btd_gatt_client_eatt_connect(device->client_dbus);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 4/5] shared/att: Make bt_att_set_security never downgrade security level
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message Luiz Augusto von Dentz
@ 2025-03-26 19:31 ` Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 5/5] device: Elevate bt_att security if bonding is in progress Luiz Augusto von Dentz
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-26 19:31 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Requesting a lower security level than existing one shall result in no
operation since higher security satisfy a lower one and it is never a
good practice to allow downgrading security to begin with.
---
src/shared/att.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/shared/att.c b/src/shared/att.c
index dabbdb4315eb..8657cb6423fb 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -727,7 +727,11 @@ static bool bt_att_chan_set_security(struct bt_att_chan *chan, int level)
{
struct bt_security sec;
- if (level == bt_att_chan_get_security(chan))
+ /* Check if security level has already been set, if the security level
+ * is higher it shall satisfy the request since we never want to
+ * downgrade security.
+ */
+ if (level <= bt_att_chan_get_security(chan))
return true;
if (chan->type == BT_ATT_LOCAL) {
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 5/5] device: Elevate bt_att security if bonding is in progress
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
` (2 preceding siblings ...)
2025-03-26 19:31 ` [PATCH BlueZ v2 4/5] shared/att: Make bt_att_set_security never downgrade security level Luiz Augusto von Dentz
@ 2025-03-26 19:31 ` Luiz Augusto von Dentz
2025-03-26 20:31 ` [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected bluez.test.bot
2025-03-27 16:10 ` [PATCH BlueZ v2 1/5] " patchwork-bot+bluetooth
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2025-03-26 19:31 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When bonding is in progress it means Device.Pair has been called thus
the user indicated the intend to pair/bond from the start so the
security of bt_att shall be set in order for it to wait until pairing
process complete before attempting to proceed with GATT discovery and
any other traffic.
Fixes: https://github.com/bluez/bluez/issues/1125
---
src/device.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/device.c b/src/device.c
index 034491b59d30..057d116be6fc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5797,6 +5797,11 @@ static void gatt_client_init(struct btd_device *device)
if (btd_opts.gatt_channels > 1)
features |= BT_GATT_CHRC_CLI_FEAT_EATT;
+ if (device->bonding) {
+ DBG("Elevating security level since bonding is in progress");
+ bt_att_set_security(device->att, BT_ATT_SECURITY_MEDIUM);
+ }
+
device->client = bt_gatt_client_new(device->db, device->att,
device->att_mtu, features);
if (!device->client) {
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
` (3 preceding siblings ...)
2025-03-26 19:31 ` [PATCH BlueZ v2 5/5] device: Elevate bt_att security if bonding is in progress Luiz Augusto von Dentz
@ 2025-03-26 20:31 ` bluez.test.bot
2025-03-27 16:10 ` [PATCH BlueZ v2 1/5] " patchwork-bot+bluetooth
5 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-03-26 20:31 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 2884 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=947562
---Test result---
Test Summary:
CheckPatch PENDING 0.24 seconds
GitLint PENDING 0.26 seconds
BuildEll PASS 20.67 seconds
BluezMake PASS 1547.48 seconds
MakeCheck FAIL 13.31 seconds
MakeDistcheck FAIL 144.10 seconds
CheckValgrind FAIL 215.07 seconds
CheckSmatch PASS 288.33 seconds
bluezmakeextell PASS 100.38 seconds
IncrementalBuild PENDING 0.31 seconds
ScanBuild PASS 879.29 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:
./test-driver: line 107: 32282 Aborted (core dumped) "$@" > $log_file 2>&1
make[3]: *** [Makefile:11780: test-suite.log] Error 1
make[2]: *** [Makefile:11888: check-TESTS] Error 2
make[1]: *** [Makefile:12317: check-am] Error 2
make: *** [Makefile:12319: check] Error 2
##############################
Test: MakeDistcheck - FAIL
Desc: Run Bluez Make Distcheck
Output:
Package cups was not found in the pkg-config search path.
Perhaps you should add the directory containing `cups.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cups' found
../../test-driver: line 107: 55085 Aborted (core dumped) "$@" > $log_file 2>&1
make[4]: *** [Makefile:11780: test-suite.log] Error 1
make[3]: *** [Makefile:11888: check-TESTS] Error 2
make[2]: *** [Makefile:12317: check-am] Error 2
make[1]: *** [Makefile:12319: check] Error 2
make: *** [Makefile:12240: distcheck] Error 1
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12907:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12907 | int main(int argc, char *argv[])
| ^~~~
./test-driver: line 107: 75123 Aborted (core dumped) "$@" > $log_file 2>&1
make[3]: *** [Makefile:11780: test-suite.log] Error 1
make[2]: *** [Makefile:11888: check-TESTS] Error 2
make[1]: *** [Makefile:12317: check-am] Error 2
make: *** [Makefile:12319: check] Error 2
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
` (4 preceding siblings ...)
2025-03-26 20:31 ` [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected bluez.test.bot
@ 2025-03-27 16:10 ` patchwork-bot+bluetooth
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2025-03-27 16:10 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, 26 Mar 2025 15:31:29 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This would make Pair act behave the same as when the device reconnect
> and bonding already exists.
> ---
> src/device.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Here is the summary with links:
- [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8e2cece67dbe
- [BlueZ,v2,2/5] device: Make Connect and Pair mutually exclusive
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1c2ec29900e4
- [BlueZ,v2,3/5] device: Use btd_device_is_initiator instead of Connect message
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=45b61a10bd0a
- [BlueZ,v2,4/5] shared/att: Make bt_att_set_security never downgrade security level
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ac1f8dd88a46
- [BlueZ,v2,5/5] device: Elevate bt_att security if bonding is in progress
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5df9521ce4d5
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] 7+ messages in thread
end of thread, other threads:[~2025-03-27 16:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 4/5] shared/att: Make bt_att_set_security never downgrade security level Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 5/5] device: Elevate bt_att security if bonding is in progress Luiz Augusto von Dentz
2025-03-26 20:31 ` [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected bluez.test.bot
2025-03-27 16:10 ` [PATCH BlueZ v2 1/5] " patchwork-bot+bluetooth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.