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=1796380098; b=2aYoXjxB5bzLcXcSgTjz18tG4pWzMWluGObmlSKmE40kdAX/rQhr4+ZKLcPQceLirlbb e3t5kjELKeKZIa+8O05BV5fq+sWZRUDsINUX3chCbG1aHdjv+18SC3GMi66niGIcx+Jke Fumse351Jmw/q1ZuTmA3etu9Qrbj0jDkLpDM2PgNpc23VfUHlelVNCfz3Qc2Hij2rG3ck BFXAEL0DQF/WcOKwLfJANrCqB+kEpysLdCdX288hP9M3HCKAlS+WX71DcE8fOYiJWc2EH Nbw8RInSzIoYXUqNXi1W5jOEiUQIJdv9DiArOgCPAz3oh6ODzXlgon97Wly4MppqjNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380098; 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=pVv6Sw/T9rRsu4U60fow3/HnVgXh+XKdnqhn5Hkj3rs=; b=JOJzbTFbgJ7Ahw2ObvYptKprL58tI51XLAcXz+hunkRmJvrX5nYKSwB6L4qRVzVZTn/8 ezBE7EMLYxu45r9oEO2vzZV1EZKGYeVXP8q+HY99ZWYYU6CRwP7k+Bdcw+ag7WpcTf7mV L4arrjqmjMzEG3gt9vbujki5c0dBcoGU/mtCjR5ccMDGIXU4nLGZb1ezBI51pB+TTGKhJ vJpu0f2poxJkQ8HnPTN9t4UZeUZn0lEeq+Ua9AGzDzEB3g4+vpBDGDm6WgRHiZzWlcCQU 8JjWdmTXOzuYdcllUSK2y4e+v4Uzu7ygdQDvzAEAuqgpc4aiav6I46AXPMfPYnbuUGA== 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=o2PsmP2P; 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 2B8F5606A32D; Fri, 4 Dec 2026 10:28:18 +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=o2PsmP2P Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91BC91F000CE; Fri, 4 Dec 2026 10:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380098; bh=pVv6Sw/T9rRsu4U60fow3/HnVgXh+XKdnqhn5Hkj3rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o2PsmP2Pw1ZS99K3IHCW4yQg0ugLmbb8t0pMBCrGFQCA9Ga0XRKyThIvsLRWE2CGv Fxvl3DyTmr4rIikBZAxTZGzslouiEidNfqtEUWsVubVAKIK1O2uaFp8XB/U9PA7lc4 XgP5NlaY3ySXvVX5DPyRUieDoske/Hz/KD4l5M28= 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 124/742] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Date: Fri, 4 Dec 2026 18:59:48 +0900 Message-ID: <20261204100638.416076294@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 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 ed9a83777af0d..110d2ec51f411 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2028,7 +2028,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; } @@ -2036,7 +2039,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; @@ -2052,7 +2059,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