Skip to content

Commit 1832f2d

Browse files
committed
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>
1 parent 407e9ef commit 1832f2d

33 files changed

Lines changed: 36 additions & 52 deletions

File tree

‎drivers/android/binder.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6063,7 +6063,7 @@ const struct file_operations binder_fops = {
60636063
.owner = THIS_MODULE,
60646064
.poll = binder_poll,
60656065
.unlocked_ioctl = binder_ioctl,
6066-
.compat_ioctl = binder_ioctl,
6066+
.compat_ioctl = compat_ptr_ioctl,
60676067
.mmap = binder_mmap,
60686068
.open = binder_open,
60696069
.flush = binder_flush,

‎drivers/crypto/qat/qat_common/adf_ctl_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static long adf_ctl_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
6868
static const struct file_operations adf_ctl_ops = {
6969
.owner = THIS_MODULE,
7070
.unlocked_ioctl = adf_ctl_ioctl,
71-
.compat_ioctl = adf_ctl_ioctl,
71+
.compat_ioctl = compat_ptr_ioctl,
7272
};
7373

7474
struct adf_ctl_drv_info {

‎drivers/dma-buf/dma-buf.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,7 @@ static const struct file_operations dma_buf_fops = {
415415
.llseek = dma_buf_llseek,
416416
.poll = dma_buf_poll,
417417
.unlocked_ioctl = dma_buf_ioctl,
418-
#ifdef CONFIG_COMPAT
419-
.compat_ioctl = dma_buf_ioctl,
420-
#endif
418+
.compat_ioctl = compat_ptr_ioctl,
421419
.show_fdinfo = dma_buf_show_fdinfo,
422420
};
423421

‎drivers/dma-buf/sw_sync.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,5 +408,5 @@ const struct file_operations sw_sync_debugfs_fops = {
408408
.open = sw_sync_debugfs_open,
409409
.release = sw_sync_debugfs_release,
410410
.unlocked_ioctl = sw_sync_ioctl,
411-
.compat_ioctl = sw_sync_ioctl,
411+
.compat_ioctl = compat_ptr_ioctl,
412412
};

‎drivers/dma-buf/sync_file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,5 +480,5 @@ static const struct file_operations sync_file_fops = {
480480
.release = sync_file_release,
481481
.poll = sync_file_poll,
482482
.unlocked_ioctl = sync_file_ioctl,
483-
.compat_ioctl = sync_file_ioctl,
483+
.compat_ioctl = compat_ptr_ioctl,
484484
};

‎drivers/gpu/drm/amd/amdkfd/kfd_chardev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static const char kfd_dev_name[] = "kfd";
4949
static const struct file_operations kfd_fops = {
5050
.owner = THIS_MODULE,
5151
.unlocked_ioctl = kfd_ioctl,
52-
.compat_ioctl = kfd_ioctl,
52+
.compat_ioctl = compat_ptr_ioctl,
5353
.open = kfd_open,
5454
.mmap = kfd_mmap,
5555
};

‎drivers/hid/hidraw.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,7 @@ static const struct file_operations hidraw_ops = {
468468
.release = hidraw_release,
469469
.unlocked_ioctl = hidraw_ioctl,
470470
.fasync = hidraw_fasync,
471-
#ifdef CONFIG_COMPAT
472-
.compat_ioctl = hidraw_ioctl,
473-
#endif
471+
.compat_ioctl = compat_ptr_ioctl,
474472
.llseek = noop_llseek,
475473
};
476474

‎drivers/iio/industrialio-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ static const struct file_operations iio_buffer_fileops = {
16101610
.owner = THIS_MODULE,
16111611
.llseek = noop_llseek,
16121612
.unlocked_ioctl = iio_ioctl,
1613-
.compat_ioctl = iio_ioctl,
1613+
.compat_ioctl = compat_ptr_ioctl,
16141614
};
16151615

16161616
static int iio_check_unique_scan_index(struct iio_dev *indio_dev)

‎drivers/infiniband/core/uverbs_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ static const struct file_operations uverbs_fops = {
11391139
.release = ib_uverbs_close,
11401140
.llseek = no_llseek,
11411141
.unlocked_ioctl = ib_uverbs_ioctl,
1142-
.compat_ioctl = ib_uverbs_ioctl,
1142+
.compat_ioctl = compat_ptr_ioctl,
11431143
};
11441144

11451145
static const struct file_operations uverbs_mmap_fops = {
@@ -1150,7 +1150,7 @@ static const struct file_operations uverbs_mmap_fops = {
11501150
.release = ib_uverbs_close,
11511151
.llseek = no_llseek,
11521152
.unlocked_ioctl = ib_uverbs_ioctl,
1153-
.compat_ioctl = ib_uverbs_ioctl,
1153+
.compat_ioctl = compat_ptr_ioctl,
11541154
};
11551155

11561156
static int ib_uverbs_get_nl_info(struct ib_device *ibdev, void *client_data,

‎drivers/media/rc/lirc_dev.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,7 @@ static const struct file_operations lirc_fops = {
720720
.owner = THIS_MODULE,
721721
.write = ir_lirc_transmit_ir,
722722
.unlocked_ioctl = ir_lirc_ioctl,
723-
#ifdef CONFIG_COMPAT
724-
.compat_ioctl = ir_lirc_ioctl,
725-
#endif
723+
.compat_ioctl = compat_ptr_ioctl,
726724
.read = ir_lirc_read,
727725
.poll = ir_lirc_poll,
728726
.open = ir_lirc_open,

0 commit comments

Comments
 (0)