From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B709A21FF21; Tue, 12 May 2026 17:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778607972; cv=none; b=dhHqlVqJ5+Jbul9L1T+OZv8GNyQRzbCkxCqUy2BHwpZ+MzUmTVxHhkxU6FiBRwBb+MpspmoN1iUUoWaliEPjiZ5uWD6N9Sa0FUXJAvjCf0RyQaM9dyS1+ua8EJgxOSFuRbu0BvXxpjSc1h95Ht3ndb5Guhb+gZbMkMaFzI6bZEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778607972; c=relaxed/simple; bh=QdbAjqvlJ87OURJN9XtnHPfoy2j9XUE3HKu3Pqhxg50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ea9lS+z2VrNJqziOKoGADLUB3LKNxS23zYr7qxRUQkc50mOuhOxHZ8KuCq2cUy/ytxcAx3l/iH5YbDsK4frkjih17kLS9w+LnfV6hcIbJy1UvUiTqdAQIY94JVd84IrMlv9kPTsjxKtjcdNEVmuGgWhuDEy86HGYcFnWKwmk3k8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QD8wox3w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QD8wox3w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D54CC2BCB0; Tue, 12 May 2026 17:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778607972; bh=QdbAjqvlJ87OURJN9XtnHPfoy2j9XUE3HKu3Pqhxg50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD8wox3wg0m+BJPZKxMwsZWg12IPwGwHs9w5FyX7h95wKi5ybMxYYQZshw9GK3jm7 SfJ00p0d8A60ABlMEQXnuTKujLFIRjkuij0lM3BBsCKu91BKAHKlV/BldW9oX901Qm cx70AFlGmSyCA6MCssMt/kwB0ml9OhYtkvbYelYs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ZhiTao Ou , Luiz Augusto von Dentz Subject: [PATCH 6.12 064/206] Bluetooth: hci_event: Fix OOB read and infinite loop in hci_le_create_big_complete_evt Date: Tue, 12 May 2026 19:38:36 +0200 Message-ID: <20260512173934.199638879@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173932.810559588@linuxfoundation.org> References: <20260512173932.810559588@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz commit 5ddb8014261137cadaf83ab5617a588d80a22586 upstream. hci_le_create_big_complete_evt() iterates over BT_BOUND connections for a BIG handle using a while loop, accessing ev->bis_handle[i++] on each iteration. However, there is no check that i stays within ev->num_bis before the array access. When a controller sends a LE_Create_BIG_Complete event with fewer bis_handle entries than there are BT_BOUND connections for that BIG, or with num_bis=0, the loop reads beyond the valid bis_handle[] flex array into adjacent heap memory. Since the out-of-bounds values typically exceed HCI_CONN_HANDLE_MAX (0x0EFF), hci_conn_set_handle() rejects them and the connection remains in BT_BOUND state. The same connection is then found again by hci_conn_hash_lookup_big_state(), creating an infinite loop with hci_dev_lock held. Fix this by terminating the BIG if in case not all BIS could be setup properly. Fixes: a0bfde167b50 ("Bluetooth: ISO: Add support for connecting multiple BISes") Cc: stable@vger.kernel.org Signed-off-by: ZhiTao Ou Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_event.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6935,9 +6935,29 @@ static void hci_le_create_big_complete_e continue; } + if (ev->num_bis <= i) { + bt_dev_err(hdev, + "Not enough BIS handles for BIG 0x%2.2x", + ev->handle); + ev->status = HCI_ERROR_UNSPECIFIED; + hci_connect_cfm(conn, ev->status); + hci_conn_del(conn); + continue; + } + if (hci_conn_set_handle(conn, - __le16_to_cpu(ev->bis_handle[i++]))) + __le16_to_cpu(ev->bis_handle[i++]))) { + bt_dev_err(hdev, + "Failed to set BIS handle for BIG 0x%2.2x", + ev->handle); + /* Force error so BIG gets terminated as not all BIS + * could be connected. + */ + ev->status = HCI_ERROR_UNSPECIFIED; + hci_connect_cfm(conn, ev->status); + hci_conn_del(conn); continue; + } conn->state = BT_CONNECTED; set_bit(HCI_CONN_BIG_CREATED, &conn->flags); @@ -6946,7 +6966,10 @@ static void hci_le_create_big_complete_e hci_iso_setup_path(conn); } - if (!ev->status && !i) + /* If there is an unexpected error or if no BISes have been connected + * for the BIG, terminate it. + */ + if (ev->status == HCI_ERROR_UNSPECIFIED || (!ev->status && !i)) /* If no BISes have been connected for the BIG, * terminate. This is in case all bound connections * have been closed before the BIG creation