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=1796388900; b=fxt+a1c9AYgrEgNuhNsIRh41pjKp8iKm4bIpwxlOg/Ev9zbDdBdDVvb+Fe6XXdqs877Q JepfLoyCmhmfAtFVfqNvU8yd6xYuVD8prIBO0aRx2OO+tp/Tq+Tt8VZ+NMJNG+Hd/ggqe VINHZ/bhC+3JEy6WwXpI59/f36UE+dLMJHE6NnevmRSaj6uSIAZsr+L2w0XXOSEBazOvb Fvc6Lo1O+S3up1vZTVg9RE1y+HVXZ4zz2GWCgX7+VyycS2Op+I7SodS1gbW4yi6P5Uuhg m/hGcW+VfkqMcpEmBj5IHLjhSdtKXK4c/y4WkcQzxkiVGFTwJW35dcSj9eH/IkUNxOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388900; 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=6gU1GGdPKGAxL5cGaTBx0oWXDEUUNRyiznf7mjKCxFo=; b=X0iWGYTfFZeL0fROLsH2MLJz7RM0TyTMPmhoodPdOFezVowXC9vXHaZDCt2uzW7GVxk/ LuZm1qVQNFZEaHToUMvsy+uv4/ocj6m7SPkNvlxOHYjwgEsLnegCk8fbQc4M32NiW83Bf cHPRlSAO2D9sge4gdlq5uz3u8cuTpqoRAIIauDbU2fmJrSpT57WKfXJakkAFWdPclVJAv phUKxeVhr26/8zNanzwP25IuM8pH8XC3GxSlW4+DXT/QzKTfWBFk9z1JMMrdgwt7pDmU3 48EhrRVl5UkXGz8I+VQurWjMNU/6ROi3BSENOitI3ZXztnhMht5aIsTcfmORmvAMhSw== 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=ESNq9Bzb; 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 8DB9E606A32D; Fri, 4 Dec 2026 12:55:00 +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=ESNq9Bzb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 947B41F000CE; Fri, 4 Dec 2026 12:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388900; bh=6gU1GGdPKGAxL5cGaTBx0oWXDEUUNRyiznf7mjKCxFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ESNq9BzbL24k7ksbQx0Lm/WFReHo3oDGok81zUQS7rkdh1Xi9NUuK62BTvLAWG3Gy NOyRQcGDmaF40kctb6/xTwhpPXh98REDryguTQI44IhGf7EvLkiJixQPGMNsmToWQY +ESB8YkxK57kyy7dV51NUnnju71HdMgfc2r95qE4= 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 0792/1059] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Date: Fri, 4 Dec 2026 19:05:23 +0900 Message-ID: <20261204100704.548340844@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: 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.1-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 ec53e5f4f4bba..5834be9c0ce46 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -2161,9 +2161,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 @@ -2193,6 +2197,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