ar71xx/ath79: ag71xx: dont fetch the same var again
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-4.19 / 950-0314-char-vcio-Add-compat-ioctl-handling.patch
1 From cc33f2492b4b2c0d377f99c19a46207297004631 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 314/725] char: vcio: Add compat ioctl handling
5
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
8 of char*.
9
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
11 ---
12 drivers/char/broadcom/vcio.c | 22 +++++++++++++++++++++-
13 1 file changed, 21 insertions(+), 1 deletion(-)
14
15 --- a/drivers/char/broadcom/vcio.c
16 +++ b/drivers/char/broadcom/vcio.c
17 @@ -24,6 +24,9 @@
18
19 #define VCIO_IOC_MAGIC 100
20 #define IOCTL_MBOX_PROPERTY _IOWR(VCIO_IOC_MAGIC, 0, char *)
21 +#ifdef CONFIG_COMPAT
22 +#define IOCTL_MBOX_PROPERTY32 _IOWR(VCIO_IOC_MAGIC, 0, compat_uptr_t)
23 +#endif
24
25 static struct {
26 dev_t devt;
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);
30 default:
31 - pr_err("unknown ioctl: %d\n", ioctl_num);
32 + pr_err("unknown ioctl: %x\n", ioctl_num);
33 return -EINVAL;
34 }
35 }
36
37 +#ifdef CONFIG_COMPAT
38 +static long vcio_device_compat_ioctl(struct file *file, unsigned int ioctl_num,
39 + unsigned long ioctl_param)
40 +{
41 + switch (ioctl_num) {
42 + case IOCTL_MBOX_PROPERTY32:
43 + return vcio_user_property_list(compat_ptr(ioctl_param));
44 + default:
45 + pr_err("unknown ioctl: %x\n", ioctl_num);
46 + return -EINVAL;
47 + }
48 +}
49 +#endif
50 +
51 const struct file_operations vcio_fops = {
52 .unlocked_ioctl = vcio_device_ioctl,
53 +#ifdef CONFIG_COMPAT
54 + .compat_ioctl = vcio_device_compat_ioctl,
55 +#endif
56 .open = vcio_device_open,
57 .release = vcio_device_release,
58 };