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=1796383314; b=3ryZTfdVj/yCY/UmuPQUgygn31tGlsYrH5vxfNyTfNC7pN1PHmzYOrnpO7mParZrRN4k Ab+IN/Q5UN8kiC8OYbmYEdYWKxFY2Y1g4k2i12EDKrkJ9OzqbZSbWQ3u8HFPqUjqgYxDn 9QzRaLXuyrYsw0AJr1128UgCQ56+JHH9xmy9E/3uZ/5wOWHzFvqOTvjuyQNiommW0BFw+ puA0rssIZWxv4zgLowlcqzgptzqnsjPBDvqrpO/ZTmQEIwulTN3AdTgS4BwTPrgADUnBc AHqeLRVXWf2QLIA5vhRUGycvWeotcLw5k3o1JcejznpEpb616OHkkUiTWxQA4hR3p/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383314; 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=+bFF3S0X979LxJXjnHq/tBFKmV2oLdqQ4gnDZ4XA9dg=; b=wRAsxjvZ0peVL2SLA3ZVDyCFvw0bstc7Xi0wwkBCchWYKsO/FX2QiQJ/mfno84fNin+z eODoZ68mVB6V06Yx8lAt+X92059HO7DIXKI2cgwvArae1T462C3B4glOEN/6JudtOAOh6 rcWH80KIqu4YWNQ7NikXf4M4Ou465C2y5ZlA6Uck/mcTE5q0sN2MTG/g5pBUBa1RBJUon JOi+Pd/5ESJ/C2eZgUBEMCwcDNNLLGmih0rE02KCvEsYcVrM/qnqpwJxqwZD+Wuquy0pe D1PWKu6ZRZphgU1GZ8GoVfiFQaCeC1lr7sVi5eIZWpx0pYGsz6ZPZ8m9T2Pt5QZ0iig== 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=C8GaZZQP; 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 399A5606A322; Fri, 4 Dec 2026 11:21:54 +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=C8GaZZQP Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABA391F000C2; Fri, 4 Dec 2026 11:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383314; bh=+bFF3S0X979LxJXjnHq/tBFKmV2oLdqQ4gnDZ4XA9dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C8GaZZQPiqTbIlAz8/FSj8pLQe/K+k0xQJnV1zUcuIRs4kk+HUFJcfH478dzzeSTh Wd+q01qeBw38H/l00e+veUh/xf1nKEgHSTL6nePknpLDo6ECJIWKQ0aTxG/5y9RoBy YysXpLw3MMHeA2QuYOnwAr/oYYN1mP4wLf4bkyEo= 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 171/555] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Date: Fri, 4 Dec 2026 19:03:34 +0900 Message-ID: <20261204100614.722177167@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: 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.12-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 e0d06338f7ac4..f89bd2c365554 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -2174,9 +2174,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 @@ -2206,6 +2210,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, msecs_to_jiffies(timeout * 1000)); } + 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