linux/drivers/media/common/videobuf2
Hans Verkuil d65842f712 media: vb2: add waiting_in_dqbuf flag
Calling VIDIOC_DQBUF can release the core serialization lock pointed to
by vb2_queue->lock if it has to wait for a new buffer to arrive.

However, if userspace dup()ped the video device filehandle, then it is
possible to read or call DQBUF from two filehandles at the same time.

It is also possible to call REQBUFS from one filehandle while the other
is waiting for a buffer. This will remove all the buffers and reallocate
new ones. Removing all the buffers isn't the problem here (that's already
handled correctly by DQBUF), but the reallocating part is: DQBUF isn't
aware that the buffers have changed.

This is fixed by setting a flag whenever the lock is released while waiting
for a buffer to arrive. And checking the flag where needed so we can return
-EBUSY.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reported-by: Syzbot <syzbot+4180ff9ca6810b06c1e9@syzkaller.appspotmail.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-04-22 11:50:07 -04:00
..
Kconfig media: Remove depends on HAS_DMA in case of platform dependency 2018-05-28 16:17:08 -04:00
Makefile media: vb2: Makefile: place vb2-trace together with vb2-core 2018-02-26 11:39:04 -05:00
vb2-trace.c media: videobuf2: fix build issues with vb2-trace 2018-02-23 05:13:53 -05:00
videobuf2-core.c media: vb2: add waiting_in_dqbuf flag 2019-04-22 11:50:07 -04:00
videobuf2-dma-contig.c videobuf2: replace a layering violation with dma_map_resource 2019-02-01 09:56:41 +01:00
videobuf2-dma-sg.c media: common: fix several typos 2019-03-01 09:44:48 -05:00
videobuf2-dvb.c
videobuf2-memops.c media: common: fix several typos 2019-03-01 09:44:48 -05:00
videobuf2-v4l2.c media: videobuf2-v4l2.c: move up STATE_DEQUEUED check 2019-04-22 11:43:00 -04:00
videobuf2-vmalloc.c media: videobuf2: Return error after allocation failure 2019-03-19 14:03:55 -04:00