From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C3F2FC19; Thu, 25 Jul 2024 14:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919207; cv=none; b=OFBk/jck87UhLBoQKy73YpbT/tHPtsZBBVCV6xbVA9Sh5orftrf2bZVFKb2pMarXVb4OsQURccH5QKVx0/WKYz47DQkF6xEMmNT1J5LR3FKluL00Qgb5mr2cYuJHTgD1SHd5gJ3jbg2Q6NbIh8YqQED5NnjnYnIUp8t5RRTpuQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721919207; c=relaxed/simple; bh=YK2t3U+SSCVJFXxHJBhOAVNXC9YMFaV/NlWhouz3l6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RxV+7kRYwF+UsN4kNet6Y67tEnf31FSI0lVhnlm0uyVkXZwHaG2y70c6x5CKJ7tbfFhw7M5W7oYkzzA9PEfzcDQUvhSvfVXut2pygVyLraQioxPn5nOY5vKWTU0Ju9gehXp607UsDSyfiDuAtXM5AGKbMFnCmR4DCbCno6+jFLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1iB71e3P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1iB71e3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3350C116B1; Thu, 25 Jul 2024 14:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721919207; bh=YK2t3U+SSCVJFXxHJBhOAVNXC9YMFaV/NlWhouz3l6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1iB71e3P6S1hwWtDpp0Drb7dhkoxNfAPDuTN0JfkJTgYQtzgZOtNI54uCKxzDWHqx qqIPw5H8Vk/3cVEV9SnLHkjLZUeCF95xsdjiE0S4CQIqCYAkwcZMC6YmROcaTbFjhb KFZZfTB0mDNWPGSrVcJX3WIg2SIUzEqIibUjgfak= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Tetsuo Handa , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.15 56/87] Bluetooth: hci_core: cancel all works upon hci_unregister_dev() Date: Thu, 25 Jul 2024 16:37:29 +0200 Message-ID: <20240725142740.545436764@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240725142738.422724252@linuxfoundation.org> References: <20240725142738.422724252@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa [ Upstream commit 0d151a103775dd9645c78c97f77d6e2a5298d913 ] syzbot is reporting that calling hci_release_dev() from hci_error_reset() due to hci_dev_put() from hci_error_reset() can cause deadlock at destroy_workqueue(), for hci_error_reset() is called from hdev->req_workqueue which destroy_workqueue() needs to flush. We need to make sure that hdev->{rx_work,cmd_work,tx_work} which are queued into hdev->workqueue and hdev->{power_on,error_reset} which are queued into hdev->req_workqueue are no longer running by the moment destroy_workqueue(hdev->workqueue); destroy_workqueue(hdev->req_workqueue); are called from hci_release_dev(). Call cancel_work_sync() on these work items from hci_unregister_dev() as soon as hdev->list is removed from hci_dev_list. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=da0a9c9721e36db712e8 Signed-off-by: Tetsuo Handa Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a3c867bdff03..fc4e02b3f26ad 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4025,7 +4025,11 @@ void hci_unregister_dev(struct hci_dev *hdev) list_del(&hdev->list); write_unlock(&hci_dev_list_lock); + cancel_work_sync(&hdev->rx_work); + cancel_work_sync(&hdev->cmd_work); + cancel_work_sync(&hdev->tx_work); cancel_work_sync(&hdev->power_on); + cancel_work_sync(&hdev->error_reset); if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) { hci_suspend_clear_tasks(hdev); -- 2.43.0