Patch "media: cedrus: fix use after free bug in cedrus_remove due to race condition" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    media: cedrus: fix use after free bug in cedrus_remove due to race condition

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     media-cedrus-fix-use-after-free-bug-in-cedrus_remove.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0448f6c3462150cfc1533662c2c8f4ad0769da28
Author: Zheng Wang <zyytlz.wz@xxxxxxx>
Date:   Mon Mar 13 16:31:20 2023 +0000

    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@xxxxxxx>
    Acked-by: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index a43d5ff667163..a50a4d0a8f715 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -547,6 +547,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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux