public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER
@ 2026-03-29 13:42 Pauli Virtanen
  2026-03-29 13:43 ` [PATCH] Bluetooth: hci_sync: fix refcounting in le_read_features_complete Pauli Virtanen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pauli Virtanen @ 2026-03-29 13:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

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: 70c464256310 ("Bluetooth: Refactor connection request handling")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---

Notes:
    This defer listen code path is covered by sco-tester
    SCO CVSD Listen Defer - Success

 net/bluetooth/hci_event.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 3ebc5e6d45d9..83248085dd4f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3340,8 +3340,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
 
 	memcpy(conn->dev_class, ev->dev_class, 3);
 
-	hci_dev_unlock(hdev);
-
 	if (ev->link_type == ACL_LINK ||
 	    (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) {
 		struct hci_cp_accept_conn_req cp;
@@ -3375,7 +3373,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
 		hci_connect_cfm(conn, 0);
 	}
 
-	return;
 unlock:
 	hci_dev_unlock(hdev);
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-29 14:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29 13:42 [PATCH] Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER Pauli Virtanen
2026-03-29 13:43 ` [PATCH] Bluetooth: hci_sync: fix refcounting in le_read_features_complete Pauli Virtanen
2026-03-29 14:11   ` bluez.test.bot
2026-03-29 13:43 ` [PATCH v3] Bluetooth: hci_conn: fix potential UAF in set_cig_params_sync Pauli Virtanen
2026-03-29 14:10   ` [v3] " bluez.test.bot
2026-03-29 13:43 ` [PATCH v3] Bluetooth: hci_event: fix potential UAF in hci_le_remote_conn_param_req_evt Pauli Virtanen
2026-03-29 14:11   ` [v3] " bluez.test.bot
2026-03-29 14:10 ` Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox