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=1796383312; b=wcFL6+Qo7S6Nw1TQfYJV9WtwWWt+CXcDU/NNf2BenuSdXVbxDYZnJhk/1hb2XFFLt5ah J4OnWpjW/eN7BNa0kAJ3qyUopglsaaXygxT3qGnQulY3cYSZPUGbDYqE2zmjuWFmc443V O+4khaXfTjVOoct/gFdvNQ/hW9oO9yr7T9SH9dYLwB8P9VW8KSUA+1Rv0PA7Tqm9+gVrW T5hJXMHvEiUWs8UQoQ4sFGsjLCoepz9jbhyZiZMGV6SUn6KmC5VXcE7YO0gXEHveXQOXq mNmv1JwlkfzpFK+nVApL+vZCNrCUergay1OdAkRED88xkfVdQ8e6QrJRlvXzdWpxZMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383312; 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=s3IE6XGyP47GoxV47xsPZxoCZEh7ay1lixlqegXVWUE=; b=4eEedMWMWq6KirbbZeWo5FI+ZfFQ4X25Hyq94Ltl1hbimsdzUKnBe61K92jLy25f1UI1 udBLR/56y3ZncJAgRr5U9SY2ojMmtzqa8hxpLT+vdpQmi6kNcGOuGEliE/eCGqY9FqCKq i0cAtLI42YsL79j/NJgbYjoR7yRwfSxsezRSSWeFNl086YReZv71TYop1zC1UFBaMBNq7 JcMCFkPZxyBKnkpZ6KHVay+QX3ajQsGFvoYkNVbsmkfBnAObO8kyPMCa8JStrzQnbmNIa kG70ir4JDR9UfEGssI2HmSqKmVvwdpWG3Foa8xnvuNUESvzK1baS/5VXmoIl0DLmX9Q== 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=aHX2CMi9; 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 08D49606A322; Fri, 4 Dec 2026 11:21:52 +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=aHX2CMi9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 767E21F000CE; Fri, 4 Dec 2026 11:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383311; bh=s3IE6XGyP47GoxV47xsPZxoCZEh7ay1lixlqegXVWUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aHX2CMi9GPz5nFbKXnhsGTGy70jS02sDmRaViN2Z3wq7XJMPHlMuuKq287CodgrnI ug117hqf4RLpR7LDoFTmksFzdCscKxwN1EEU5bndLbKWgKiRkri1pADMH/iSxI/LjC W2j5G7983mIrT5/veYYcaj6SC0K6G6MX69T4EXL8= 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 170/555] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Date: Fri, 4 Dec 2026 19:03:33 +0900 Message-ID: <20261204100614.687002203@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 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 3793fc359a9ff..e0d06338f7ac4 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -1250,16 +1250,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; } @@ -1272,7 +1282,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