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 DECEF2DE6E3; Tue, 12 May 2026 18:07:08 +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=1778609228; cv=none; b=O3NPK0k2YWrm+dNrz6MjT3o+G9nReT2tlyJzzX35oWOiIxQgPll5eGaRKjFgFozYMePOIOt2DYYQNE2GlmjRLAr8tYYFD/6AnmrOivNRWW+jnujp37FMPY5Xlp/mIb2WpQNWHWybXv8Oab5kdbbOSPQfjXfodoyx3cr/OKs/xNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778609228; c=relaxed/simple; bh=mga2/kU+JmQjnw4T8XXPWZU2mOXVBtNVtCbg7oFttnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqW619Z9l9eMDi5F53ZR/6ev262wOnzd6huvsBlPfWHujiukdWEU2hh7iZpcjP6XmcUFnHZk4doPiPzeMNWMpcSFaYrHTNUQnBi7HWoxSnlvES9GNRQ6enxaMdubvJX1mXuY6K1hnFFgzerKa8M3rx/zwHMtG/2a5jJcaZEEVSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ehilg97a; 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="Ehilg97a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CCD0C2BCB0; Tue, 12 May 2026 18:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778609228; bh=mga2/kU+JmQjnw4T8XXPWZU2mOXVBtNVtCbg7oFttnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ehilg97agYhKFWYiKrSL6U2xL5PSpZjWztAq5Zzyo5tZS+cTOKR1ngG8K/culNBpa 4hzec8/8BBdKFS7m8Xgugv/nGb6PaQy1B2jxXYmzXSr8AZVm2Ms+YTFX8ZDYKojbWW 42g8r/158vnsR+Dxl0PovXP/DJ5FJjYQQcGS3CiI= 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 7.0 073/307] Bluetooth: hci_event: Fix OOB read and infinite loop in hci_le_create_big_complete_evt Date: Tue, 12 May 2026 19:37:48 +0200 Message-ID: <20260512173941.662971167@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173940.117428952@linuxfoundation.org> References: <20260512173940.117428952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-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 @@ -7121,9 +7121,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); @@ -7132,7 +7152,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