summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorZheng Wang <zyytlz.wz@163.com>2023-03-13 19:31:20 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-11 17:03:14 +0300
commit2cdc8f729d953143b3bbdc56841bb6800752de7f (patch)
treee2a36b421afa4a0a68f81a2ba046265cc1486183 /drivers/staging
parent231a6947ff8460f3353a12f4aa7a962304410da4 (diff)
downloadlinux-2cdc8f729d953143b3bbdc56841bb6800752de7f.tar.xz
media: cedrus: fix use after free bug in cedrus_remove due to race condition
[ Upstream commit 50d0a7aea4809cef87979d4669911276aa23b71f ] In cedrus_probe, dev->watchdog_work is bound with cedrus_watchdog function. In cedrus_device_run, it will started by schedule_delayed_work. If there is an unfinished work in cedrus_remove, there may be a race condition and trigger UAF bug. CPU0 CPU1 |cedrus_watchdog cedrus_remove | v4l2_m2m_release | kfree(m2m_dev) | | | v4l2_m2m_get_curr_priv | m2m_dev //use Fix it by canceling the worker in cedrus_remove. Fixes: 7c38a551bda1 ("media: cedrus: Add watchdog for job completion") Signed-off-by: Zheng Wang <zyytlz.wz@163.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/sunxi/cedrus/cedrus.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 55c54dfdc585..d2419319afd7 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -541,6 +541,7 @@ static int cedrus_remove(struct platform_device *pdev)
{
struct cedrus_dev *dev = platform_get_drvdata(pdev);
+ cancel_delayed_work_sync(&dev->watchdog_work);
if (media_devnode_is_registered(dev->mdev.devnode)) {
media_device_unregister(&dev->mdev);
v4l2_m2m_unregister_media_controller(dev->m2m_dev);