Skip to content

Commit 8779f45

Browse files
bluesheep1337sfX-bot
authored andcommitted
media: rkvdec: fix use after free bug in rkvdec_remove
[ Upstream commit 3228cec23b8b29215e18090c6ba635840190993d ] In rkvdec_probe, rkvdec->watchdog_work is bound with rkvdec_watchdog_func. Then rkvdec_vp9_run may be called to start the work. If we remove the module which will call rkvdec_remove to make cleanup, there may be a unfinished work. The possible sequence is as follows, which will cause a typical UAF bug. Fix it by canceling the work before cleanup in rkvdec_remove. CPU0 CPU1 |rkvdec_watchdog_func rkvdec_remove | rkvdec_v4l2_cleanup| v4l2_m2m_release | kfree(m2m_dev); | | | v4l2_m2m_get_curr_priv | m2m_dev->curr_ctx //use Fixes: cd33c83 ("media: rkvdec: Add the rkvdec driver") Signed-off-by: Zheng Wang <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 972a533 commit 8779f45

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/staging/media/rkvdec/rkvdec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@ static int rkvdec_remove(struct platform_device *pdev)
10771077
{
10781078
struct rkvdec_dev *rkvdec = platform_get_drvdata(pdev);
10791079

1080+
cancel_delayed_work_sync(&rkvdec->watchdog_work);
1081+
10801082
rkvdec_v4l2_cleanup(rkvdec);
10811083
pm_runtime_disable(&pdev->dev);
10821084
pm_runtime_dont_use_autosuspend(&pdev->dev);

0 commit comments

Comments
 (0)