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=1796383357; b=gB4PeOswiozOO1Oj9KweS2NurvgrNBBIFlwEwqPa+vcZCCt58NM/fYnLfNTCj+Q7BNtk 89ifk+1bHBxOCyvJxvfDhXui2SsAFBBtjDdwQ52TkEZKPQe7fKnWda9GStlS3Sdr5LkXa msRcIHJSf2JTfxXwPLP182QqQKS6KbFsHuwDg9SI0do/soZ2tKqxz1b3ovfONWWyYs50a 7tdd1aV7LJSkbQn8iUBj1MaYTX4dNUn2EeG2K9EEqeVPPtKswDni29YSyr+mR48cCRHz0 TRAbpNQbtwMl6897JKTrKeGeyIaM4nDfoKy89bmxRymkJ5lnDtzJ9E4X2nRLGtuEcnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383357; 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=gI1cRXKsq7/HXmBOyxypuT1z7IVpO+yoNg35tqa4Mgg=; b=DCrBzgfQS6jeu2eZeYAuU4Js7T4VMjEHAoKLX2M7JZ848qsa7Ze4qHSpGNz9UHYKK54v sR5z4b+tzFX29NWpPTcjc9cHFsxEJoJsZy5EPFZaRdCgQa9JbqZcWfjkz8Cwr6hdtwzD9 LEOnqgwH++MyIsOQFrD5z8E0ZUaoSYXzehLAELjocF7o63u4M+/nY1nbM4S6uqFvqylq2 Uu1kAAMzBPC1r7dlg2PkqsVrnE4av+Clb/7w4aOZIJPQnV7iw1t3krvJhCEH/7NZKs21I Kz+xh51RvYFgvlzwHW6ytaZ8qGG8o4ZVTXEiEOD8J76r71fHiwDX2O9fxZWX8+zXxdw== 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="F6/PyKWQ"; 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 33B6F606A322; Fri, 4 Dec 2026 11:22:37 +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=F6/PyKWQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE801F000CE; Fri, 4 Dec 2026 11:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383357; bh=gI1cRXKsq7/HXmBOyxypuT1z7IVpO+yoNg35tqa4Mgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F6/PyKWQLysDUnnA8iaY1w0RMgEgzKV5ROWX5nXvNzSk/dQ2FsmYFjsNKf7fP6e6D tWDo1if09xABqbI5hJtAczT4mqD3X/9L9/5rbfvtVt00G2ScV5rG8ynMxFBIyUO0Xb xlMgdhVq7XdOR9Gc1RNuvvNSXevpCJYkSneTcSYo= 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.12 193/555] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Date: Fri, 4 Dec 2026 19:03:56 +0900 Message-ID: <20261204100615.504042252@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz [ Upstream commit 7f08b6ef44fa17f1a5ad3926663ddb5abe6ff68a ] hci_remove_single_adv_monitor() and hci_remove_all_adv_monitor() only require hci_req_sync_lock, yet they look up and free monitors, modifying hdev->adv_monitors_idr and adv_monitors_cnt, which Read Advertisement Monitor Features iterates under hdev->lock. Take hdev->lock around the IDR accesses and the freeing, but not across the HCI commands sent to the controller. Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-8b358899-5ac9-4687-af16-58420a4d9bba Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor") Assisted-by: OpenCode:claude-fable-5.2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 53b677594fc2e..7811d7a3f6052 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2066,7 +2066,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev, if (status == -ENOENT) bt_dev_warn(hdev, "Removing monitor with no matching handle %d", monitor->handle); + + hci_dev_lock(hdev); hci_free_adv_monitor(hdev, monitor); + hci_dev_unlock(hdev); return status; } @@ -2074,7 +2077,11 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev, /* This function requires the caller holds hci_req_sync_lock */ int hci_remove_single_adv_monitor(struct hci_dev *hdev, u16 handle) { - struct adv_monitor *monitor = idr_find(&hdev->adv_monitors_idr, handle); + struct adv_monitor *monitor; + + hci_dev_lock(hdev); + monitor = idr_find(&hdev->adv_monitors_idr, handle); + hci_dev_unlock(hdev); if (!monitor) return -EINVAL; @@ -2090,7 +2097,10 @@ int hci_remove_all_adv_monitor(struct hci_dev *hdev) int status = 0; while (1) { + hci_dev_lock(hdev); monitor = idr_get_next(&hdev->adv_monitors_idr, &idr_next_id); + hci_dev_unlock(hdev); + if (!monitor) break; -- 2.53.0