Commit 655e9780 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Mauro Carvalho Chehab

[media] v4l2-compat-ioctl32: fix alignment for ARM64

Alignment/padding rules on AMD64 and ARM64 differs. To allow properly match
compatible ioctls on ARM64 kernels without breaking AMD64 some fields
should be aligned using compat_s64 type and in one case struct should be
unpacked.
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Cc: <stable@vger.kernel.org>      # for v3.10 and up
[hans.verkuil@cisco.com: use compat_u64 instead of compat_s64 in v4l2_input32]
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 63ab664c
...@@ -266,7 +266,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_ ...@@ -266,7 +266,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_
struct v4l2_standard32 { struct v4l2_standard32 {
__u32 index; __u32 index;
__u32 id[2]; /* __u64 would get the alignment wrong */ compat_u64 id;
__u8 name[24]; __u8 name[24];
struct v4l2_fract frameperiod; /* Frames, not fields */ struct v4l2_fract frameperiod; /* Frames, not fields */
__u32 framelines; __u32 framelines;
...@@ -286,7 +286,7 @@ static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 ...@@ -286,7 +286,7 @@ static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32
{ {
if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) || if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) ||
put_user(kp->index, &up->index) || put_user(kp->index, &up->index) ||
copy_to_user(up->id, &kp->id, sizeof(__u64)) || put_user(kp->id, &up->id) ||
copy_to_user(up->name, kp->name, 24) || copy_to_user(up->name, kp->name, 24) ||
copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) || copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) ||
put_user(kp->framelines, &up->framelines) || put_user(kp->framelines, &up->framelines) ||
...@@ -587,10 +587,10 @@ struct v4l2_input32 { ...@@ -587,10 +587,10 @@ struct v4l2_input32 {
__u32 type; /* Type of input */ __u32 type; /* Type of input */
__u32 audioset; /* Associated audios (bitfield) */ __u32 audioset; /* Associated audios (bitfield) */
__u32 tuner; /* Associated tuner */ __u32 tuner; /* Associated tuner */
v4l2_std_id std; compat_u64 std;
__u32 status; __u32 status;
__u32 reserved[4]; __u32 reserved[4];
} __attribute__ ((packed)); };
/* The 64-bit v4l2_input struct has extra padding at the end of the struct. /* The 64-bit v4l2_input struct has extra padding at the end of the struct.
Otherwise it is identical to the 32-bit version. */ Otherwise it is identical to the 32-bit version. */
...@@ -738,6 +738,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext ...@@ -738,6 +738,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
struct v4l2_event32 { struct v4l2_event32 {
__u32 type; __u32 type;
union { union {
compat_s64 value64;
__u8 data[64]; __u8 data[64];
} u; } u;
__u32 pending; __u32 pending;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment