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 2E583C142 for ; Mon, 4 Sep 2023 18:36:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A67ECC433C7; Mon, 4 Sep 2023 18:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693852572; bh=0o0K5fduYPQwiQvZH5GjCwDM3+alAL5XocwGwgDv6A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0CPfcGkI1+5M3aVmRIvEXKzkc5Li5ELSnTe6+mZaKg+qzmXFFYd4+MHmT+KKrnvYx COixFAcZwbcpVlrGLz1zgusZ1jH0YHisDXa2/YZKNDmFv9vmcVsRSBwDDds/tx8zs/ kfyftEOiirqi9lghDHM4T1k9SO8mnyR+fjYhI5/Q= 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 5.15 16/28] Bluetooth: btsdio: fix use after free bug in btsdio_remove due to race condition Date: Mon, 4 Sep 2023 19:30:47 +0100 Message-ID: <20230904182945.945335299@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230904182945.178705038@linuxfoundation.org> References: <20230904182945.178705038@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: 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 @@ -355,6 +355,7 @@ static void btsdio_remove(struct sdio_fu if (!data) return; + cancel_work_sync(&data->work); hdev = data->hdev; sdio_set_drvdata(func, NULL);