2015-07-13 12:36:45

by Jakub Pawlowski

[permalink] [raw]
Subject: [PATCH] Bluetooth: Fix Add Device response status

Make sure that MGMT_STATUS_INVALID_PARAMS is returned when non identity
address is passed to ADD_DEVICE. Right now MGMT_STATUS_FAILED is
returned, which might be misleading.

Signed-off-by: Jakub Pawlowski <[email protected]>
---
net/bluetooth/mgmt.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7998fb2..47462bf 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6226,6 +6226,13 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
else
auto_conn = HCI_AUTO_CONN_REPORT;

+ /* Allow only identity addresses */
+ if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
+ err = cmd->cmd_complete(cmd, MGMT_STATUS_INVALID_PARAMS);
+ mgmt_pending_remove(cmd);
+ goto unlock;
+ }
+
/* If the connection parameters don't exist for this device,
* they will be created and configured with defaults.
*/
--
2.1.4



2015-07-30 12:15:20

by Jakub Pawlowski

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix Add Device response status

On Thu, Jul 30, 2015 at 1:54 PM, Marcel Holtmann <[email protected]> wrote:
> Hi Jakub,
>
>> Make sure that MGMT_STATUS_INVALID_PARAMS is returned when non identity
>> address is passed to ADD_DEVICE. Right now MGMT_STATUS_FAILED is
>> returned, which might be misleading.
>>
>> Signed-off-by: Jakub Pawlowski <[email protected]>
>> ---
>> net/bluetooth/mgmt.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>> index 7998fb2..47462bf 100644
>> --- a/net/bluetooth/mgmt.c
>> +++ b/net/bluetooth/mgmt.c
>> @@ -6226,6 +6226,13 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
>> else
>> auto_conn = HCI_AUTO_CONN_REPORT;
>>
>> + /* Allow only identity addresses */
>> + if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
>> + err = cmd->cmd_complete(cmd, MGMT_STATUS_INVALID_PARAMS);
>> + mgmt_pending_remove(cmd);
>> + goto unlock;
>> + }
>> +
>
> did we loose this patch or is it no longer needed?
>
It's no longer needed, it was squashed with other patch.
Thanks,
Jakub
> Regards
>
> Marcel
>

2015-07-30 11:54:31

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix Add Device response status

Hi Jakub,

> Make sure that MGMT_STATUS_INVALID_PARAMS is returned when non identity
> address is passed to ADD_DEVICE. Right now MGMT_STATUS_FAILED is
> returned, which might be misleading.
>
> Signed-off-by: Jakub Pawlowski <[email protected]>
> ---
> net/bluetooth/mgmt.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 7998fb2..47462bf 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -6226,6 +6226,13 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
> else
> auto_conn = HCI_AUTO_CONN_REPORT;
>
> + /* Allow only identity addresses */
> + if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) {
> + err = cmd->cmd_complete(cmd, MGMT_STATUS_INVALID_PARAMS);
> + mgmt_pending_remove(cmd);
> + goto unlock;
> + }
> +

did we loose this patch or is it no longer needed?

Regards

Marcel