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 64F1EC142 for ; Mon, 4 Sep 2023 18:34:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF53CC433C8; Mon, 4 Sep 2023 18:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693852489; bh=FAJJSBiEsxxd0ktJBPuEGYtnrzeACx6L4VbH5hEI8Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtqzSOiXBJPf4OSPwzMjcNtzi3DZz14W89eZNLWtKz5j06m4V2qns1n9sk22qoMuQ X1JroyQdT2Dl12gER+YH3050tkN6g4f/Nhibfp3sk+vu42PTtBXxpOLddCi0oUb1Py puGcB/xu4BrFoQXFKZ0OaAkosEMCI2MS0XDgxVN0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zheng Wang , Luiz Augusto von Dentz , "Denis Efremov (Oracle)" Subject: [PATCH 6.1 18/31] Bluetooth: btsdio: fix use after free bug in btsdio_remove due to race condition Date: Mon, 4 Sep 2023 19:30:26 +0100 Message-ID: <20230904182947.917790680@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230904182946.999390199@linuxfoundation.org> References: <20230904182946.999390199@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zheng Wang commit 73f7b171b7c09139eb3c6a5677c200dc1be5f318 upstream. In btsdio_probe, the data->work is bound with btsdio_work. It will be started in btsdio_send_frame. If the btsdio_remove runs with a unfinished work, there may be a race condition that hdev is freed but used in btsdio_work. Fix it by canceling the work before do cleanup in btsdio_remove. Fixes: CVE-2023-1989 Fixes: ddbaf13e3609 ("[Bluetooth] Add generic driver for Bluetooth SDIO devices") Cc: stable@vger.kernel.org Signed-off-by: Zheng Wang Signed-off-by: Luiz Augusto von Dentz [ Denis: Added CVE-2023-1989 and fixes tags. ] Signed-off-by: Denis Efremov (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/btsdio.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -357,6 +357,7 @@ static void btsdio_remove(struct sdio_fu if (!data) return; + cancel_work_sync(&data->work); hdev = data->hdev; sdio_set_drvdata(func, NULL);