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=1796384368; b=JB4y/UPthzQy97B5OEoIlyXTvYxXxMb9z4BAox9K9/dV8PxtjboZOkaR2CW+LkQxle7E dpimytpuH6i2r5icXxnMhb6vouyQUQUQ1PzK47Tn9iIQyBOBMJxIOY0+DDJG9w3wXIMt9 WjkDPjbNRTIZsM4IhqQ0GK9ONDKZfke5js0c/MneVqcnOOY3VuDocDl+7s7N9oXYzC4G9 79mb/fc9Z0a5rmLhXZsezK9HAra2RghtzHNzUqdFVGmsU5hPXniNLNvOo28Ou3qGTOH+8 +R0ThZ9XwyeCMVuRtCnWgR1uzusRvBokYmuS4guBrclwqKkoXnHAl/xzieqeBq3EeRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384368; 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=5CHoab6Wzc8EpywxJIHwXPmRC/75Sen2ltnPC9tWTd4=; b=m65dA9wZRrqRU2JOIL3jOrEpqHm7+07nD5hBvn/8A2vAK4X3L/f0DzLweDST9yuMGOl0 xsEqKy28kF3Xn0C2L70y7WFEp7cACHzoYZabFVB1VE7E6ULXcFYjdmQ49A5rhdtkb+Qb8 nfepC9uB5pz2xrgZrN4/5ZdwxOFgAQViTPQD+V92XUwwt2oTNM0zHG5oRiwtPDxHclidK 7oY9njZ5y6iexrpV84T+013pvzFacycrGLNZaq1auV/jKbHMNLeyqdL001aeIJpVotQMN PanFfJ6V7xwKtPrfJpLhQinJLI2MkKk06Vd2SSt/BwvH2rMkwOqEAI82ZjuMmQszrZw== 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=gWh+nk4H; 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 0AC7A606A32F; Fri, 4 Dec 2026 11:39:27 +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=gWh+nk4H Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47D4B1F000CE; Fri, 4 Dec 2026 11:39:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384367; bh=5CHoab6Wzc8EpywxJIHwXPmRC/75Sen2ltnPC9tWTd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gWh+nk4Hfw9JBASsd52amEejW/FruWScHfn7iN+SmRisyqWBwpL/F5LS75wPhT8gW xmiY/II/jJ2/iJdKXImrgx9T3lIClyUHws+fLm9tHQpl1kHwAs61nxaSpd+kIElzV+ 8RhHnyq6JL5/V7VDQxvQeZqsm8RuR4KqSXwAQWe8= 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.6 0121/1167] Bluetooth: mgmt: reply to cancelled mgmt commands instead of silently dropping Date: Fri, 4 Dec 2026 18:52:28 +0900 Message-ID: <20261204100705.241156940@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: 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.6-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 3307a86709280..50fb92103a7d3 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; @@ -5648,8 +5650,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