public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: hci_conn: fix UAF in create_big_sync and create_big_complete
@ 2026-03-30 14:03 Aaron Esau
  2026-03-30 14:03 ` [PATCH 3/3] Bluetooth: hci_conn: fix UAF in hci_enhanced_setup_sync Aaron Esau
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Esau @ 2026-03-30 14:03 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, marcel, johan.hedberg, linux-kernel, Aaron Esau

From: Aaron Esau <aaron1esau@gmail.com>

hci_connect_bis() queues create_big_sync with a raw conn pointer.
create_big_sync blocks in __hci_cmd_sync_sk while a concurrent
hci_conn_del on hdev->workqueue frees conn. On timeout, freed memory
is dereferenced. The dequeue path also double-frees: hci_conn_del
invokes create_big_complete via hci_cmd_sync_dequeue, which calls
hci_conn_del again.

Take hci_conn_get before queueing, add hci_conn_valid checks, handle
-ECANCELED, drop with hci_conn_put in create_big_complete. Follows
the create_le_conn_complete pattern.

Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Signed-off-by: Aaron Esau <aaron1esau@gmail.com>
---
 net/bluetooth/hci_conn.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index dc08585..59f5451 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -2119,11 +2119,16 @@ static void hci_iso_qos_setup(struct hci_dev *hdev, struct hci_conn *conn,
 static int create_big_sync(struct hci_dev *hdev, void *data)
 {
 	struct hci_conn *conn = data;
-	struct bt_iso_qos *qos = &conn->iso_qos;
+	struct bt_iso_qos *qos;
 	u16 interval, sync_interval = 0;
 	u32 flags = 0;
 	int err;
 
+	if (!hci_conn_valid(hdev, conn))
+		return -ECANCELED;
+
+	qos = &conn->iso_qos;
+
 	if (qos->bcast.out.phy == 0x02)
 		flags |= MGMT_ADV_FLAG_SEC_2M;
 
@@ -2198,11 +2203,24 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err)
 
 	bt_dev_dbg(hdev, "conn %p", conn);
 
+	if (err == -ECANCELED)
+		goto done;
+
+	hci_dev_lock(hdev);
+
+	if (!hci_conn_valid(hdev, conn))
+		goto unlock;
+
 	if (err) {
 		bt_dev_err(hdev, "Unable to create BIG: %d", err);
 		hci_connect_cfm(conn, err);
 		hci_conn_del(conn);
 	}
+
+unlock:
+	hci_dev_unlock(hdev);
+done:
+	hci_conn_put(conn);
 }
 
 struct hci_conn *hci_bind_bis(struct hci_dev *hdev, bdaddr_t *dst, __u8 sid,
@@ -2331,9 +2349,11 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
 				 BT_BOUND, &data);
 
 	/* Queue start periodic advertising and create BIG */
+	hci_conn_get(conn);
 	err = hci_cmd_sync_queue(hdev, create_big_sync, conn,
 				 create_big_complete);
 	if (err < 0) {
+		hci_conn_put(conn);
 		hci_conn_drop(conn);
 		return ERR_PTR(err);
 	}
-- 
2.52.0


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 14:03 [PATCH 1/3] Bluetooth: hci_conn: fix UAF in create_big_sync and create_big_complete Aaron Esau
2026-03-30 14:03 ` [PATCH 3/3] Bluetooth: hci_conn: fix UAF in hci_enhanced_setup_sync Aaron Esau

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