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=1796386991; b=dPDCG/f+/5KMbbPtA0BhJqSL+qOT2x1k4dJLllv4HBKo6OBl0BmX5mUx/65YEUGocsmw Q/Y6JigEsrPbOl03RrhZW1BC5PMhzNh50HxqZUA1a+IRmFYCpGDwVbLUSvOXuy1sCa/L7 nGpTGKpYUk7fvUl0KIKMM9J6cxZXudjzvzP5ej45TBAEuJG/uVDAgu2aE7L7esjJ9gKLu ufqOzE4ZVE2WVRU+p/Hy8kS5qe6cfM9nGozzu99+f5Z9tVMg6Luju1cBux0VFzTvtnnsr sfbuBtDRjjB1WOpegtkkJJQhrRY8Ysh0H77jXNxAc+AsM9fiQAWAZmNyA8tE8FFxQyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386991; 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=U/7rj6sDXt64ZuywSlXCK51vjJGPr97eP5NH1BVeL2c=; b=1t01n1cVmJciBILMk+pUg+8WC3GiBhGSgFlMlbe0FKyM2JJyxDBuExEqIiBHDEuIp0B7 G9UGdll/rSQuEx1AG931JdRQjMY6wD8BYfR+I7S4w7shw8AM9IeHq06f01RV5SB/x1jyG 36FxoUpPjXeyDeeeUFT/ut9riByvbT5gtGvjGWgi+U0lx3mSgjSO8dy9Bwc/rPs/RD6Hm qED+nIK8fjZbTLdVav6tq0O8oZJrBJB6o1Fho72BdsYa5OXdI096pRiw5abXWPn7irTNA r8+HWpG76I85RDP3Z574IZ0wrEVt9ZBiXmLQlf+bohRDoh1CUDqnp0cVflUc0iP3hoA== 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=Hd57IEgv; 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 895A5606A322; Fri, 4 Dec 2026 12:23:11 +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=Hd57IEgv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01C981F000CE; Fri, 4 Dec 2026 12:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386991; bh=U/7rj6sDXt64ZuywSlXCK51vjJGPr97eP5NH1BVeL2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Hd57IEgvl+TMBqL/UWkWMfHrhqPKOek5uAQ0aAp3n67Gr+9L27TXsIUHWYeduy2DA czHU1ZCBPN7IpNq8HKWlnfcmLHM8AYA8uk21jDE0NpMOWoCWHsmEOisx5t/Ausrx3H eT5i+MjZZSzsuDPuSWvq65/Hxqc+2JpTDf8+FrgY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuai Zhang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.1 0087/1059] Bluetooth: mgmt: reply to cancelled mgmt commands instead of silently dropping Date: Fri, 4 Dec 2026 18:53:38 +0900 Message-ID: <20261204100646.365505514@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: Shuai Zhang [ Upstream commit c0bb764fc082672678d371c375597a6a9f614cf9 ] The kernel sets HCI_AUTO_OFF when a controller is first registered and starts a 2-second timer. On slower boots bluetoothd and the HCI_AUTO_OFF timer can race: hci_power_off() is already queued while bluetoothd is still in the middle of its adapter setup sequence. hci_cmd_sync_clear() then cancels any pending mgmt commands with -ECANCELED, including the MGMT_OP_REMOVE_ADV_MONITOR sent by reset_adv_monitors() early in the setup sequence. When auto_off=1, hci_dev_close_sync() skips __mgmt_power_off() entirely, so there is no fallback path to reply to the cancelled commands. mgmt_remove_adv_monitor_complete() silently returns on -ECANCELED, leaving the command with no reply. Since bluez's mgmt queue is strictly serialised, this stalls all subsequent commands indefinitely, leaving bluetoothd unable to register the adapter. Fix by mapping -ECANCELED to MGMT_STATUS_CANCELLED in mgmt_errno_status() and replying to the cancelled command in mgmt_remove_adv_monitor_complete() instead of returning early. Signed-off-by: Shuai Zhang Signed-off-by: Luiz Augusto von Dentz Stable-dep-of: 7eac80614300 ("Bluetooth: MGMT: Return RFKILLED for Set Powered on a blocked controller") Signed-off-by: Sasha Levin --- net/bluetooth/mgmt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 574ef8bc7845d..e4f78685fb6d1 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -304,6 +304,8 @@ static u8 mgmt_errno_status(int err) return MGMT_STATUS_ALREADY_CONNECTED; case -ENOTCONN: return MGMT_STATUS_DISCONNECTED; + case -ECANCELED: + return MGMT_STATUS_CANCELLED; } return MGMT_STATUS_FAILED; @@ -5557,8 +5559,18 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev, struct mgmt_pending_cmd *cmd = data; struct mgmt_cp_remove_adv_monitor *cp; - if (status == -ECANCELED) + /* Reply to a cancelled command so bluetoothd's serialised mgmt queue + * is not blocked. + */ + if (status == -ECANCELED) { + cp = cmd->param; + rp.monitor_handle = cp->monitor_handle; + + mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, + mgmt_status(status), &rp, sizeof(rp)); + mgmt_pending_free(cmd); return; + } hci_dev_lock(hdev); -- 2.53.0