From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386188; b=QB7mCc6FRnDdfx7NDQhEbESD1HmjIM5gLHxPr5D9WolRMyc23K+OOqoFvnI2/Ty3Z2CP ZbiJBOGRomzJU9gZAkkKnR+bmEJOVvgrFGwELRuPqfFzwJxnblP4HyWqUz5jiL5m0eUyH Ln0DTRNb2kj2Qyzs3yKpTgWVWbwSyut7h07lflDm49RCGkHoD5WxnxSIl0SL7UeCg9w8R 5NTC2CM3ythVjjhKFkF6o9p92PxEjVvyM9p7qNwiQmSmzsuMEHIdbuFXjXP1sv8fgfT9i 9XmqmlGAOYIEBsqtwDFNcibv07i9aThFA+ZtT2aGO+Ne9S5wym77GJH0uGY1WaoT/NA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386188; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=dAgXa9gtEH82bRd2GPcEl4vfkEwIxOca7ikoOeB5pT8=; b=mE+Ju5y8Kfj3YUen47kf4vplWzUbqlhdxylWbP7++/IbAYOcz61IjEYVUz/J22kJ1/pZ ir3i7QEwcp37pl50jqnAUaMHwZIiLxsaxYscxkOmLmi+pouzjOR6zzF0IwRxi/zpicPbL CHEY7g0yPfeT23JSGhrdPAFxptLEL0iF1+NBLJ/00tMBnTiDnkx2EVNJgQcpzGXYiznR+ asGfkT03MrGzEE+fVvLGfnaj8OBU7SR9DETTsIzS2vpgWr44IqTverxDZW4HCA0h0FwgH hTdFzk3RlwyEqK73HOGanlnn7HjRhdufTPJ4CmaBnfgrRJG3kyefBGP7XTcEeJXUmrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="fRT/eFrW"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DD6A606A322; Fri, 4 Dec 2026 12:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fRT/eFrW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DED11F000C2; Fri, 4 Dec 2026 12:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386187; bh=dAgXa9gtEH82bRd2GPcEl4vfkEwIxOca7ikoOeB5pT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fRT/eFrW41+R5AbhwwytiRtgrWLOgCW5qVM25c9iMTtr/3zx5/PLFRO2q0s1mFefZ tEkeITmGvY98Rmg+c1FWQhqBnYBkWL0cpVXpZRnHU1U0ttdTVoV6vrWToLormVkls7 60DUpJh7S98snnoMJLFR/hqIBKwz7vh/lFVfmsNQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 0864/1167] Bluetooth: mgmt: Fix read_index_list() buffer overflow Date: Fri, 4 Dec 2026 19:04:51 +0900 Message-ID: <20261204100724.618477550@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz [ Upstream commit cfdd650c5dabbd2f59a0e916aa8ef3f1965a3b4b ] The first pass counts only configured controllers, but HCI_UNCONFIGURED can change before the second pass, which may then write more entries than were allocated. Size the buffer from the total number of controllers as read_unconf_index_list() already does. Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-7841362e-9b8f-465f-aa22-e99c315231e2 Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command") Assisted-by: OpenCode:claude-fable-5.2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/mgmt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 306dc70ec3528..b14b9a8a880d9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -446,10 +446,8 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, read_lock(&hci_dev_list_lock); count = 0; - list_for_each_entry(d, &hci_dev_list, list) { - if (!hci_dev_test_flag(d, HCI_UNCONFIGURED)) - count++; - } + list_for_each_entry(d, &hci_dev_list, list) + count++; rp_len = sizeof(*rp) + (2 * count); rp = kmalloc(rp_len, GFP_ATOMIC); -- 2.53.0