[media] V4L2: fix VIDIOC_CREATE_BUFS in 64- / 32-bit compatibility mode
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Sat, 26 Apr 2014 15:51:31 +0000 (12:51 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 13 May 2014 23:00:28 +0000 (20:00 -0300)
commitec77581a6ca0be566bf3428263820da6d12ed5ae
tree8cb4811439d7e6ee45b2bb8e914e985678f7ddb6
parent322e6d19ede96ac6c13a132590c435ff17e0827f
[media] V4L2: fix VIDIOC_CREATE_BUFS in 64- / 32-bit compatibility mode

If a struct contains 64-bit fields, it is aligned on 64-bit boundaries
within containing structs in 64-bit compilations. This is the case with
struct v4l2_window, which contains pointers and is embedded into struct
v4l2_format, and that one is embedded into struct v4l2_create_buffers.
Unlike some other structs, used as a part of the kernel ABI as ioctl()
arguments, that are packed, these structs aren't packed. This isn't a
problem per se, but the ioctl-compat code for VIDIOC_CREATE_BUFS contains
a bug, that triggers in such 64-bit builds. That code wrongly assumes,
that in struct v4l2_create_buffers, struct v4l2_format immediately follows
the __u32 memory field, which in fact isn't the case. This bug wasn't
visible until now, because until recently hardly any applications used
this ioctl() and mostly embedded 32-bit only drivers implemented it. This
is changing now with addition of this ioctl() to some USB drivers, e.g.
UVC. This patch fixes the bug by copying parts of struct
v4l2_create_buffers separately.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-compat-ioctl32.c