From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ACCDCE79CE for ; Wed, 20 Sep 2023 12:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235339AbjITMKZ (ORCPT ); Wed, 20 Sep 2023 08:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235470AbjITMJy (ORCPT ); Wed, 20 Sep 2023 08:09:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C40CEB4 for ; Wed, 20 Sep 2023 05:09:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13F4BC433C7; Wed, 20 Sep 2023 12:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695211788; bh=S7ruFL9kXdOuq4RtPcaEkPOf4OGH3Vvbr5qcIw9AeTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ke0mVvzgzBI5ngA9ca8UNVFXCCLzrMQh0cKOdsSBxzCNmct2i2PtnVY8QpXh9irgH nRkHO8A6wujezpxtG33wcVznWAYBgdMEidbS4GBJpLB8s0Zqa3rWw3F5HN47V013vT uB0jtecblth0vJk0XXfsbeUEnBRW922BECQ8ycyY= 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 4.19 009/273] Bluetooth: btsdio: fix use after free bug in btsdio_remove due to race condition Date: Wed, 20 Sep 2023 13:27:29 +0200 Message-ID: <20230920112846.721021880@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112846.440597133@linuxfoundation.org> References: <20230920112846.440597133@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.19-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 @@ -356,6 +356,7 @@ static void btsdio_remove(struct sdio_fu if (!data) return; + cancel_work_sync(&data->work); hdev = data->hdev; sdio_set_drvdata(func, NULL);