Skip to contentSkip to conversation

Bluetooth: Fix link security setting when powering on

PATCH Superseded Johan Hedberg 2 participants 3 messages Jan 26, 2013 – Jan 27, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Bluetooth: Fix link security setting when powering on

From: Johan Hedberg <[email protected]>

If a controller is powered on while the HCI_AUTO_OFF flag is set the link security setting (HCI_LINK_SECURITY) might not be in sync with the actual state of the controller (HCI_AUTH). This patch fixes the issue by checking for inequality between the intended and actual settings and sends a HCI_Write_Auth_Enable command if necessary.

---
 net/bluetooth/mgmt.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/bluetooth/mgmt.c +7 -0
index fbc8edf..f6ef8ff 100644
@@ -3096,6 +3096,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 					     sizeof(cp), &cp);
 		}
 
+		if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags) !=
+		    test_bit(HCI_AUTH, &hdev->flags)) {
+			u8 val = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
+			hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
+				     sizeof(val), &val);
+		}
+
 		if (lmp_bredr_capable(hdev)) {
 			set_bredr_scan(hdev);
 			update_class(hdev);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 Bluetooth: Increment Management interface revision

From: Johan Hedberg <[email protected]>

The fixing of several mgmt issues, such as the correct handling of 32 and 128 bit UUIDs means that it is now safe for user space to send such commands. However, user space needs a way to detect that it is safe, so increment the mgmt revision so that it can be checked against.

---
 net/bluetooth/mgmt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/mgmt.c +1 -1
index f6ef8ff..8e69d89 100644
@@ -35,7 +35,7 @@
 bool enable_hs;
 
 #define MGMT_VERSION	1
-#define MGMT_REVISION	2
+#define MGMT_REVISION	3
 
 static const u16 mgmt_commands[] = {
 	MGMT_OP_READ_INDEX_LIST,
Signature · 1 line
1.7.10.4
maintainer
#2 lore raw
In reply to Johan Hedberg

Hi Johan,

Quoted 16 lines

If a controller is powered on while the HCI_AUTO_OFF flag is set the link security setting (HCI_LINK_SECURITY) might not be in sync with the actual state of the controller (HCI_AUTH). This patch fixes the issue by checking for inequality between the intended and actual settings and sends a HCI_Write_Auth_Enable command if necessary.

---
 net/bluetooth/mgmt.c |    7 +++++++
 1 file changed, 7 insertions(+)
net/bluetooth/mgmt.c +0 -0
index fbc8edf..f6ef8ff 100644

net/bluetooth/mgmt.c int mgmt_powered(struct hci_dev *hdev, u8 powered) · line 3104

Quoted 9 lines
net/bluetooth/mgmt.c +6 -0
@@ -3096,6 +3096,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 					     sizeof(cp), &cp);
 		}
 
+		if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags) !=
+		    test_bit(HCI_AUTH, &hdev->flags)) {
+			u8 val = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
+			hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
+				     sizeof(val), &val);
+		}

why not actually just test for the value and store its result, then compare and then use the value. Testing HCI_LINK_SECURITY twice seems a bit too much.

Regards

Marcel