From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v6 4/5] device: Reset Security Level and Encryption Type on disconnect
Date: Thu, 26 Nov 2026 09:52:10 +0100 [thread overview]
Message-ID: <20261126085211.80204-5-frederic.danis@collabora.com> (raw)
In-Reply-To: <20261126085211.80204-1-frederic.danis@collabora.com>
SecurityLevel and EncryptionType are retained across disconnects, so
replaying them for a later unsecured reconnect could report the
previous connection's security state. Reset both to zero, with a
PropertiesChanged notification, once the last bearer disconnects.
Assisted-by: Claude:claude-sonnet-5
---
v5->v6: New in v6.
src/device.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/device.c b/src/device.c
index a21819419..b7235f56b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4141,6 +4141,24 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
if (device->bredr_state.connected || device->le_state.connected)
return;
+ /* Security level and encryption type are only meaningful for the
+ * current connection: reset them once both bearers are disconnected
+ * so a later reconnect doesn't report a stale value.
+ */
+ if (device->sec_level) {
+ device->sec_level = 0;
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE,
+ "SecurityLevel");
+ }
+
+ if (device->enc_type) {
+ device->enc_type = 0;
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE,
+ "EncryptionType");
+ }
+
device_update_last_seen(device, bdaddr_type, true);
g_slist_free_full(device->eir_uuids, g_free);
--
2.43.0
next prev parent reply other threads:[~2026-11-26 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 8:52 [PATCH BlueZ v6 0/5] client/btpclient: Security Level reporting Frédéric Danis
2026-11-26 8:52 ` [PATCH BlueZ v6 1/5] device: Provide Security Level props when kernel supports them Frédéric Danis
2026-11-26 15:13 ` client/btpclient: Security Level reporting bluez.test.bot
2026-11-26 8:52 ` [PATCH BlueZ v6 2/5] org.bluez.Device: Make Security Level props optional Frédéric Danis
2026-11-26 8:52 ` [PATCH BlueZ v6 3/5] client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support Frédéric Danis
2026-11-26 8:52 ` Frédéric Danis [this message]
2026-11-26 8:52 ` [PATCH BlueZ v6 5/5] client/btpclient: Suppress duplicate BTP security-level events Frédéric Danis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126085211.80204-5-frederic.danis@collabora.com \
--to=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox