Skip to content

Commit

Permalink
media: exynos4-is: Fix a use after free in isp_video_release
Browse files Browse the repository at this point in the history
In isp_video_release, file->private_data is freed via
_vb2_fop_release()->v4l2_fh_release(). But the freed
file->private_data is still used in v4l2_fh_is_singular_file()
->v4l2_fh_is_singular(file->private_data), which is a use
after free bug.

My patch uses a variable 'is_singular_file' to avoid the uaf.
v3: https://lore.kernel.org/patchwork/patch/1419058/

Fixes: 34947b8 ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA driver")
Signed-off-by: Lv Yunlong <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Yunlongs authored and mchehab committed Jun 2, 2021
1 parent f9c2fd3 commit 01fe904
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/media/platform/exynos4-is/fimc-isp-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,20 @@ static int isp_video_release(struct file *file)
struct fimc_is_video *ivc = &isp->video_capture;
struct media_entity *entity = &ivc->ve.vdev.entity;
struct media_device *mdev = entity->graph_obj.mdev;
bool is_singular_file;

mutex_lock(&isp->video_lock);

if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
is_singular_file = v4l2_fh_is_singular_file(file);

if (is_singular_file && ivc->streaming) {
media_pipeline_stop(entity);
ivc->streaming = 0;
}

_vb2_fop_release(file, NULL);

if (v4l2_fh_is_singular_file(file)) {
if (is_singular_file) {
fimc_pipeline_call(&ivc->ve, close);

mutex_lock(&mdev->graph_mutex);
Expand Down

0 comments on commit 01fe904

Please sign in to comment.