]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
media: vb2: vb2_mmap: move lock up
authorHans Verkuil <hverkuil@xs4all.nl>
Tue, 13 Nov 2018 14:06:46 +0000 (09:06 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Jan 2019 20:09:56 +0000 (21:09 +0100)
commitc1014f1acf797e910d4b9f60a592c18a2aa9609d
tree671afa94afa9e33fa1571efc2ab724cbaf0ae0d6
parent06959caf70bc8ac27743381c5cf159ba1a23ca4d
media: vb2: vb2_mmap: move lock up

commit cd26d1c4d1bc947b56ae404998ae2276df7b39b7 upstream.

If a filehandle is dup()ped, then it is possible to close it from one fd
and call mmap from the other. This creates a race condition in vb2_mmap
where it is using queue data that __vb2_queue_free (called from close())
is in the process of releasing.

By moving up the mutex_lock(mmap_lock) in vb2_mmap this race is avoided
since __vb2_queue_free is called with the same mutex locked. So vb2_mmap
now reads consistent buffer data.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reported-by: syzbot+be93025dd45dccd8923c@syzkaller.appspotmail.com
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/common/videobuf2/videobuf2-core.c