linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] adapter: Fix up address type for all keys
@ 2024-11-04 20:35 Luiz Augusto von Dentz
  2024-11-04 22:43 ` [BlueZ,v1] " bluez.test.bot
  2024-11-04 22:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2024-11-04 20:35 UTC (permalink / raw)
  To: linux-bluetooth

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(-)

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);
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ,v1] adapter: Fix up address type for all keys
  2024-11-04 20:35 [PATCH BlueZ v1] adapter: Fix up address type for all keys Luiz Augusto von Dentz
@ 2024-11-04 22:43 ` bluez.test.bot
  2024-11-04 22:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-11-04 22:43 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 949 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=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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ v1] adapter: Fix up address type for all keys
  2024-11-04 20:35 [PATCH BlueZ v1] adapter: Fix up address type for all keys Luiz Augusto von Dentz
  2024-11-04 22:43 ` [BlueZ,v1] " bluez.test.bot
@ 2024-11-04 22:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2024-11-04 22:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-04 22:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 20:35 [PATCH BlueZ v1] adapter: Fix up address type for all keys Luiz Augusto von Dentz
2024-11-04 22:43 ` [BlueZ,v1] " bluez.test.bot
2024-11-04 22:50 ` [PATCH BlueZ v1] " 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;
as well as URLs for NNTP newsgroup(s).