mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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 <[email protected]> Reported-by: Syzbot <[email protected]> Reviewed-by: Tomasz Figa <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
This commit is contained in:
parent
c1ced46c7b
commit
d65842f712
2 changed files with 23 additions and 0 deletions
|
|
@ -596,6 +596,7 @@ struct vb2_queue {
|
|||
unsigned int start_streaming_called:1;
|
||||
unsigned int error:1;
|
||||
unsigned int waiting_for_buffers:1;
|
||||
unsigned int waiting_in_dqbuf:1;
|
||||
unsigned int is_multiplanar:1;
|
||||
unsigned int is_output:1;
|
||||
unsigned int copy_timestamp:1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue