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=1796380123; b=YVnRtQVJMaDK9QStmpwI3xGY9onUa7ffn8sUabXUD5lSpMW+1k1a9F8oit/FM5wJ8T+y iz756di8LUzwX2EtmQrVE2h7cPnQ+FPwqDldLQEQ7Pvk7ZjhHRd2sRhqYxTKbagf66vhs gz3mQjNYLErUE4WbnfjbDYGI0WKvh6KS03rVws8jPTnWwz6pDKsNHt4afscfnBk2fkD6U pPATqo1WigtyR4KTwGd83khFdYak428DYxQ8uDqDApMt7LqSk0tlvk8bc04eWX7ENFF5o HHcqq018KtZJM+yDINpPCcaaOIBNWb+AtWIOB5Z29ena/Ku5cudiqhEKvEM2p3vbQyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380123; 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=0zjWtf9kiq3RuXxXd4vDBp4Rc/rrl7eZ6EYIBEnaOZk=; b=GAMWlaGk0LVuRzOxb1mJAUSXNW2ciSS8xATII3LGPJ2uJRQLVInCPqfIp0At/PWg7iR3 7uzDOCTgL3KiOdvLd/AdLPMaYQc7UR1DStacEEMnww4gQx+ZCITl0KZMaI5/NyocBRkiD cUaszuG0PU6SIxWv6/A6vGZwolsmjw04w2M2odXR5HmUSyZjSFSoxXJpmr47q2qQA8HFh J9CSeMQatGgJXD2j6B9i1RGL5iXZNdcLEH+p+OuLojTFE3qxvHSOuIMtUMZjbYlDrSf9i JYv5IdZDc/9++ctIspJzoHFHZJyo8ZRQ7tqvoZ442qzHVmQT1U2zO1hRoEVpxsU10qQ== 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=RlFsefem; 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 74166606A322; Fri, 4 Dec 2026 10:28:43 +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=RlFsefem Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAA1C1F00897; Fri, 4 Dec 2026 10:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380123; bh=0zjWtf9kiq3RuXxXd4vDBp4Rc/rrl7eZ6EYIBEnaOZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RlFsefemWEDeG+z31zTR8m2mSy6F6tRQFoh4RlbmLN6z2arKXE6e9ZPDpVB5SA12G sCKLo0Bom7ggGhZwiQi7jO4JXlpBo+bb7UPR+uzSFfbA8mPk91+XJAVuekL2HprAGr 5mzhGIyYSQxG8Y59iAVg7ZFDhjQPeC2bhlVqYcIc= 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 7.3 095/742] Bluetooth: mgmt: Fix read_index_list() buffer overflow Date: Fri, 4 Dec 2026 18:59:19 +0900 Message-ID: <20261204100637.631526540@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 a287dd4bb26e3..d7f54056d0918 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -444,10 +444,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