2012-04-16 05:13:01

by Hemant Gupta

[permalink] [raw]
Subject: [PATCH] Bluetooth: mgmt: Fix address type while loading Long Term Key

This patch fixes the address type while loading long term keys when BT is
switched on. Without this fix pairing is reinitated even though LTK exists
for remote device because of mismatch of address type.

Signed-off-by: Hemant Gupta <[email protected]>
---
net/bluetooth/mgmt.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 880b7c9..b84de64 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2652,7 +2652,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
else
type = HCI_SMP_LTK_SLAVE;

- hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
+ hci_add_ltk(hdev, &key->addr.bdaddr,
+ mgmt_to_link(LE_LINK, key->addr.type),
type, 0, key->authenticated, key->val,
key->enc_size, key->ediv, key->rand);
}
--
1.7.0.4



2012-04-16 09:05:27

by Hemant Gupta

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: mgmt: Fix address type while loading Long Term Key

Hi Johan,

On Mon, Apr 16, 2012 at 2:15 PM, Johan Hedberg <[email protected]> wrote:
> Hi Hemant,
>
> On Mon, Apr 16, 2012, Hemant Gupta wrote:
>> This patch fixes the address type while loading long term keys when BT is
>> switched on. Without this fix pairing is reinitated even though LTK exists
>> for remote device because of mismatch of address type.
>>
>> Signed-off-by: Hemant Gupta <[email protected]>
>> ---
>> ?net/bluetooth/mgmt.c | ? ?3 ++-
>> ?1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>> index 880b7c9..b84de64 100644
>> --- a/net/bluetooth/mgmt.c
>> +++ b/net/bluetooth/mgmt.c
>> @@ -2652,7 +2652,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
>> ? ? ? ? ? ? ? else
>> ? ? ? ? ? ? ? ? ? ? ? type = HCI_SMP_LTK_SLAVE;
>>
>> - ? ? ? ? ? ? hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
>> + ? ? ? ? ? ? hci_add_ltk(hdev, &key->addr.bdaddr,
>> + ? ? ? ? ? ? ? ? ? ? ? ? mgmt_to_link(LE_LINK, key->addr.type),
>> ? ? ? ? ? ? ? ? ? ? ? ? ? type, 0, key->authenticated, key->val,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? key->enc_size, key->ediv, key->rand);
>> ? ? ? }
>
> This doesn't compile:
>
> net/bluetooth/mgmt.c: In function 'load_long_term_keys':
> net/bluetooth/mgmt.c:2656:8: error: implicit declaration of function 'mgmt_to_link' [-Werror=implicit-function-declaration]
Thanks for comment, I forgot to send a dependent patch somehow. have
sent it now.

>
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html



--
Best Regards
Hemant Gupta
ST-Ericsson India

2012-04-16 08:45:22

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: mgmt: Fix address type while loading Long Term Key

Hi Hemant,

On Mon, Apr 16, 2012, Hemant Gupta wrote:
> This patch fixes the address type while loading long term keys when BT is
> switched on. Without this fix pairing is reinitated even though LTK exists
> for remote device because of mismatch of address type.
>
> Signed-off-by: Hemant Gupta <[email protected]>
> ---
> net/bluetooth/mgmt.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 880b7c9..b84de64 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -2652,7 +2652,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
> else
> type = HCI_SMP_LTK_SLAVE;
>
> - hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
> + hci_add_ltk(hdev, &key->addr.bdaddr,
> + mgmt_to_link(LE_LINK, key->addr.type),
> type, 0, key->authenticated, key->val,
> key->enc_size, key->ediv, key->rand);
> }

This doesn't compile:

net/bluetooth/mgmt.c: In function 'load_long_term_keys':
net/bluetooth/mgmt.c:2656:8: error: implicit declaration of function 'mgmt_to_link' [-Werror=implicit-function-declaration]

Johan