1 From 70194b474d22974cd46356e5b3d3b0582abd02da Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Thu, 24 Jan 2019 13:56:30 +0000
4 Subject: [PATCH] char: vcio: Add compat ioctl handling
6 There was no compat ioctl handler, so 32 bit userspace on a
7 64 bit kernel failed as IOCTL_MBOX_PROPERTY used the size
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 drivers/char/broadcom/vcio.c | 22 +++++++++++++++++++++-
13 1 file changed, 21 insertions(+), 1 deletion(-)
15 --- a/drivers/char/broadcom/vcio.c
16 +++ b/drivers/char/broadcom/vcio.c
19 #define VCIO_IOC_MAGIC 100
20 #define IOCTL_MBOX_PROPERTY _IOWR(VCIO_IOC_MAGIC, 0, char *)
22 +#define IOCTL_MBOX_PROPERTY32 _IOWR(VCIO_IOC_MAGIC, 0, compat_uptr_t)
27 @@ -87,13 +90,30 @@ static long vcio_device_ioctl(struct fil
28 case IOCTL_MBOX_PROPERTY:
29 return vcio_user_property_list((void *)ioctl_param);
31 - pr_err("unknown ioctl: %d\n", ioctl_num);
32 + pr_err("unknown ioctl: %x\n", ioctl_num);
38 +static long vcio_device_compat_ioctl(struct file *file, unsigned int ioctl_num,
39 + unsigned long ioctl_param)
41 + switch (ioctl_num) {
42 + case IOCTL_MBOX_PROPERTY32:
43 + return vcio_user_property_list(compat_ptr(ioctl_param));
45 + pr_err("unknown ioctl: %x\n", ioctl_num);
51 const struct file_operations vcio_fops = {
52 .unlocked_ioctl = vcio_device_ioctl,
54 + .compat_ioctl = vcio_device_compat_ioctl,
56 .open = vcio_device_open,
57 .release = vcio_device_release,