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

Configure Feed

Select the types of activity you want to include in your feed.

compat_sys_ioctl(): make parallel to do_vfs_ioctl()

Handle ioctls that might be handled without reaching ->ioctl() in
native case on the top level there. The counterpart of vfs_ioctl()
(i.e. calling ->unlock_ioctl(), etc.) left as-is; eventually
that would turn simply into the call of ->compat_ioctl(), but
that'll take more work. Once that is done, we can move the
remains of compat_sys_ioctl() into fs/ioctl.c and finally bury
fs/compat_ioctl.c.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Al Viro and committed by
Arnd Bergmann
37ecf8b2 011da44b

+28 -37
+28 -37
fs/compat_ioctl.c
··· 487 487 /* compatible ioctls first */ 488 488 /* Little t */ 489 489 COMPATIBLE_IOCTL(TIOCOUTQ) 490 - /* Little f */ 491 - COMPATIBLE_IOCTL(FIOCLEX) 492 - COMPATIBLE_IOCTL(FIONCLEX) 493 - COMPATIBLE_IOCTL(FIOASYNC) 494 - COMPATIBLE_IOCTL(FIONBIO) 495 - COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */ 496 - COMPATIBLE_IOCTL(FS_IOC_FIEMAP) 497 - /* 0x00 */ 498 - COMPATIBLE_IOCTL(FIBMAP) 499 - COMPATIBLE_IOCTL(FIGETBSZ) 500 490 /* 'X' - originally XFS but some now in the VFS */ 501 - COMPATIBLE_IOCTL(FIFREEZE) 502 - COMPATIBLE_IOCTL(FITHAW) 503 491 COMPATIBLE_IOCTL(FITRIM) 504 492 #ifdef CONFIG_BLOCK 505 493 /* Big S */ ··· 528 540 COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */ 529 541 /* Little m */ 530 542 COMPATIBLE_IOCTL(MTIOCTOP) 531 - /* Socket level stuff */ 532 - COMPATIBLE_IOCTL(FIOQSIZE) 533 543 #ifdef CONFIG_BLOCK 534 544 /* md calls this on random blockdevs */ 535 545 IGNORE_IOCTL(RAID_VERSION) ··· 957 971 if (error) 958 972 goto out_fput; 959 973 960 - /* 961 - * To allow the compat_ioctl handlers to be self contained 962 - * we need to check the common ioctls here first. 963 - * Just handle them with the standard handlers below. 964 - */ 965 974 switch (cmd) { 975 + /* these are never seen by ->ioctl(), no argument or int argument */ 966 976 case FIOCLEX: 967 977 case FIONCLEX: 978 + case FIFREEZE: 979 + case FITHAW: 980 + case FICLONE: 981 + goto do_ioctl; 982 + /* these are never seen by ->ioctl(), pointer argument */ 968 983 case FIONBIO: 969 984 case FIOASYNC: 970 985 case FIOQSIZE: 971 - break; 972 - 986 + case FS_IOC_FIEMAP: 987 + case FIGETBSZ: 988 + case FICLONERANGE: 989 + case FIDEDUPERANGE: 990 + goto found_handler; 991 + /* 992 + * The next group is the stuff handled inside file_ioctl(). 993 + * For regular files these never reach ->ioctl(); for 994 + * devices, sockets, etc. they do and one (FIONREAD) is 995 + * even accepted in some cases. In all those cases 996 + * argument has the same type, so we can handle these 997 + * here, shunting them towards do_vfs_ioctl(). 998 + * ->compat_ioctl() will never see any of those. 999 + */ 1000 + /* pointer argument, never actually handled by ->ioctl() */ 1001 + case FIBMAP: 1002 + goto found_handler; 1003 + /* handled by some ->ioctl(); always a pointer to int */ 1004 + case FIONREAD: 1005 + goto found_handler; 1006 + /* these two get messy on amd64 due to alignment differences */ 973 1007 #if defined(CONFIG_X86_64) 974 1008 case FS_IOC_RESVSP_32: 975 1009 case FS_IOC_RESVSP64_32: ··· 998 992 #else 999 993 case FS_IOC_RESVSP: 1000 994 case FS_IOC_RESVSP64: 1001 - error = ioctl_preallocate(f.file, compat_ptr(arg)); 1002 - goto out_fput; 1003 - #endif 1004 - 1005 - case FICLONE: 1006 - goto do_ioctl; 1007 - case FICLONERANGE: 1008 - case FIDEDUPERANGE: 1009 - case FS_IOC_FIEMAP: 1010 - case FIGETBSZ: 1011 995 goto found_handler; 1012 - 1013 - case FIBMAP: 1014 - case FIONREAD: 1015 - if (S_ISREG(file_inode(f.file)->i_mode)) 1016 - break; 1017 - /*FALL THROUGH*/ 996 + #endif 1018 997 1019 998 default: 1020 999 if (f.file->f_op->compat_ioctl) {