Skip to contentSkip to conversation

Bluetooth: Fix NULL pointer dereference in smp_conn_security

PATCH In review Johan Hedberg 2 participants 2 messages Jul 20, 2015 – Jul 23, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix NULL pointer dereference in smp_conn_security

From: Johan Hedberg <[email protected]>

The l2cap_conn->smp pointer may be NULL for various valid reasons where SMP has failed to initialize properly. One such scenario is when crypto support is missing, another when the adapter has been powered on through a legacy method. The smp_conn_security() function should have the appropriate check for this situation to avoid NULL pointer dereferences.

---
 net/bluetooth/smp.c | 4 ++++
 1 file changed, 4 insertions(+)
net/bluetooth/smp.c +4 -0
index 3d0f7d2a0616..ad82324f710f 100644
@@ -2312,6 +2312,10 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
 		return 1;
 
 	chan = conn->smp;
+	if (!chan) {
+		BT_ERR("SMP security requested but not available");
+		return 1;
+	}
 
 	if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED))
 		return 1;
Signature · 1 line
2.4.3
maintainer
#1 lore raw

Hi Johan,

Quoted 11 lines

The l2cap_conn->smp pointer may be NULL for various valid reasons where SMP has failed to initialize properly. One such scenario is when crypto support is missing, another when the adapter has been powered on through a legacy method. The smp_conn_security() function should have the appropriate check for this situation to avoid NULL pointer dereferences.

---
net/bluetooth/smp.c | 4 ++++

1 file changed, 4 insertions(+)

patch has been applied to bluetooth-stable tree.

Regards

Marcel