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=1796386206; b=hLLlPRpTmh4/t407Wq6WvvkdkZ3m2BCCDE0ElBNeWBvNciJMvs3VRo8mE3JxSdbmN9pi IgRbDiurewJ7cYYKPHq1X1ew03+/jZ/xbHJrBRczZVjmYnNYdvK/VF9hNlDiOCGI6QhO6 eNNfju5suTxzBCMHcpYCsqDYlSHHKvUeRbyxh6SwMwCHKDFrHHi5GRImpx7FJ2oCa+zPc csPtj/Ef2gn91P0wZzGtU5CwBwydSQINpFZqBUHNr4OHVt8Cc85x4dQOZsZOMIKJfBOmE tp7cZyoCxHSS4OE+yMpMQ/WFf/h/Sbl7YApk+S91HpxHSiHKixnsHPmlTKGhImMu+1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386206; 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=hsGEgvtz33xt0yBnp0niEQtB68KSZIW586uNOx2ckWY=; b=ZxdzS6bW/vHTH+dNEH6OG/l+Z9FgELg88itZDhbtniFbfheF7d2FbLNBu10/dc5iotrV Q2C3wZkU4V9XPZou8fFraQE1nVipVFPPSUesyVsbpRdle/x/i7JU4P4qG8N0NBRwtUwRz uQiNsypg5bPSBPoPjdbWBa4IVsdVHrMpG4LfBgIf0TJiMORo0wQ9wceFEWlVB3f9j62z3 +9D2npfjSBluBxMvs3gKeOuQT/fIhbWYkpKLyVBuA5FUlTEsHN8y/qvBieLdDmANLXGpq AXnwAyM6gMF7zrNH1vG6Qe7cABxV8BFB6m4C0mWLyyv6X3yKUHgK+hiurm6i9UW4TRw== 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="tR/872Gz"; 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 8AC40606A32C; Fri, 4 Dec 2026 12:10:06 +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=tR/872Gz Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3B3F1F000C2; Fri, 4 Dec 2026 12:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386206; bh=hsGEgvtz33xt0yBnp0niEQtB68KSZIW586uNOx2ckWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tR/872GzVoApi+w01yv6s7Lypli7tnQaXV7ZI13sO61/vT+BC+sNRqpnL3UiChHOl rAm0aA/YMI+ZOTEmoFVwMFlm6YyG5vZv3LEy3osNBi0Ob/XAwZXPMpwtk3duymRggr pSZdoneEjfJGQEbADwsw9FZ0N+TWxDSdpRE/EmjU= 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 0870/1167] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Date: Fri, 4 Dec 2026 19:04:57 +0900 Message-ID: <20261204100724.802751750@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: 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz [ Upstream commit 8a119ba64f33dd9ab265d3b978f7811a80b7fe8a ] smp_force_bredr() created a BR/EDR SMP channel even when the controller was powered off or not LE capable, leaving a stale channel that smp_register() later warns about and leaks. Only create it when SMP is registered and guard the removal; smp_register() creates it on power on if the flag is set. Since smp_unregister() runs with hdev->lock take it around smp_register() as well so they can't race with each other nor with smp_force_bredr(). Reported-by: Sashiko Link: https://sashiko.dev/#/bug/linux-a921c99c-0b41-485c-91a4-1c6e54b45b0b Fixes: 300acfdec916 ("Bluetooth: Introduce force_bredr_smp debugfs option for testing") Assisted-by: OpenCode:claude-fable-5.2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_sync.c | 2 ++ net/bluetooth/smp.c | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index e9676b16124e0..ce2f95b96ac93 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3713,7 +3713,9 @@ int hci_powered_update_sync(struct hci_dev *hdev) * registration is required so that LE SMP can clearly decide if * the public address or static address is used. */ + hci_dev_lock(hdev); smp_register(hdev); + hci_dev_unlock(hdev); err = hci_write_ssp_mode_sync(hdev, 0x01); if (err) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index c89de7c51c78c..ccd6650c5210d 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -3395,20 +3395,28 @@ int smp_force_bredr(struct hci_dev *hdev, bool enable) if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP)) return -EALREADY; + /* The channels are only registered while the controller is powered + * and LE capable. Otherwise just record the flag, smp_register() will + * create the BR/EDR channel on the next power on. + */ if (enable) { struct l2cap_chan *chan; - chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR); - if (IS_ERR(chan)) - return PTR_ERR(chan); + if (hdev->smp_data && !hdev->smp_bredr_data) { + chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR); + if (IS_ERR(chan)) + return PTR_ERR(chan); - hdev->smp_bredr_data = chan; + hdev->smp_bredr_data = chan; + } } else { struct l2cap_chan *chan; chan = hdev->smp_bredr_data; - hdev->smp_bredr_data = NULL; - smp_del_chan(chan); + if (chan) { + hdev->smp_bredr_data = NULL; + smp_del_chan(chan); + } } hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP); -- 2.53.0