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=1796388898; b=vgvY/zmpd533ty7+EWulh4ZrTT2sF4wS3uMqhZvQkKr6RZkdVinTmrRGfEL7l2BlbX90 arMFIvFez/QDkBvWrA63Zg7+cfSyOg0T+0Kte7Ar/dzG8flbg1xvJi4FHmtwOzvdUjrC2 frGHE7mS3abZJUHF0gy9AYAifmoZkXPEZ1GJaB7aLUkkxUkRaxLVQdDckdptc4gWL3ERb ARFgrmStkgavXpsQxBsozf3DGtzzHaJEw9OEd53PlCkpBwoRAC0Y6/2Zniwc8me/1ubn6 nfQ5dbT3q47wCEEInJIWat738Y2ez+aKuTnk9z3np+dhA/fKSOnVkudRsWirnEk2b6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388898; 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=fUR1AH5H7qJ4q03uWI9oo5uFjZPHmKM7eKPfVNclVoc=; b=JbqA52a38/Xi6NazhpoB6PjEZOFn5lfd8ZflVZ9Xw/t7Eju/mwJAvSuX4pfJZyaA56gk EAuCLqxAfJ2dhT28tmz7Q8sAkgFkzhiezxUy/mQer0aR3k1TTyBp9xqT59AwApolB6Qm+ 90PDfidPUF108U7DF14QWNvYw1cuPMyfVhXpTVpR28BybP1ze3oUaVmOftzU9BYPUVRz7 PjnSEZT7CqU0KpB2/rW6Vlx5wTqSxYZFKKBr9fAsdcSDZkNu7A47Jcp87rSiZ5ikm/9qG 43vbDwAty7DcSULjA5uKdqvvM5QmeJMayYf8okzkDbPMmLrzrUdMVbD4kZCu6qAtyKw== 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=CATqQ8o3; 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 1E6EC606A32D; Fri, 4 Dec 2026 12:54:57 +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=CATqQ8o3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 552ED1F00897; Fri, 4 Dec 2026 12:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388897; bh=fUR1AH5H7qJ4q03uWI9oo5uFjZPHmKM7eKPfVNclVoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CATqQ8o3oLfLKF9nAiSFydeWFzt+o0tNCxVVIgAWPxN7SscU3PYhehI4OQUJqeg95 CWtMTY6YYL13lLo/U54KeDI+2S1b+nrnr+G8yPuMTr89glFSSuDcPJ1fEBbk+NlBBH DcOtLzWxFdPbe+foVPGyKNYSXhz7EmRTBzxh3hTg= 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 0791/1059] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Date: Fri, 4 Dec 2026 19:05:22 +0900 Message-ID: <20261204100704.522741790@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 8984b72f9508b2d03c58a82d73881b5e1e5f5bc4 ] hci_disable_ext_adv_instance_sync() calls hci_find_adv_instance() and dereferences the instance without hdev->lock, racing with the removal of the instance. Look the instance up under the lock and only use the values copied while it is held. Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-a364929c-cd00-492a-a83c-5425d042b09f 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 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 7d7122c5bb43a..ec53e5f4f4bba 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -1252,16 +1252,26 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) struct hci_cp_ext_adv_set *set; u8 data[sizeof(*cp) + sizeof(*set) * 1]; u8 size; - struct adv_info *adv = NULL; + u8 handle = instance; /* If request specifies an instance that doesn't exist, fail */ if (instance > 0) { + struct adv_info *adv; + bool enabled = false; + + hci_dev_lock(hdev); adv = hci_find_adv_instance(hdev, instance); + if (adv) { + enabled = adv->enabled; + handle = adv->handle; + } + hci_dev_unlock(hdev); + if (!adv) return -EINVAL; /* If not enabled there is nothing to do */ - if (!adv->enabled) + if (!enabled) return 0; } @@ -1274,7 +1284,7 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) cp->num_of_sets = !!instance; cp->enable = 0x00; - set->handle = adv ? adv->handle : instance; + set->handle = handle; size = sizeof(*cp) + sizeof(*set) * cp->num_of_sets; -- 2.53.0