diff mbox series

[BlueZ,v1] adapter: Fix up address type for all keys

Message ID 20241104203549.772512-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 7322ec38fb65afe8f34b9e363ed9fce37e1ff868
Headers show
Series [BlueZ,v1] adapter: Fix up address type for all keys | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Luiz Augusto von Dentz Nov. 4, 2024, 8:35 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

66a8c522b64 ("adapter: Fix up address type when loading keys") didn't
fix all instances of wrong address type being loaded, so peripheral LTK
and IRK were still left with possible invalid types.
---
 src/adapter.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

Comments

bluez.test.bot@gmail.com Nov. 4, 2024, 10:43 p.m. UTC | #1
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=906247

---Test result---

Test Summary:
CheckPatch                    PASS      0.35 seconds
GitLint                       PASS      0.22 seconds
BuildEll                      PASS      24.80 seconds
BluezMake                     PASS      1705.03 seconds
MakeCheck                     PASS      13.50 seconds
MakeDistcheck                 PASS      181.90 seconds
CheckValgrind                 PASS      256.08 seconds
CheckSmatch                   PASS      360.59 seconds
bluezmakeextell               PASS      121.93 seconds
IncrementalBuild              PASS      1602.75 seconds
ScanBuild                     PASS      1028.36 seconds



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Nov. 4, 2024, 10:50 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon,  4 Nov 2024 15:35:49 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> 66a8c522b64 ("adapter: Fix up address type when loading keys") didn't
> fix all instances of wrong address type being loaded, so peripheral LTK
> and IRK were still left with possible invalid types.
> ---
>  src/adapter.c | 44 +++++++++++++++++++++++++-------------------
>  1 file changed, 25 insertions(+), 19 deletions(-)

Here is the summary with links:
  - [BlueZ,v1] adapter: Fix up address type for all keys
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7322ec38fb65

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index 2bb94cf1673e..f422bbaae155 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3994,6 +3994,13 @@  static struct link_key_info *get_key_info(GKeyFile *key_file, const char *peer,
 	str2ba(peer, &info->bdaddr);
 	info->bdaddr_type = bdaddr_type;
 
+	/* Fix up address type if it was stored with the wrong
+	 * address type since Load Link Keys are only meant to
+	 * work with BR/EDR addresses as per MGMT documentation.
+	 */
+	if (info->bdaddr_type != BDADDR_BREDR)
+		info->bdaddr_type = BDADDR_BREDR;
+
 	if (!strncmp(str, "0x", 2))
 		str2buf(&str[2], info->key, sizeof(info->key));
 	else
@@ -4035,6 +4042,13 @@  static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
 	str2ba(peer, &ltk->bdaddr);
 	ltk->bdaddr_type = peer_type;
 
+	/* Fix up address type if it was stored with the wrong
+	 * address type since Load Long Term Keys are only meant
+	 * to work with LE addresses as per MGMT documentation.
+	 */
+	if (ltk->bdaddr_type == BDADDR_BREDR)
+		ltk->bdaddr_type = BDADDR_LE_PUBLIC;
+
 	/*
 	 * Long term keys should respond to an identity address which can
 	 * either be a public address or a random static address. Keys
@@ -4117,7 +4131,8 @@  static struct irk_info *get_irk_info(GKeyFile *key_file, const char *peer,
 	struct irk_info *irk = NULL;
 	char *str;
 
-	str = g_key_file_get_string(key_file, "IdentityResolvingKey", "Key", NULL);
+	str = g_key_file_get_string(key_file, "IdentityResolvingKey", "Key",
+					NULL);
 	if (!str || strlen(str) < 32)
 		goto failed;
 
@@ -4126,6 +4141,13 @@  static struct irk_info *get_irk_info(GKeyFile *key_file, const char *peer,
 	str2ba(peer, &irk->bdaddr);
 	irk->bdaddr_type = bdaddr_type;
 
+	/* Fix up address type if it was stored with the wrong
+	 * address type since Load Identity Keys are only meant
+	 * to work with LE addresses as per MGMT documentation.
+	 */
+	if (irk->bdaddr_type == BDADDR_BREDR)
+		irk->bdaddr_type = BDADDR_LE_PUBLIC;
+
 	if (!strncmp(str, "0x", 2))
 		str2buf(&str[2], irk->val, sizeof(irk->val));
 	else
@@ -5000,27 +5022,11 @@  static void load_devices(struct btd_adapter *adapter)
 			goto free;
 		}
 
-		if (key_info) {
-			/* Fix up address type if it was stored with the wrong
-			 * address type since Load Link Keys are only meant to
-			 * work with BR/EDR addresses as per MGMT documentation.
-			 */
-			if (key_info->bdaddr_type != BDADDR_BREDR)
-				key_info->bdaddr_type = BDADDR_BREDR;
-
+		if (key_info)
 			keys = g_slist_append(keys, key_info);
-		}
-
-		if (ltk_info) {
-			/* Fix up address type if it was stored with the wrong
-			 * address type since Load Long Term Keys are only meant
-			 * to work with LE addresses as per MGMT documentation.
-			 */
-			if (ltk_info->bdaddr_type == BDADDR_BREDR)
-				ltk_info->bdaddr_type = BDADDR_LE_PUBLIC;
 
+		if (ltk_info)
 			ltks = g_slist_append(ltks, ltk_info);
-		}
 
 		if (peripheral_ltk_info)
 			ltks = g_slist_append(ltks, peripheral_ltk_info);