From: Zheng Wang Date: Thu, 9 Mar 2023 08:07:39 +0000 (+0800) Subject: Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work X-Git-Tag: baikal/mips/sdk5.8.2~80 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=8cc600746c7d188bb3995221f8c175b7d750af7f;p=kernel.git Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work [ 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: d129a62d7d1d ("[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 --- diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index fd9571d5fdac9..81125fb180351 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -343,6 +343,7 @@ static void btsdio_remove(struct sdio_func *func) BT_DBG("func %p", func); + cancel_work_sync(&data->work); if (!data) return;