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=1796386194; b=txaiG5aYBC43HKqI26qoP49EjL6WLkPUA0oIgnP9f3dfNeQwigY6IR3yl7+lUcsTik8f HwUo9EGrY5PfsiynZvmwBVjsLzvqHFpwQTLqLT/5jV4+YbLdnTLJzHmCqSxdts02vJTKa 5mBsDS72y05j/Z01arEXXgLs5wF5VAvvLvSGkb6J8/wQ9caggOFBlqCrB/dwfNhY9XSjh Zps4AuyMCgfgUt/u7WG/rC6a0/xPSo4SvxtLO7UWvCqQN/tCmYWrjXrjkZX5T0loAxNY8 TzVVHkgl+/iwB5znmuTLyL77N7sKxlLH4tDfT5sEQHOlfqSlLeNojLLo6bC42vUXMJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386194; 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=ZyXvvq2ZYv0GqFtLu19YbYFqQPEX8oQHjzJfrY5Izvg=; b=Ucq9nvrHZRJLiVmqmxQu5aBSP26qk23EjKx6Fr5NlV8WUuHEa7SuDR9RjMw+2+JUKe7+ iXfPepQM9+oG+OPROFFS+2Ann8wXznaqXTaIzFR01gM3nGxg1fhXsOrRllR+xOo9XieIq vnBD0Taj4tKdWpvM1xBHO4r+yeSA61CLDyQ6f4Ce4ehz3ixNvA+xQqDHq2rUFnwYIpC8C OHocroKm+d1Ius4yUI9Y6QeHjTwTvn423hQ8M78VtOmwfUfDvvZchUx3gpxSQscl7GBZk 63heyWyVqVmriuJRd96qiYS4iRIJfr3+OPyQKJCY83l/bZei2WNeYa33oeT39xhAZhQ== 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=YQSFWCZr; 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 7E2DC606A322; Fri, 4 Dec 2026 12:09: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=YQSFWCZr Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2E651F000CE; Fri, 4 Dec 2026 12:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386194; bh=ZyXvvq2ZYv0GqFtLu19YbYFqQPEX8oQHjzJfrY5Izvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YQSFWCZrBnwdOt2NTnPtgfPgQKeR5HvqQGRY96e9UjbaZS9NwLcqzwFPU5kJj/a6a NHuojrYbUGNIyYDPZEm9DHouCCutwU4PtIHhs7sITfZnGMou543UhINseFih395OCW 8m6PQhLQj0hdEPXQRjzQHxTlu4PI68FqDcevaa2U= 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 0866/1167] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Date: Fri, 4 Dec 2026 19:04:53 +0900 Message-ID: <20261204100724.672698940@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: 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.6-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 c21a9ffc26e43..e9676b16124e0 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -2139,9 +2139,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 @@ -2171,6 +2175,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