bcm27xx: 6.1: add kernel patches
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0738-pps-Compatibility-hack-should-be-X86-specific.patch
1 From 138d22ae4abf49d9694a4398857fb4be5114f103 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Mon, 22 May 2023 14:22:55 +0100
4 Subject: [PATCH] pps: Compatibility hack should be X86-specific
5
6 As of [1], using PPS_FETCH on a 64-bit ARM kernel with a 32-bit userland
7 is broken, returning a timeout. This is because the requested 4-byte
8 alignment for struct pps_ktime_compat (illegal on arm64) results in the
9 timeout flags field being uninitialised.
10
11 Make the hack specific to X86_64 builds with CONFIG_COMPAT defined.
12
13 [1] commit c2a49fe8eeef ("pps: fix padding issue with PPS_FETCH for
14 ioctl_compat")
15
16 See: https://github.com/raspberrypi/linux/issues/5430
17 Fixes: c2a49fe8eeef ("pps: fix padding issue with PPS_FETCH for ioctl_compat")
18 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
19 ---
20 drivers/pps/pps.c | 6 ++++--
21 1 file changed, 4 insertions(+), 2 deletions(-)
22
23 --- a/drivers/pps/pps.c
24 +++ b/drivers/pps/pps.c
25 @@ -249,12 +249,13 @@ static long pps_cdev_ioctl(struct file *
26 static long pps_cdev_compat_ioctl(struct file *file,
27 unsigned int cmd, unsigned long arg)
28 {
29 - struct pps_device *pps = file->private_data;
30 - void __user *uarg = (void __user *) arg;
31
32 cmd = _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(void *));
33
34 +#ifdef CONFIG_X86_64
35 if (cmd == PPS_FETCH) {
36 + struct pps_device *pps = file->private_data;
37 + void __user *uarg = (void __user *) arg;
38 struct pps_fdata_compat compat;
39 struct pps_fdata fdata;
40 int err;
41 @@ -289,6 +290,7 @@ static long pps_cdev_compat_ioctl(struct
42 return copy_to_user(uarg, &compat,
43 sizeof(struct pps_fdata_compat)) ? -EFAULT : 0;
44 }
45 +#endif
46
47 return pps_cdev_ioctl(file, cmd, arg);
48 }