Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

compat_ioctl: move more drivers to compat_ptr_ioctl

The .ioctl and .compat_ioctl file operations have the same prototype so
they can both point to the same function, which works great almost all
the time when all the commands are compatible.

One exception is the s390 architecture, where a compat pointer is only
31 bit wide, and converting it into a 64-bit pointer requires calling
compat_ptr(). Most drivers here will never run in s390, but since we now
have a generic helper for it, it's easy enough to use it consistently.

I double-checked all these drivers to ensure that all ioctl arguments
are used as pointers or are ignored, but are not interpreted as integer
values.

Acked-by: Jason Gunthorpe <jgg@mellanox.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Sterba <dsterba@suse.com>
Acked-by: Darren Hart (VMware) <dvhart@infradead.org>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+36 -52
+1 -1
drivers/android/binder.c
··· 6063 6063 .owner = THIS_MODULE, 6064 6064 .poll = binder_poll, 6065 6065 .unlocked_ioctl = binder_ioctl, 6066 - .compat_ioctl = binder_ioctl, 6066 + .compat_ioctl = compat_ptr_ioctl, 6067 6067 .mmap = binder_mmap, 6068 6068 .open = binder_open, 6069 6069 .flush = binder_flush,
+1 -1
drivers/crypto/qat/qat_common/adf_ctl_drv.c
··· 68 68 static const struct file_operations adf_ctl_ops = { 69 69 .owner = THIS_MODULE, 70 70 .unlocked_ioctl = adf_ctl_ioctl, 71 - .compat_ioctl = adf_ctl_ioctl, 71 + .compat_ioctl = compat_ptr_ioctl, 72 72 }; 73 73 74 74 struct adf_ctl_drv_info {
+1 -3
drivers/dma-buf/dma-buf.c
··· 415 415 .llseek = dma_buf_llseek, 416 416 .poll = dma_buf_poll, 417 417 .unlocked_ioctl = dma_buf_ioctl, 418 - #ifdef CONFIG_COMPAT 419 - .compat_ioctl = dma_buf_ioctl, 420 - #endif 418 + .compat_ioctl = compat_ptr_ioctl, 421 419 .show_fdinfo = dma_buf_show_fdinfo, 422 420 }; 423 421
+1 -1
drivers/dma-buf/sw_sync.c
··· 408 408 .open = sw_sync_debugfs_open, 409 409 .release = sw_sync_debugfs_release, 410 410 .unlocked_ioctl = sw_sync_ioctl, 411 - .compat_ioctl = sw_sync_ioctl, 411 + .compat_ioctl = compat_ptr_ioctl, 412 412 };
+1 -1
drivers/dma-buf/sync_file.c
··· 480 480 .release = sync_file_release, 481 481 .poll = sync_file_poll, 482 482 .unlocked_ioctl = sync_file_ioctl, 483 - .compat_ioctl = sync_file_ioctl, 483 + .compat_ioctl = compat_ptr_ioctl, 484 484 };
+1 -1
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 49 49 static const struct file_operations kfd_fops = { 50 50 .owner = THIS_MODULE, 51 51 .unlocked_ioctl = kfd_ioctl, 52 - .compat_ioctl = kfd_ioctl, 52 + .compat_ioctl = compat_ptr_ioctl, 53 53 .open = kfd_open, 54 54 .mmap = kfd_mmap, 55 55 };
+1 -3
drivers/hid/hidraw.c
··· 468 468 .release = hidraw_release, 469 469 .unlocked_ioctl = hidraw_ioctl, 470 470 .fasync = hidraw_fasync, 471 - #ifdef CONFIG_COMPAT 472 - .compat_ioctl = hidraw_ioctl, 473 - #endif 471 + .compat_ioctl = compat_ptr_ioctl, 474 472 .llseek = noop_llseek, 475 473 }; 476 474
+1 -1
drivers/iio/industrialio-core.c
··· 1610 1610 .owner = THIS_MODULE, 1611 1611 .llseek = noop_llseek, 1612 1612 .unlocked_ioctl = iio_ioctl, 1613 - .compat_ioctl = iio_ioctl, 1613 + .compat_ioctl = compat_ptr_ioctl, 1614 1614 }; 1615 1615 1616 1616 static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
+2 -2
drivers/infiniband/core/uverbs_main.c
··· 1139 1139 .release = ib_uverbs_close, 1140 1140 .llseek = no_llseek, 1141 1141 .unlocked_ioctl = ib_uverbs_ioctl, 1142 - .compat_ioctl = ib_uverbs_ioctl, 1142 + .compat_ioctl = compat_ptr_ioctl, 1143 1143 }; 1144 1144 1145 1145 static const struct file_operations uverbs_mmap_fops = { ··· 1150 1150 .release = ib_uverbs_close, 1151 1151 .llseek = no_llseek, 1152 1152 .unlocked_ioctl = ib_uverbs_ioctl, 1153 - .compat_ioctl = ib_uverbs_ioctl, 1153 + .compat_ioctl = compat_ptr_ioctl, 1154 1154 }; 1155 1155 1156 1156 static int ib_uverbs_get_nl_info(struct ib_device *ibdev, void *client_data,
+1 -3
drivers/media/rc/lirc_dev.c
··· 720 720 .owner = THIS_MODULE, 721 721 .write = ir_lirc_transmit_ir, 722 722 .unlocked_ioctl = ir_lirc_ioctl, 723 - #ifdef CONFIG_COMPAT 724 - .compat_ioctl = ir_lirc_ioctl, 725 - #endif 723 + .compat_ioctl = compat_ptr_ioctl, 726 724 .read = ir_lirc_read, 727 725 .poll = ir_lirc_poll, 728 726 .open = ir_lirc_open,
+1 -1
drivers/misc/vmw_vmci/vmci_host.c
··· 961 961 .release = vmci_host_close, 962 962 .poll = vmci_host_poll, 963 963 .unlocked_ioctl = vmci_host_unlocked_ioctl, 964 - .compat_ioctl = vmci_host_unlocked_ioctl, 964 + .compat_ioctl = compat_ptr_ioctl, 965 965 }; 966 966 967 967 static struct miscdevice vmci_host_miscdev = {
+2 -2
drivers/nvdimm/bus.c
··· 1227 1227 .owner = THIS_MODULE, 1228 1228 .open = nd_open, 1229 1229 .unlocked_ioctl = bus_ioctl, 1230 - .compat_ioctl = bus_ioctl, 1230 + .compat_ioctl = compat_ptr_ioctl, 1231 1231 .llseek = noop_llseek, 1232 1232 }; 1233 1233 ··· 1235 1235 .owner = THIS_MODULE, 1236 1236 .open = nd_open, 1237 1237 .unlocked_ioctl = dimm_ioctl, 1238 - .compat_ioctl = dimm_ioctl, 1238 + .compat_ioctl = compat_ptr_ioctl, 1239 1239 .llseek = noop_llseek, 1240 1240 }; 1241 1241
+1 -1
drivers/nvme/host/core.c
··· 2947 2947 .owner = THIS_MODULE, 2948 2948 .open = nvme_dev_open, 2949 2949 .unlocked_ioctl = nvme_dev_ioctl, 2950 - .compat_ioctl = nvme_dev_ioctl, 2950 + .compat_ioctl = compat_ptr_ioctl, 2951 2951 }; 2952 2952 2953 2953 static ssize_t nvme_sysfs_reset(struct device *dev,
+1 -1
drivers/pci/switch/switchtec.c
··· 1025 1025 .read = switchtec_dev_read, 1026 1026 .poll = switchtec_dev_poll, 1027 1027 .unlocked_ioctl = switchtec_dev_ioctl, 1028 - .compat_ioctl = switchtec_dev_ioctl, 1028 + .compat_ioctl = compat_ptr_ioctl, 1029 1029 }; 1030 1030 1031 1031 static void link_event_work(struct work_struct *work)
+1 -1
drivers/platform/x86/wmi.c
··· 911 911 .read = wmi_char_read, 912 912 .open = wmi_char_open, 913 913 .unlocked_ioctl = wmi_ioctl, 914 - .compat_ioctl = wmi_ioctl, 914 + .compat_ioctl = compat_ptr_ioctl, 915 915 }; 916 916 917 917 static int wmi_dev_probe(struct device *dev)
+2 -2
drivers/rpmsg/rpmsg_char.c
··· 290 290 .write_iter = rpmsg_eptdev_write_iter, 291 291 .poll = rpmsg_eptdev_poll, 292 292 .unlocked_ioctl = rpmsg_eptdev_ioctl, 293 - .compat_ioctl = rpmsg_eptdev_ioctl, 293 + .compat_ioctl = compat_ptr_ioctl, 294 294 }; 295 295 296 296 static ssize_t name_show(struct device *dev, struct device_attribute *attr, ··· 451 451 .open = rpmsg_ctrldev_open, 452 452 .release = rpmsg_ctrldev_release, 453 453 .unlocked_ioctl = rpmsg_ctrldev_ioctl, 454 - .compat_ioctl = rpmsg_ctrldev_ioctl, 454 + .compat_ioctl = compat_ptr_ioctl, 455 455 }; 456 456 457 457 static void rpmsg_ctrldev_release_device(struct device *dev)
+1 -1
drivers/sbus/char/display7seg.c
··· 156 156 static const struct file_operations d7s_fops = { 157 157 .owner = THIS_MODULE, 158 158 .unlocked_ioctl = d7s_ioctl, 159 - .compat_ioctl = d7s_ioctl, 159 + .compat_ioctl = compat_ptr_ioctl, 160 160 .open = d7s_open, 161 161 .release = d7s_release, 162 162 .llseek = noop_llseek,
+1 -3
drivers/sbus/char/envctrl.c
··· 715 715 .owner = THIS_MODULE, 716 716 .read = envctrl_read, 717 717 .unlocked_ioctl = envctrl_ioctl, 718 - #ifdef CONFIG_COMPAT 719 - .compat_ioctl = envctrl_ioctl, 720 - #endif 718 + .compat_ioctl = compat_ptr_ioctl, 721 719 .open = envctrl_open, 722 720 .release = envctrl_release, 723 721 .llseek = noop_llseek,
+1 -3
drivers/scsi/3w-xxxx.c
··· 1049 1049 static const struct file_operations tw_fops = { 1050 1050 .owner = THIS_MODULE, 1051 1051 .unlocked_ioctl = tw_chrdev_ioctl, 1052 - #ifdef CONFIG_COMPAT 1053 - .compat_ioctl = tw_chrdev_ioctl, 1054 - #endif 1052 + .compat_ioctl = compat_ptr_ioctl, 1055 1053 .open = tw_chrdev_open, 1056 1054 .release = NULL, 1057 1055 .llseek = noop_llseek,
+1 -1
drivers/scsi/cxlflash/main.c
··· 3593 3593 .owner = THIS_MODULE, 3594 3594 .open = cxlflash_chr_open, 3595 3595 .unlocked_ioctl = cxlflash_chr_ioctl, 3596 - .compat_ioctl = cxlflash_chr_ioctl, 3596 + .compat_ioctl = compat_ptr_ioctl, 3597 3597 }; 3598 3598 3599 3599 /**
+1 -1
drivers/scsi/esas2r/esas2r_main.c
··· 613 613 614 614 /* Handle ioctl calls to "/proc/scsi/esas2r/ATTOnode" */ 615 615 static const struct file_operations esas2r_proc_fops = { 616 - .compat_ioctl = esas2r_proc_ioctl, 616 + .compat_ioctl = compat_ptr_ioctl, 617 617 .unlocked_ioctl = esas2r_proc_ioctl, 618 618 }; 619 619
+1 -3
drivers/scsi/pmcraid.c
··· 3973 3973 .open = pmcraid_chr_open, 3974 3974 .fasync = pmcraid_chr_fasync, 3975 3975 .unlocked_ioctl = pmcraid_chr_ioctl, 3976 - #ifdef CONFIG_COMPAT 3977 - .compat_ioctl = pmcraid_chr_ioctl, 3978 - #endif 3976 + .compat_ioctl = compat_ptr_ioctl, 3979 3977 .llseek = noop_llseek, 3980 3978 }; 3981 3979
+1 -3
drivers/staging/android/ion/ion.c
··· 533 533 static const struct file_operations ion_fops = { 534 534 .owner = THIS_MODULE, 535 535 .unlocked_ioctl = ion_ioctl, 536 - #ifdef CONFIG_COMPAT 537 - .compat_ioctl = ion_ioctl, 538 - #endif 536 + .compat_ioctl = compat_ptr_ioctl, 539 537 }; 540 538 541 539 static int debug_shrink_set(void *data, u64 val)
+1 -1
drivers/staging/vme/devices/vme_user.c
··· 494 494 .write = vme_user_write, 495 495 .llseek = vme_user_llseek, 496 496 .unlocked_ioctl = vme_user_unlocked_ioctl, 497 - .compat_ioctl = vme_user_unlocked_ioctl, 497 + .compat_ioctl = compat_ptr_ioctl, 498 498 .mmap = vme_user_mmap, 499 499 }; 500 500
+1 -1
drivers/tee/tee_core.c
··· 675 675 .open = tee_open, 676 676 .release = tee_release, 677 677 .unlocked_ioctl = tee_ioctl, 678 - .compat_ioctl = tee_ioctl, 678 + .compat_ioctl = compat_ptr_ioctl, 679 679 }; 680 680 681 681 static void tee_release_device(struct device *dev)
+1 -1
drivers/usb/class/cdc-wdm.c
··· 734 734 .release = wdm_release, 735 735 .poll = wdm_poll, 736 736 .unlocked_ioctl = wdm_ioctl, 737 - .compat_ioctl = wdm_ioctl, 737 + .compat_ioctl = compat_ptr_ioctl, 738 738 .llseek = noop_llseek, 739 739 }; 740 740
+1 -3
drivers/usb/class/usbtmc.c
··· 2217 2217 .release = usbtmc_release, 2218 2218 .flush = usbtmc_flush, 2219 2219 .unlocked_ioctl = usbtmc_ioctl, 2220 - #ifdef CONFIG_COMPAT 2221 - .compat_ioctl = usbtmc_ioctl, 2222 - #endif 2220 + .compat_ioctl = compat_ptr_ioctl, 2223 2221 .fasync = usbtmc_fasync, 2224 2222 .poll = usbtmc_poll, 2225 2223 .llseek = default_llseek,
+1 -1
drivers/virt/fsl_hypervisor.c
··· 706 706 .poll = fsl_hv_poll, 707 707 .read = fsl_hv_read, 708 708 .unlocked_ioctl = fsl_hv_ioctl, 709 - .compat_ioctl = fsl_hv_ioctl, 709 + .compat_ioctl = compat_ptr_ioctl, 710 710 }; 711 711 712 712 static struct miscdevice fsl_hv_misc_dev = {
+1 -1
fs/btrfs/super.c
··· 2297 2297 static const struct file_operations btrfs_ctl_fops = { 2298 2298 .open = btrfs_control_open, 2299 2299 .unlocked_ioctl = btrfs_control_ioctl, 2300 - .compat_ioctl = btrfs_control_ioctl, 2300 + .compat_ioctl = compat_ptr_ioctl, 2301 2301 .owner = THIS_MODULE, 2302 2302 .llseek = noop_llseek, 2303 2303 };
+1 -1
fs/fuse/dev.c
··· 2260 2260 .release = fuse_dev_release, 2261 2261 .fasync = fuse_dev_fasync, 2262 2262 .unlocked_ioctl = fuse_dev_ioctl, 2263 - .compat_ioctl = fuse_dev_ioctl, 2263 + .compat_ioctl = compat_ptr_ioctl, 2264 2264 }; 2265 2265 EXPORT_SYMBOL_GPL(fuse_dev_operations); 2266 2266
+1 -1
fs/notify/fanotify/fanotify_user.c
··· 523 523 .fasync = NULL, 524 524 .release = fanotify_release, 525 525 .unlocked_ioctl = fanotify_ioctl, 526 - .compat_ioctl = fanotify_ioctl, 526 + .compat_ioctl = compat_ptr_ioctl, 527 527 .llseek = noop_llseek, 528 528 }; 529 529
+1 -1
fs/userfaultfd.c
··· 1923 1923 .poll = userfaultfd_poll, 1924 1924 .read = userfaultfd_read, 1925 1925 .unlocked_ioctl = userfaultfd_ioctl, 1926 - .compat_ioctl = userfaultfd_ioctl, 1926 + .compat_ioctl = compat_ptr_ioctl, 1927 1927 .llseek = noop_llseek, 1928 1928 }; 1929 1929
+1 -1
net/rfkill/core.c
··· 1311 1311 .release = rfkill_fop_release, 1312 1312 #ifdef CONFIG_RFKILL_INPUT 1313 1313 .unlocked_ioctl = rfkill_fop_ioctl, 1314 - .compat_ioctl = rfkill_fop_ioctl, 1314 + .compat_ioctl = compat_ptr_ioctl, 1315 1315 #endif 1316 1316 .llseek = no_llseek, 1317 1317 };