Skip to content

Commit 33c525c

Browse files
jhedbergGustavo Padovan
authored andcommitted
Bluetooth: mgmt: Restrict BR/EDR settings to BR/EDR-only adapters
This patch makes sure that settings which are specific for BR/EDR capable adapters are not allowed for non-BR/EDR (e.g. LE-only) adapters. Instead, a "not supported" error is returned of such a setting is attempted to be set for a non-BR/EDR adapter. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 7f0ae64 commit 33c525c

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎net/bluetooth/mgmt.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@ static u32 get_supported_settings(struct hci_dev *hdev)
376376
u32 settings = 0;
377377

378378
settings |= MGMT_SETTING_POWERED;
379-
settings |= MGMT_SETTING_CONNECTABLE;
380-
settings |= MGMT_SETTING_FAST_CONNECTABLE;
381-
settings |= MGMT_SETTING_DISCOVERABLE;
382379
settings |= MGMT_SETTING_PAIRABLE;
383380

384381
if (lmp_ssp_capable(hdev))
385382
settings |= MGMT_SETTING_SSP;
386383

387384
if (lmp_bredr_capable(hdev)) {
385+
settings |= MGMT_SETTING_CONNECTABLE;
386+
settings |= MGMT_SETTING_FAST_CONNECTABLE;
387+
settings |= MGMT_SETTING_DISCOVERABLE;
388388
settings |= MGMT_SETTING_BREDR;
389389
settings |= MGMT_SETTING_LINK_SECURITY;
390390
}
@@ -867,6 +867,10 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
867867

868868
BT_DBG("request for %s", hdev->name);
869869

870+
if (!lmp_bredr_capable(hdev))
871+
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
872+
MGMT_STATUS_NOT_SUPPORTED);
873+
870874
timeout = __le16_to_cpu(cp->timeout);
871875
if (!cp->val && timeout > 0)
872876
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
@@ -962,6 +966,10 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
962966

963967
BT_DBG("request for %s", hdev->name);
964968

969+
if (!lmp_bredr_capable(hdev))
970+
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
971+
MGMT_STATUS_NOT_SUPPORTED);
972+
965973
hci_dev_lock(hdev);
966974

967975
if (!hdev_is_powered(hdev)) {
@@ -1060,6 +1068,10 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
10601068

10611069
BT_DBG("request for %s", hdev->name);
10621070

1071+
if (!lmp_bredr_capable(hdev))
1072+
return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
1073+
MGMT_STATUS_NOT_SUPPORTED);
1074+
10631075
hci_dev_lock(hdev);
10641076

10651077
if (!hdev_is_powered(hdev)) {
@@ -2594,6 +2606,10 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
25942606

25952607
BT_DBG("%s", hdev->name);
25962608

2609+
if (!lmp_bredr_capable(hdev))
2610+
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
2611+
MGMT_STATUS_NOT_SUPPORTED);
2612+
25972613
if (!hdev_is_powered(hdev))
25982614
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
25992615
MGMT_STATUS_NOT_POWERED);

0 commit comments

Comments
 (0)