From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F21F3D1709 for ; Mon, 30 Mar 2026 14:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774879467; cv=none; b=B5zN/sa8SY31njwJ5bpowFy9qz7K3nXhna1dqMe2Ro4KoEN+H9FO2wjUGc2x8PzXWaqz3CxytDx7PfnIhunf40WE1Rk8Ar1+6ovaFfVnCZrGccOomxGOuX052gA9GCW2YYzBo5nN6M7XtFFJe+jefGteJ9zeH2opgaJe2r8umcU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774879467; c=relaxed/simple; bh=L0gl5ZvGzXWpu5CM/BlfL3VlES43T/wr0UNKCn7zalw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Gdy+TOBtQbB00kXUJVfbW+g663agcqWhX+OlxFENcOyo6/QHqiio485dbbi45mgJFLko30n6UXICGAk7qHw4qEWTO6bPxqJQoHqGS6NJ+sjzPls1V4Lm8JeSU/RSpGzwCuekDmBAGclBHhrRB0Y9sieeyQz/qsBQ92rAXjTHzL8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZTI8viNu; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZTI8viNu" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-486fd5c4891so4986815e9.2 for ; Mon, 30 Mar 2026 07:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774879464; x=1775484264; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GDmJDYaQn1v0SJ7Zi6FTasnNARSB0I+h5h5AqOO5/W0=; b=ZTI8viNuGfdq3Xli1FuOKsqDPUUeiTDqwELcxgU1/I0lRGrRo4q7L/GDH4KiPPsdQ6 1ae3IBpYoQWFFiN8JDVMeAzO+24pG8KlaQ3EQnCrQBiIMT+QFZpHk/CaeCyQK64gFnxF OBDR8uEQiVWpKYDIzo3ssbL+iZqwAfpXA5ysYita+YbJZtwQaXboHBSA/V8riUmZfCIy mL1a9d56Q8G9IXSuDSdqI+5CpjfJyvKyheQIRUwvuavyeTRJaIrEDweHmC0GXW2A0/c+ uOEWLunlMc36v5Chbtx6mxLHAVsDAmy1PFpkpD7xIs4rYX68Xz9nSPBrK+/SQ87m/wvV RXmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774879464; x=1775484264; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GDmJDYaQn1v0SJ7Zi6FTasnNARSB0I+h5h5AqOO5/W0=; b=l4x2Icz9Wmsr8WeBNOctRZYclachDrl1qjM0fFErVtUQ2wbJ2RNE8AojSA9AOWxRED Dx+qhFBeBUMqAIpWeLdAWIx9oCZp4fSmVMjN60ZNzhDi/xCbM8a3jaE2VhthWtVtFeKk jeEJ6OgO3FHsaONdeEC17s0RRKGFk7fCxyk0xlGA6R11RjjoJXiSyc+n/NNUiQ/DULbB ZvWdvv4wm+WoVx5J4EBdbUTW57LhS6GDf4jozKMtgDvOvXZ/mo4EyjcnzTItISmoNHBm IPZXMdS5rT2K4GfaRXLBo2xZE21hZRII8iBwHnpAU5zJdf8MMQ8oyPSHIN5f6F9/nLgf wHyQ== X-Forwarded-Encrypted: i=1; AJvYcCXGFUgQgoVYth08GrxoYb9jn5AtXyk+/Uy8faePwgtHZIPZ162XXiHEY67/ZtjtBluFTUbQBh0CcTWOY64=@vger.kernel.org X-Gm-Message-State: AOJu0Yxkn58rkCb4o9oJ6cxHATzDViV74WAJBcC8goyq8p/R+S9gWxWa 7gaLENdF3cU9+GAFdg95kj/Ta1bB/9GdmliPf83EY3pqLCbTAsSm1DLZ X-Gm-Gg: ATEYQzzJtkHlsTyrPR7xeKXynvZniAbQFKE4Lc4yAvuwTTlG/+6pOGr4M40o4cW9BKa KGmsSAWsqkKnRhlo6Q6QtrifPGAm84MFcd4KVx5RjzsXRW8XX15KKEeSZ6tDXK57vk2fllNcait 4zjkni2QvvD6XG3mGo8EIAwplqMMu6bNORLQt93mnAWhkCjxZAOIKcMZ1/efE4FyOTaysQJYIie 6Elq1BKz7A1A6sxFJhM/u/+X6nQVU3l7bhqXpG9GYKFLT1HZCPaxZP5eTRRWQF8Y47jBq+VJoIA IO93RQgST9Suz3GYMCyAiNaNRb74CgE30BqAG0Liiv8WSnH6bUe5Dtqe5clyprIFqkNq6n6Lkwg GccG5LpppZ2APy7GWYCGsmWnQLKYoiQwBbdQSMtPyLKShmPsdtCWj5Ofi8O6daiZewVpCo2QJJM xPe/eBGTPoA8SWQ1jdHTFB3xo7S7TSbBX8IbqatHRQJ1atuCGYfo+EfC97QdNDKhHeYlib25caN o3h6SeX/J+0gK1gouiB9QUvqeE4 X-Received: by 2002:a05:600c:c178:b0:487:1fbb:5a1c with SMTP id 5b1f17b1804b1-48727ef5629mr113171685e9.2.1774879464062; Mon, 30 Mar 2026 07:04:24 -0700 (PDT) Received: from localhost ([2a01:cb1d:4ec:6700:174f:90cc:2ec3:a84b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722c6b495sm541568475e9.2.2026.03.30.07.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 07:04:23 -0700 (PDT) From: Aaron Esau X-Google-Original-From: Aaron Esau To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, Aaron Esau Subject: [PATCH 1/3] Bluetooth: hci_conn: fix UAF in create_big_sync and create_big_complete Date: Mon, 30 Mar 2026 16:03:47 +0200 Message-ID: <20260330140347.906689-2-git@aaronesau.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Aaron Esau 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 --- 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