Files
kernel_oneplus_sm8250/include/linux
Arnd Bergmann 01a4631d6f UPSTREAM: compat_ioctl: add compat_ptr_ioctl()
Many drivers have ioctl() handlers that are completely compatible between
32-bit and 64-bit architectures, except for the argument that is passed
down from user space and may have to be passed through compat_ptr()
in order to become a valid 64-bit pointer.

Using ".compat_ptr = compat_ptr_ioctl" in file operations should let
us simplify a lot of those drivers to avoid #ifdef checks, and convert
additional drivers that don't have proper compat handling yet.

On most architectures, the compat_ptr_ioctl() just passes all arguments
to the corresponding ->ioctl handler. The exception is arch/s390, where
compat_ptr() clears the top bit of a 32-bit pointer value, so user space
pointers to the second 2GB alias the first 2GB, as is the case for native
32-bit s390 user space.

The compat_ptr_ioctl() function must therefore be used only with
ioctl functions that either ignore the argument or pass a pointer to a
compatible data type.

If any ioctl command handled by fops->unlocked_ioctl passes a plain
integer instead of a pointer, or any of the passed data types is
incompatible between 32-bit and 64-bit architectures, a proper handler
is required instead of compat_ptr_ioctl.

Change-Id: Ia20c6ebcef3e02d16b7002d8c4934d6c750b492a
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: add a better description
v2: use compat_ptr_ioctl instead of generic_compat_ioctl_ptrarg,
as suggested by Al Viro
2025-12-03 07:05:50 -05:00
..
2025-08-31 10:10:00 +01:00
2025-09-30 21:35:03 +01:00
2022-10-26 13:19:32 +02:00
2022-12-17 00:25:35 +02:00
2025-08-30 09:46:24 +02:00
2025-08-30 09:46:24 +02:00
2020-06-17 06:00:22 +05:30
2021-01-30 13:32:12 +01:00
2020-05-11 10:27:22 -07:00
2024-06-09 02:32:30 +03:00
2021-03-05 07:01:18 +01:00
2021-08-27 15:24:34 +02:00
2022-08-25 11:15:23 +02:00
2020-09-09 19:48:58 +02:00
2025-08-30 09:45:32 +02:00
2021-06-30 19:17:14 +02:00
2023-06-21 15:39:57 +02:00
2025-09-22 10:17:51 +02:00
2020-06-16 12:51:47 -07:00
2023-02-22 12:28:07 +00:00
2025-09-16 13:55:10 +02:00
2025-08-28 03:26:18 +03:00
2023-10-25 11:16:20 +02:00
2021-12-14 10:18:04 +01:00
2025-08-30 09:45:32 +02:00
2023-05-18 15:51:07 +00:00
2020-09-11 11:22:30 -07:00
2024-02-23 08:12:39 +01:00