Skip to content

Commit 385b2d0

Browse files
pvgregkh
authored andcommitted
Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER
[ Upstream commit 5c7209a ] When protocol sets HCI_PROTO_DEFER, hci_conn_request_evt() calls hci_connect_cfm(conn) without hdev->lock. Generally hci_connect_cfm() assumes it is held, and if conn is deleted concurrently -> UAF. Only SCO and ISO set HCI_PROTO_DEFER and only for defer setup listen, and HCI_EV_CONN_REQUEST is not generated for ISO. In the non-deferred listening socket code paths, hci_connect_cfm(conn) is called with hdev->lock held. Fix by holding the lock. Fixes: 70c4642 ("Bluetooth: Refactor connection request handling") Signed-off-by: Pauli Virtanen <pav@iki.fi> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3daa581 commit 385b2d0

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

net/bluetooth/hci_event.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,8 +3309,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
33093309

33103310
memcpy(conn->dev_class, ev->dev_class, 3);
33113311

3312-
hci_dev_unlock(hdev);
3313-
33143312
if (ev->link_type == ACL_LINK ||
33153313
(!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) {
33163314
struct hci_cp_accept_conn_req cp;
@@ -3344,7 +3342,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
33443342
hci_connect_cfm(conn, 0);
33453343
}
33463344

3347-
return;
33483345
unlock:
33493346
hci_dev_unlock(hdev);
33503347
}

0 commit comments

Comments
 (0)