Skip to contentSkip to conversation

Bluetooth: Fix BR/EDR-only address checks for remote OOB data

PATCH Superseded Johan Hedberg 2 participants 3 messages Nov 17, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix BR/EDR-only address checks for remote OOB data

From: Johan Hedberg <[email protected]>

For now the mgmt commands dealing with remote OOB data are strictly BR/EDR-only. This patch fixes missing checks for the passed address type so that any non-BR/EDR value triggers the appropriate error response.

---
 net/bluetooth/mgmt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
net/bluetooth/mgmt.c +19 -0
index b84c0923ec62..aaaa605f48b0 100644
@@ -3589,6 +3589,13 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
 		struct mgmt_cp_add_remote_oob_data *cp = data;
 		u8 status;
 
+		if (cp->addr.type != BDADDR_BREDR) {
+			err = cmd_status(sk, hdev->id,
+					 MGMT_OP_ADD_REMOTE_OOB_DATA,
+					 MGMT_STATUS_INVALID_PARAMS);
+			goto unlock;
+		}
+
 		err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr,
 					      cp->hash, cp->randomizer);
 		if (err < 0)
@@ -3602,6 +3609,13 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
 		struct mgmt_cp_add_remote_oob_ext_data *cp = data;
 		u8 status;
 
+		if (cp->addr.type != BDADDR_BREDR) {
+			err = cmd_status(sk, hdev->id,
+					 MGMT_OP_ADD_REMOTE_OOB_DATA,
+					 MGMT_STATUS_INVALID_PARAMS);
+			goto unlock;
+		}
+
 		err = hci_add_remote_oob_ext_data(hdev, &cp->addr.bdaddr,
 						  cp->hash192,
 						  cp->randomizer192,
@@ -3620,6 +3634,7 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
 				 MGMT_STATUS_INVALID_PARAMS);
 	}
 
+unlock:
 	hci_dev_unlock(hdev);
 	return err;
 }
@@ -3633,6 +3648,10 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
 
 	BT_DBG("%s", hdev->name);
 
+	if (cp->addr.type != BDADDR_BREDR)
+		return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+				  MGMT_STATUS_INVALID_PARAMS);
+
 	hci_dev_lock(hdev);
 
 	if (!bacmp(&cp->addr.bdaddr, BDADDR_ANY)) {
Signature · 1 line
2.1.0
#1 lore raw

Hi Johan,

Quoted 16 lines · On Monday 17 of November 2014 18:49:25 Johan Hedberg wrote:

From: Johan Hedberg <[email protected]>

For now the mgmt commands dealing with remote OOB data are strictly BR/EDR-only. This patch fixes missing checks for the passed address type so that any non-BR/EDR value triggers the appropriate error response.

---
 net/bluetooth/mgmt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
net/bluetooth/mgmt.c +0 -0
index b84c0923ec62..aaaa605f48b0 100644

net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, · line 3597

Quoted 9 lines
net/bluetooth/mgmt.c +6 -0
@@ -3589,6 +3589,13 @@ static int add_remote_oob_data(struct sock *sk,
 struct hci_dev *hdev, struct mgmt_cp_add_remote_oob_data *cp = data;
 		u8 status;
 
+		if (cp->addr.type != BDADDR_BREDR) {
+			err = cmd_status(sk, hdev->id,
+					 MGMT_OP_ADD_REMOTE_OOB_DATA,
+					 MGMT_STATUS_INVALID_PARAMS);
+			goto unlock;
+		}

This should generate command complete event.
(it looks like there is also similar bug in 'else' case in the code)

Quoted 5 lines
net/bluetooth/mgmt.c +1 -0
+
 		err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr,
 					      cp->hash, cp->randomizer);
 		if (err < 0)

net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, · line 3617

Quoted 9 lines
net/bluetooth/mgmt.c +6 -0
@@ -3602,6 +3609,13 @@ static int add_remote_oob_data(struct sock *sk,
 struct hci_dev *hdev, struct mgmt_cp_add_remote_oob_ext_data *cp = data;
 		u8 status;
 
+		if (cp->addr.type != BDADDR_BREDR) {
+			err = cmd_status(sk, hdev->id,
+					 MGMT_OP_ADD_REMOTE_OOB_DATA,
+					 MGMT_STATUS_INVALID_PARAMS);
+			goto unlock;
+		}

Same here.

Quoted 13 lines
net/bluetooth/mgmt.c +2 -0
+
 		err = hci_add_remote_oob_ext_data(hdev, &cp->addr.bdaddr,
 						  cp->hash192,
 						  cp->randomizer192,
@@ -3620,6 +3634,7 @@ static int add_remote_oob_data(struct sock *sk, struct
 hci_dev *hdev, MGMT_STATUS_INVALID_PARAMS);
 	}
 
+unlock:
 	hci_dev_unlock(hdev);
 	return err;
 }

net/bluetooth/mgmt.c static int remove_remote_oob_data(struct sock *sk, · line 3655

Quoted 8 lines
net/bluetooth/mgmt.c +4 -0
@@ -3633,6 +3648,10 @@ static int remove_remote_oob_data(struct sock *sk,
 struct hci_dev *hdev,
 
 	BT_DBG("%s", hdev->name);
 
+	if (cp->addr.type != BDADDR_BREDR)
+		return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+				  MGMT_STATUS_INVALID_PARAMS);
+

And here.

Quoted 3 lines
net/bluetooth/mgmt.c +0 -0
 	hci_dev_lock(hdev);
 

if (!bacmp(&cp->addr.bdaddr, BDADDR_ANY)) {

Signature · 2 lines
BR
Szymon Janc
#2 lore raw

Hy Szymon,

Quoted 20 lines · Szymon Janc
Quoted 19 lines · On Monday 17 of November 2014 18:49:25 Johan Hedberg wrote:

From: Johan Hedberg <[email protected]>

For now the mgmt commands dealing with remote OOB data are strictly BR/EDR-only. This patch fixes missing checks for the passed address type so that any non-BR/EDR value triggers the appropriate error response.

---
 net/bluetooth/mgmt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
net/bluetooth/mgmt.c +0 -0
index b84c0923ec62..aaaa605f48b0 100644
@@ -3589,6 +3589,13 @@ static int add_remote_oob_data(struct sock *sk,
 struct hci_dev *hdev, struct mgmt_cp_add_remote_oob_data *cp = data;
 		u8 status;
 
Quoted 9 lines

net/bluetooth/mgmt.c static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, · line 3597

Quoted 6 lines
net/bluetooth/mgmt.c +6 -0
+		if (cp->addr.type != BDADDR_BREDR) {
+			err = cmd_status(sk, hdev->id,
+					 MGMT_OP_ADD_REMOTE_OOB_DATA,
+					 MGMT_STATUS_INVALID_PARAMS);
+			goto unlock;
+		}

This should generate command complete event.
(it looks like there is also similar bug in 'else' case in the code)

Good point! v2 coming in a minute (also resending my other patch to avoid conflicts).

Johan