Skip to contentSkip to conversation

media: venus: fix use after free in vdec_close

git:media_stage/master Hans Verkuil 1 participant 1 message Jun 30, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: venus: fix use after free in vdec_close
Author:  Dikshita Agarwal <[email protected]>
Date:    Thu May 9 10:44:29 2024 +0530

There appears to be a possible use after free with vdec_close(). The firmware will add buffer release work to the work queue through HFI callbacks as a normal part of decoding. Randomly closing the decoder device from userspace during normal decoding can incur a read after free for inst.

Fix it by cancelling the work in vdec_close.

Fixes af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
 drivers/media/platform/qcom/venus/vdec.c | 1 +
 1 file changed, 1 insertion(+)

---

drivers/media/platform/qcom/venus/vdec.c +1 -0
index 0d2ab95bec0f..d12089370d91 100644
@@ -1747,6 +1747,7 @@ static int vdec_close(struct file *file)
 
 	vdec_pm_get(inst);
 
+	cancel_work_sync(&inst->delayed_process_work);
 	v4l2_m2m_ctx_release(inst->m2m_ctx);
 	v4l2_m2m_release(inst->m2m_dev);
 	vdec_ctrl_deinit(inst);