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 3FA025683 for ; Mon, 3 Apr 2023 14:11:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1304C433D2; Mon, 3 Apr 2023 14:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680531098; bh=Ln/lfPB/i44AdjzE3fAZ0YGhQc5SmLWIszoCNLrFTeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P2v7zqAz2q/udwxkKlH88M+tP39GtcQEKNtQiUtu+anKHUuh32hoY+W+s4rikoBUQ mUlsJ1yVc/dhyBpEdmZNvYQ3RJ6blRhpGq0hln3QL225qZhNkyWAY93tU/4hV533TZ Oe1umhOZjHb4CU6tlCFvqmHjUGd/T51hl3FZxJCs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zheng Wang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 4.14 19/66] Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work Date: Mon, 3 Apr 2023 16:08:27 +0200 Message-Id: <20230403140352.592297669@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403140351.636471867@linuxfoundation.org> References: <20230403140351.636471867@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Zheng Wang [ Upstream commit 1e9ac114c4428fdb7ff4635b45d4f46017e8916f ] In btsdio_probe, &data->work was bound with btsdio_work.In btsdio_send_frame, it was started by schedule_work. If we call btsdio_remove with an unfinished job, there may be a race condition and cause UAF bug on hdev. Fixes: ddbaf13e3609 ("[Bluetooth] Add generic driver for Bluetooth SDIO devices") Signed-off-by: Zheng Wang Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btsdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index 20142bc77554c..bd55bf7a9914c 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -353,6 +353,7 @@ static void btsdio_remove(struct sdio_func *func) BT_DBG("func %p", func); + cancel_work_sync(&data->work); if (!data) return; -- 2.39.2