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 D37F6CD13DA for ; Sun, 17 Sep 2023 19:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbjIQTRT (ORCPT ); Sun, 17 Sep 2023 15:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjIQTQy (ORCPT ); Sun, 17 Sep 2023 15:16:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C69FA for ; Sun, 17 Sep 2023 12:16:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB2C0C433C7; Sun, 17 Sep 2023 19:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694978208; bh=AowzVBOMXUjVHZDLDOWt5KlxuOqVfac+4P76kuLkK58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fm3o010ma9PDZ6kD2mfo5iuv45YvWgCwnu//+AwwUeWvwjF/95osV4Yc5Aq5atWXH +rO663fKD3rtlp+W2zrdW/6DcpajcDMWc4lI5jqtK1WlaQZryB2vRAOrfYeMPSrtHN /uzPJy22KRwDJA7v8J/0Y+YqahYcz8i9tBw4arpo= 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.10 013/406] Bluetooth: btsdio: fix use after free bug in btsdio_remove due to race condition Date: Sun, 17 Sep 2023 21:07:47 +0200 Message-ID: <20230917191101.481868540@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917191101.035638219@linuxfoundation.org> References: <20230917191101.035638219@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 5.10-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);