diff options
author | Arnaud Patard <apatard@mandriva.com> | 2010-01-25 16:02:31 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 19:10:49 +0100 |
commit | 22c859faf5e10e7f7b04a2c643a98eeee69c1815 (patch) | |
tree | 0257f38579b7055c8a5163d9961865726e95616f /drivers/media/video/v4l2-compat-ioctl32.c | |
parent | V4L/DVB: zoran: remove variable shadowing (diff) | |
download | linux-22c859faf5e10e7f7b04a2c643a98eeee69c1815.tar.xz linux-22c859faf5e10e7f7b04a2c643a98eeee69c1815.zip |
V4L/DVB: Fix VIDIOC_QBUF compat ioctl32
When using VIDIOC_QBUF with memory type set to V4L2_MEMORY_MMAP, the
v4l2_buffer buffer gets unmodified on drivers like uvc (well, only
bytesused field is modified). Then some apps like gstreamer are reusing
the same buffer later to call munmap (eg passing the buffer "length"
field as 2nd parameter of munmap).
It's working fine on full 32bits but on 32bits systems with 64bit
kernel, the get_v4l2_buffer32() doesn't copy length/m.offset values and
then copy garbage to userspace in put_v4l2_buffer32().
This has for consequence things like that in the libv4l2 logs:
libv4l2: v4l2 unknown munmap 0x2e2b0000, -2145144908
libv4l2: v4l2 unknown munmap 0x2e530000, -2145144908
The buffer are not unmap'ed and then if the application close and open
again the device, it won't work and logs will show something like:
libv4l2: error setting pixformat: Device or resource busy
The easy solution is to read length and m.offset in get_v4l2_buffer32().
Signed-off-by: Arnaud Patard <apatard@mandriva.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-compat-ioctl32.c')
-rw-r--r-- | drivers/media/video/v4l2-compat-ioctl32.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index dc7b8c23eac0..f77f84bfe714 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c @@ -475,6 +475,9 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user return -EFAULT; switch (kp->memory) { case V4L2_MEMORY_MMAP: + if (get_user(kp->length, &up->length) || + get_user(kp->m.offset, &up->m.offset)) + return -EFAULT; break; case V4L2_MEMORY_USERPTR: { |