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 107FF19F49C; Tue, 16 Jul 2024 14:25:38 +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=1721139938; cv=none; b=JMkXJJLf7snS6L+E8/6higj/TLCsvM2/WhJA6MfrRMlchLU7WyKs9SYWhrXfkI3dUDZSFU5Hk0oOwQ2geH8xJPnNBx8cwRZnAjipD0Z08g0qJeKrxySn78HastnA/bfu/oz//bNAR7IeYnmcZiepIcxKFRiFJEQcvdrrJfG0oao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721139938; c=relaxed/simple; bh=dVwbQu2Lhi3yVdptdzzJwBkJyFVjnx7GDwNWH0Y84Gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CHNrBuWmV9S5+l96YXVFek2xekXK+wdZ+WVhPh+Mpaa/dLrMB9yTlXKESspX6BuUHPBcnR9LnI+0jW2L43kdEDH6Omd+nggJf0EugODVi/DbBSqBwYw2S41eeUuVrem5qQ0b8GVexKMmhgkT8clsnJ3Zj5Wq12sDzwyk+Oi+nSk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dPan5Zey; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dPan5Zey" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9860EC4AF0E; Tue, 16 Jul 2024 14:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721139937; bh=dVwbQu2Lhi3yVdptdzzJwBkJyFVjnx7GDwNWH0Y84Gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPan5ZeyPTQI87bRdfoxI2AEhePqB5/nTlaC4dAMIJOhWUxdhFFqp2SMifwRuabJE 3gzlv1Ectu4iC/LvMAYcHSy501kHX7nVYIWfa3LKrum7lAhSvVIq8DPQP8CEOHNVlo kyzQI7IF/EV0XaFpMIGtk/RwL9JbntBozUVhqa9OKOnY2wZ6ZFjCzM33AmTfnU6wKR ihX0mOeN0msSmwHfgC+hOoxR8O1WP5RoWrXk7bZ7ZRwdG/QNkuxtq9Ao3VMmNBrtWb GsZpJJpVxlbhNPpsAU+TmrB14nf2dtL6jPtrqN+o++DH8d2SvMiaCZ8wJ9W8J/fiF9 4WdGV8sqhF7XA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tetsuo Handa , syzbot , Luiz Augusto von Dentz , Sasha Levin , marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 6.9 07/22] Bluetooth: hci_core: cancel all works upon hci_unregister_dev() Date: Tue, 16 Jul 2024 10:24:14 -0400 Message-ID: <20240716142519.2712487-7-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716142519.2712487-1-sashal@kernel.org> References: <20240716142519.2712487-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.9 Content-Transfer-Encoding: 8bit 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 24f6b6a5c7721..131bb8b5777b4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2744,7 +2744,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); hci_cmd_sync_clear(hdev); -- 2.43.0