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=1796389053; b=yUq+1LUldLfwzsTSaiarJi6OUiPKeVHaDvdVHBSBUsyi2BJ/hml8CMZIC6GMnMwGZUJQ fyhnZn3c7sUPa2MC5Z3WM5Kxqxku2Q9NAUUFswVDA0vxzH0roqsKy/flrfzfgVefD6gaQ jVvheonNPaSpCze8n2iyMBLQjsaLPPqaM0jxvZyvhvnSL1bOUuQ4GYtgYSNXIGjdenr9N 9daJ+WGXnLrgp/pxsIo4EupB051A87vlozCYq874AdoZ7BTp6d1OA+OZrap7xXY4Lzom3 xP3KNr6Ct0N3CD0RYqyXOQ4D4tBX3JukZAJpCpkLDDYGTownW7HtlEBJ5doluOVe9uQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389053; 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=E0gu5KnylViDtBiKiMvSDWFVJnQYlDKwD5ddFk98Eb8=; b=TLBvjuopZZhs8KXMZdsYiD/QL44BZefpvJH1iOIZglyrJL17go6/CgwSgPAhWiRTGWBa npmAWWHa5gUS4OQs1NCfhS/Jy2IXnmnAUmGX7colq8jQ7e6HX7DU+xAUJLNSBK7oBv5hr g+XI8IXZQgNujpEKFQ0f9WogTkdvYkY1fKQbqfoltBhMyiavdBjsTaZgsUz5XnMCNx4SX WhMv/E0cYLJGABZGRVBTxprfc9sZRLPR8Kcdj/0ogYizUqFABHn7Md9XwjcbF8/S2ZlGr GXVS+/pO9Q5xsMlTRvMtIrJHdlzFqmttCB6mCw/fBspDf65JlT25suf+3468KLbMx3A== 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=AerVPgCD; 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 78736606A33A; Fri, 4 Dec 2026 12:57:33 +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=AerVPgCD Received: by smtp.kernel.org (Postfix) with ESMTPSA id C94861F00934; Fri, 4 Dec 2026 12:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389053; bh=E0gu5KnylViDtBiKiMvSDWFVJnQYlDKwD5ddFk98Eb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AerVPgCDqViUFuZ2bRtUSh3CaiXbO12nnw7f43lYwefVWMFqq8/yOyHTLCFcyCch6 TxDutv1KxwZAuQjxR2Bq43xXT7Uqy6yQFRFlK/VOSVlZMzI9QD9ugtcszIvxUxgnk6 wi6zsRiIIge9d0WSHSScP8pJNgkPGQDosoOnlQOY= 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.1 0799/1059] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Date: Fri, 4 Dec 2026 19:05:30 +0900 Message-ID: <20261204100704.725893441@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 0e5ab33d553a9..d4d271db1eacd 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1993,7 +1993,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; } @@ -2001,7 +2004,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; @@ -2017,7 +2024,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