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

compat_ioctl: use correct compat_ptr() translation in drivers

A handful of drivers all have a trivial wrapper around their ioctl
handler, but don't call the compat_ptr() conversion function at the
moment. In practice this does not matter, since none of them are used
on the s390 architecture and for all other architectures, compat_ptr()
does not do anything, but using the new compat_ptr_ioctl()
helper makes it more correct in theory, and simplifies the code.

I checked that all ioctl handlers in these files are compatible
and take either pointer arguments or no argument.

Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+4 -67
+1 -7
drivers/misc/cxl/flash.c
··· 473 473 return -EINVAL; 474 474 } 475 475 476 - static long device_compat_ioctl(struct file *file, unsigned int cmd, 477 - unsigned long arg) 478 - { 479 - return device_ioctl(file, cmd, arg); 480 - } 481 - 482 476 static int device_close(struct inode *inode, struct file *file) 483 477 { 484 478 struct cxl *adapter = file->private_data; ··· 508 514 .owner = THIS_MODULE, 509 515 .open = device_open, 510 516 .unlocked_ioctl = device_ioctl, 511 - .compat_ioctl = device_compat_ioctl, 517 + .compat_ioctl = compat_ptr_ioctl, 512 518 .release = device_close, 513 519 }; 514 520
+1 -22
drivers/misc/genwqe/card_dev.c
··· 1215 1215 return rc; 1216 1216 } 1217 1217 1218 - #if defined(CONFIG_COMPAT) 1219 - /** 1220 - * genwqe_compat_ioctl() - Compatibility ioctl 1221 - * 1222 - * Called whenever a 32-bit process running under a 64-bit kernel 1223 - * performs an ioctl on /dev/genwqe<n>_card. 1224 - * 1225 - * @filp: file pointer. 1226 - * @cmd: command. 1227 - * @arg: user argument. 1228 - * Return: zero on success or negative number on failure. 1229 - */ 1230 - static long genwqe_compat_ioctl(struct file *filp, unsigned int cmd, 1231 - unsigned long arg) 1232 - { 1233 - return genwqe_ioctl(filp, cmd, arg); 1234 - } 1235 - #endif /* defined(CONFIG_COMPAT) */ 1236 - 1237 1218 static const struct file_operations genwqe_fops = { 1238 1219 .owner = THIS_MODULE, 1239 1220 .open = genwqe_open, 1240 1221 .fasync = genwqe_fasync, 1241 1222 .mmap = genwqe_mmap, 1242 1223 .unlocked_ioctl = genwqe_ioctl, 1243 - #if defined(CONFIG_COMPAT) 1244 - .compat_ioctl = genwqe_compat_ioctl, 1245 - #endif 1224 + .compat_ioctl = compat_ptr_ioctl, 1246 1225 .release = genwqe_release, 1247 1226 }; 1248 1227
+1 -27
drivers/scsi/megaraid/megaraid_mm.c
··· 41 41 static void mraid_mm_free_adp_resources(mraid_mmadp_t *); 42 42 static void mraid_mm_teardown_dma_pools(mraid_mmadp_t *); 43 43 44 - #ifdef CONFIG_COMPAT 45 - static long mraid_mm_compat_ioctl(struct file *, unsigned int, unsigned long); 46 - #endif 47 - 48 44 MODULE_AUTHOR("LSI Logic Corporation"); 49 45 MODULE_DESCRIPTION("LSI Logic Management Module"); 50 46 MODULE_LICENSE("GPL"); ··· 64 68 static const struct file_operations lsi_fops = { 65 69 .open = mraid_mm_open, 66 70 .unlocked_ioctl = mraid_mm_unlocked_ioctl, 67 - #ifdef CONFIG_COMPAT 68 - .compat_ioctl = mraid_mm_compat_ioctl, 69 - #endif 71 + .compat_ioctl = compat_ptr_ioctl, 70 72 .owner = THIS_MODULE, 71 73 .llseek = noop_llseek, 72 74 }; ··· 218 224 { 219 225 int err; 220 226 221 - /* inconsistent: mraid_mm_compat_ioctl doesn't take the BKL */ 222 227 mutex_lock(&mraid_mm_mutex); 223 228 err = mraid_mm_ioctl(filep, cmd, arg); 224 229 mutex_unlock(&mraid_mm_mutex); ··· 1220 1227 return 0; 1221 1228 } 1222 1229 1223 - 1224 - #ifdef CONFIG_COMPAT 1225 - /** 1226 - * mraid_mm_compat_ioctl - 32bit to 64bit ioctl conversion routine 1227 - * @filep : file operations pointer (ignored) 1228 - * @cmd : ioctl command 1229 - * @arg : user ioctl packet 1230 - */ 1231 - static long 1232 - mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd, 1233 - unsigned long arg) 1234 - { 1235 - int err; 1236 - 1237 - err = mraid_mm_ioctl(filep, cmd, arg); 1238 - 1239 - return err; 1240 - } 1241 - #endif 1242 1230 1243 1231 /** 1244 1232 * mraid_mm_exit - Module exit point
+1 -11
drivers/usb/gadget/function/f_fs.c
··· 1352 1352 return ret; 1353 1353 } 1354 1354 1355 - #ifdef CONFIG_COMPAT 1356 - static long ffs_epfile_compat_ioctl(struct file *file, unsigned code, 1357 - unsigned long value) 1358 - { 1359 - return ffs_epfile_ioctl(file, code, value); 1360 - } 1361 - #endif 1362 - 1363 1355 static const struct file_operations ffs_epfile_operations = { 1364 1356 .llseek = no_llseek, 1365 1357 ··· 1360 1368 .read_iter = ffs_epfile_read_iter, 1361 1369 .release = ffs_epfile_release, 1362 1370 .unlocked_ioctl = ffs_epfile_ioctl, 1363 - #ifdef CONFIG_COMPAT 1364 - .compat_ioctl = ffs_epfile_compat_ioctl, 1365 - #endif 1371 + .compat_ioctl = compat_ptr_ioctl, 1366 1372 }; 1367 1373 1368 1374