adapter: Fix up address type for all keys
Luiz Augusto von Dentz
maintainerPATCH 1/1 adapter: Fix up address type for all keys
From: Luiz Augusto von Dentz <[email protected]>
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(-)
src/adapter.c +25 -19
@@ -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, <k->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);
Signature · 1 line
2.47.0
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
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Mon, 4 Nov 2024 15:35:49 -0500 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html