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=1796381733; b=1FI+3IbtZzSDRGNeQQ0jCzixfNeR28LcxbKFbup978I4FhxhgvTtLKN3a4F046g5hrYK zKnEk6LyG0K4zp5DLNrtIoYONMcWBIpa/ki2MOSufPbDZo7mpdAhbPjS9MQOGFyuijVaO kzE1nVhtnE3HAlSsGRVPdX2KjCGMZ2dTyyyWmIZbdTKBMMUFE/XD2BU5oJhP7jsiJp6Hv 8tW3pWhVpBfVM1qgY9DZl4nX7XDKv8CkihFOAgnUcDSsObV/4Y5YtryTIvnqy3koS/6XD WPJbwGk7/cXm23+39m8k0rXnrr4Hxc/P8gxGZ0e/NQvzJavtTh7cYxepe27+M145cDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381733; 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=/GmdO/725FRqzvjel04d8z7wfLDSn4DebtkNg/NgKsY=; b=YHedjrNXwXy7VbqAB7XbX12coROZKL4NhXf6xpRZcyVRJLpct7E2uxzQ6Oe2W8hcHxWz 46GYEo1cE93TlrG1wB2WEZ/J1Elyz4NYCJBN8TOIl9TQcEkQum5TXD6JTd9gWEcmVEUGx 4Viv0f0kL+xBU6BijhuQVM/fCLc1D1Q8lssWXnuZb5qEozG8BX6trMtseUwLjJHi7FF0h SHeHCAMIxDu55Sq8NRkZuOSNXnIyhj+gmRPu6pWPmIuVOdDjQMDMry9rc5Ag+iAMj3nbT 7hBHzQNhAsu05YT45PmONNd19Rqepc6iEOxF3eyjUaz4iL5EfH25zjJGP9svY0mkSPQ== 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=ez5jL+Dq; 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 65C00606A322; Fri, 4 Dec 2026 10:55: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=ez5jL+Dq Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3A651F00897; Fri, 4 Dec 2026 10:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381733; bh=/GmdO/725FRqzvjel04d8z7wfLDSn4DebtkNg/NgKsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ez5jL+DqlvpxgPr47CdMdeFt/jSdTD2EeRi4rlinjCmCLPwCd0luZGYj52S87YODQ KRmC0DUc9grpRTmpDpgU5wzQei3DZ0mc90IkUcorkWICQqTwM+e2BnEGdwTFsqvPR8 PBOfXe8LpxBzy772BPISuhBccwvNSHWqGk/1YWv8= 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 151/703] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Date: Fri, 4 Dec 2026 19:00:50 +0900 Message-ID: <20261204100631.921632135@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: 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz [ Upstream commit c592dfe9637c65eeaff4c9f6fd869f39ad7ae472 ] The advertising instance returned by hci_find_adv_instance() was dereferenced without hdev->lock and could be freed concurrently. Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-616b1f8e-06ec-4634-a907-5eb4e82f66df Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2") Assisted-by: OpenCode:claude-fable-5.2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_sync.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 63c351d099e72..3f75dbd63c279 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -2150,9 +2150,13 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, if (hdev->adv_instance_timeout) return -EBUSY; + hci_dev_lock(hdev); + adv = hci_find_adv_instance(hdev, instance); - if (!adv) + if (!adv) { + hci_dev_unlock(hdev); return -ENOENT; + } /* A zero timeout means unlimited advertising. As long as there is * only one instance, duration should be ignored. We still set a timeout @@ -2182,6 +2186,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, secs_to_jiffies(timeout)); } + hci_dev_unlock(hdev); + /* If we're just re-scheduling the same instance again then do not * execute any HCI commands. This happens when a single instance is * being advertised. -- 2.53.0