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=1796381823; b=yNicd+LWbKV3qoMkBJHw8LVaDavhb5BRNMtIIS98ymNsdtz1q4cJEScBH14mrXGA/TUt kWAjayq7XUPE+i13cWlkA4bKlP419ya7wXkxCkziwRDRXkcZrveiQzvtTO4VaKyDoxjPk rS0DRYz2YQuSTE+FnlXBwWRhGyxfBE5P2KaYr4SVIy9k5WjQ0qN++/Epf/C5LB3oAS4BQ 3BZJvnkymHp0FRxYPu3rfcXwemELGoAOX9LwDp5fJODLGK59DHJ6eWOwQ2h7Zpl6VYQ5T ra34HkEkzOzlLH8eOAoZR077Z7/vzRCW/YffQDrZ/WipuIP0xXQJp2JxT9DK5nbM3Yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381823; 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=yT8t4gFphvoexjmpXIN3oTY/J5Z1BQOz5CGILg+K6oM=; b=VAm4LcW0FoMFXulwqxGOi9U6UO55vNkNgAZVI38VvsdtlKQHF55C3238rSyqR3ICp8ad suI+ZzHG8/AsL5ye8tV2l4GDvqzdXLFlh4hot1PsGQdI3jWT4zwiE/NAfsSxAvXWUmJBQ JZPTUW9DPAcnMTM236L6V7oHkLHyjgrogXF0LlZnQIjNqXUqsiMQvpMk5tC07JQ93o/6t sTqa45p2jeBEja67UWFcBEQisFO/Q2RH5BWsQCDo22j3HRNvv8RAiGcFH+WVMchCi99An jtcnZtpiCPa3zZAHVFpTPEknPV80o+bBFLPBRuCCUXvRblZ6lCalhXI4aD90LDqW+Hg== 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=KO6nbrno; 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 C89D0606A330; Fri, 4 Dec 2026 10:57:03 +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=KO6nbrno Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4017E1F000CE; Fri, 4 Dec 2026 10:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381823; bh=yT8t4gFphvoexjmpXIN3oTY/J5Z1BQOz5CGILg+K6oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KO6nbrnoisTpVzeTRr8w8KMfBCIt2upLzUkB7gONkJ0eSzfjqYWVAoZdvbPbOOo/T 7pnyz0//5FuviSmx3MfVo5cZhi1L3QGRjVlhII6C1McPiKcVuXLWrASc8idO65kOLv w0s7CJP+iYdgpJSDqJJrawpx7BU0U1aW31+ELbKM= 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.18 148/703] Bluetooth: mgmt: Fix read_index_list() buffer overflow Date: Fri, 4 Dec 2026 19:00:47 +0900 Message-ID: <20261204100631.833298919@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 b16b70a3cab61..90929d9c423f5 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