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=1796381730; b=U3U47DBcuFRNe6ZKEqQ6FEQolJnf+XQc2efKC6bVg1QdpNUmFLUKWp1oZBq8no2kJkxT 0HlyT7yvHXs2J8rWzyqXMOY6o8Vwdn2EcqEm2Bbn6e6Ki3xtBzQW1kiAQ+B0SFcS3IRjj 3NZcgb1N+i4r8wPqI+HZo9+xly1hJ7o9FqTgkpcnsdyH24Ru1zKrIoODEwup13mK5UlK+ kHSU4Q9gkAVBNaO0QFsTuvyvK9WZD+RY6h2GwOR7NNQMK0MpUcmq4O5o9TwxvpHh2wjCG 9aakGgJF1yNeBlYRoG6jQiAhXD8eEpJCOD7ESzVqyrWT13gpeJvmKxUck8UucrybF0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381730; 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=hZ0MxRfFhPfXjDSAYG0pZXC8TMlPjBTjYTwRiFr2NBA=; b=yX/fQ6XcO3D8vLvEAN3lzDv+f+MDr0DxNnophsXVNe2Uglh7KAHXdNZXbHEiE0dHwqqd EvZF3Byr2+neBw5duH+ws3DDNssfQJZLn9R5Bm/6wm/2XiQPJ+yWx/OyGO98wYN2aCGCW u0tXjU43uphDbJpU22MiVyaJQl7DNtwZ748YDsac4CalJkBI7wYmkRqDsCkBvknU4Uj6j cl8Xjead4RlTePvpb+rowvYwq5rkT3G8Z7Yw3dgBUaLb3yOgjDruzlQeCZbOSLXp124zK xMt/xdrIxMgPRUaS7rc27JY867ZGVxs5jgmDiUBcdJRXCuvyunLk3kM4CTouQ1ph+iw== 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=LaqyQlW2; 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 A4A28606A322; Fri, 4 Dec 2026 10:55:30 +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=LaqyQlW2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D8E91F00897; Fri, 4 Dec 2026 10:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381730; bh=hZ0MxRfFhPfXjDSAYG0pZXC8TMlPjBTjYTwRiFr2NBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LaqyQlW2vP0Qsz2mOzkAeP/NvwMKAyWhk+gNUmR+aK/1bJhN0Ki/0sKY8GPue2w6x RC+fHjprlVrWCeuVNM6b1sYLhpM6816cOZw+wnSXReMT7EGz+nNqc+MSgEyah6Y7v5 GTaB0BsJqFhM13+CyjJEp6ou3yf6FVmmw+8DhN8o= 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.18 150/703] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Date: Fri, 4 Dec 2026 19:00:49 +0900 Message-ID: <20261204100631.893858587@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 ba5add3292e33..63c351d099e72 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