Skip to content

Commit 04affe4

Browse files
danielmentzgooglegregkh
authored andcommitted
media: v4l2-compat-ioctl32: Fix timespec conversion
commit 9c7ba1d7634cef490b85bc64c4091ff004821bfd upstream. Certain syscalls like recvmmsg support 64 bit timespec values for the X32 ABI. The helper function compat_put_timespec converts a timespec value to a 32 bit or 64 bit value depending on what ABI is used. The v4l2 compat layer, however, is not designed to support 64 bit timespec values and always uses 32 bit values. Hence, compat_put_timespec must not be used. Without this patch, user space will be provided with bad timestamp values from the VIDIOC_DQEVENT ioctl. Also, fields of the struct v4l2_event32 that come immediately after timestamp get overwritten, namely the field named id. Fixes: 81993e8 ("compat: Get rid of (get|put)_compat_time(val|spec)") Cc: H. Peter Anvin <hpa@linux.intel.com> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Cc: Tiffany Lin <tiffany.lin@mediatek.com> Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Daniel Mentz <danielmentz@google.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7498bd6 commit 04affe4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/media/v4l2-core/v4l2-compat-ioctl32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
773773
copy_to_user(&up->u, &kp->u, sizeof(kp->u)) ||
774774
put_user(kp->pending, &up->pending) ||
775775
put_user(kp->sequence, &up->sequence) ||
776-
compat_put_timespec(&kp->timestamp, &up->timestamp) ||
776+
put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) ||
777+
put_user(kp->timestamp.tv_nsec, &up->timestamp.tv_nsec) ||
777778
put_user(kp->id, &up->id) ||
778779
copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32)))
779780
return -EFAULT;

0 commit comments

Comments
 (0)