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=1796386255; b=BrTxVMhSW/1TAkEVW2+pZ2FOIrr/fukbV2Y8G62gmG4OExdsxEI9L0XwOvnWtH3UJTaS wpqcQZLx85YVKn/w81ttfkG4KO66709O3sGzl2sMftvpcLiQXkRqZh3uYyvWwM9yqtUbZ 59tE/RHwMK4mMxnLAG68wvrHtod37xaL7c7aFst8H5vP9xV0jmPiw9A0pQSOAu/yRPXpX 5Q1ZpsYdVwd06vLg/f8Y9tKIYXRhCIJx8a5uVYJRgbbEOFlqwQyf0lk7lhLjfDMjvasm5 w8VK+JzrjvqozWIFoFPElHHtZHYpkBiyJ0EwAFYAJir67Q432ddVfhuupV6JiOtNlbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386255; 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=D7Psp7oEfQGxRHd8jELYXO0lBl+aOEvegtlVPMXfHYM=; b=ha8ZlZgkuTvOHHTB9EI+qg2Pg4hNxAKKnbr/Y8z6RSETvUd6EU4c4LQJLoE6kMFO6lDf yexLMFp+BCGjP/Hvzj3b2LWWdYtLrdLXhjcIkxdgKzg2dU+ltqJNqakwF04RTOsdo9jZL AlbAlFqFI1yPh9cQgi9Wvd26P6ueKaO9sRJevkAr1lN/Ki6T9Qi/cpdC/eQMgZhixo1Ib 7xBE2RibBbIMfZaN+kbRsQK5lRTgNmx6OZ7oFwsSAaw7XZkYYdXAwnghsta4mPhZ5FMZL a3gOqQa8CitOIdKi1vPhkkBQT+deRAi5BrqPCMZYsI9lVGQLTyD1IOFO97W0MK9vmBA== 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=RVZ2rURu; 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 80431606A32D; Fri, 4 Dec 2026 12:10:55 +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=RVZ2rURu Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2C131F000CE; Fri, 4 Dec 2026 12:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386255; bh=D7Psp7oEfQGxRHd8jELYXO0lBl+aOEvegtlVPMXfHYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RVZ2rURuQ3iKKnOls4PXI8DG6xwC2+vHARLqjtUWBG5j7W+MLmXUKX1e6G9W0bO6z vb7N7qBYHdYel2LuM4b8Iq5MRMGXQ40I1qBZLYARjR2RTQY71s5esWIuroYI7J6KWy TSwk2tq+PGnLJH2Yk5VkqVnCd9PvDvKErSlogsa0= 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 0887/1167] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Date: Fri, 4 Dec 2026 19:05:14 +0900 Message-ID: <20261204100725.286336173@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: 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.6-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 68c585fd5d945..69a4fdc7baf7a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2037,7 +2037,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; } @@ -2045,7 +2048,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; @@ -2061,7 +2068,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