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

Remove compat_sys_getdents64()

Unlike normal compat syscall variants, it is needed only for
biarch architectures that have different alignement requirements for
u64 in 32bit and 64bit ABI *and* have __put_user() that won't handle
a store of 64bit value at 32bit-aligned address. We used to have one
such (ia64), but its biarch support has been gone since 2010 (after
being broken in 2008, which went unnoticed since nobody had been using
it).

It had escaped removal at the same time only because back in 2004
a patch that switched several syscalls on amd64 from private wrappers to
generic compat ones had switched to use of compat_sys_getdents64(), which
hadn't needed (or used) a compat wrapper on amd64.

Let's bury it - it's at least 7 years overdue.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 2611dc19 a71c9a1c

+3 -102
-1
arch/arm64/include/asm/unistd.h
··· 14 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 15 */ 16 16 #ifdef CONFIG_COMPAT 17 - #define __ARCH_WANT_COMPAT_SYS_GETDENTS64 18 17 #define __ARCH_WANT_COMPAT_STAT64 19 18 #define __ARCH_WANT_SYS_GETHOSTNAME 20 19 #define __ARCH_WANT_SYS_PAUSE
+1 -1
arch/arm64/include/asm/unistd32.h
··· 456 456 #define __NR_setfsgid32 216 457 457 __SYSCALL(__NR_setfsgid32, sys_setfsgid) 458 458 #define __NR_getdents64 217 459 - __SYSCALL(__NR_getdents64, compat_sys_getdents64) 459 + __SYSCALL(__NR_getdents64, sys_getdents64) 460 460 #define __NR_pivot_root 218 461 461 __SYSCALL(__NR_pivot_root, sys_pivot_root) 462 462 #define __NR_mincore 219
+1 -1
arch/x86/entry/syscalls/syscall_32.tbl
··· 226 226 217 i386 pivot_root sys_pivot_root 227 227 218 i386 mincore sys_mincore 228 228 219 i386 madvise sys_madvise 229 - 220 i386 getdents64 sys_getdents64 compat_sys_getdents64 229 + 220 i386 getdents64 sys_getdents64 230 230 221 i386 fcntl64 sys_fcntl64 compat_sys_fcntl64 231 231 # 222 is unused 232 232 # 223 is unused
-1
arch/x86/include/asm/unistd.h
··· 23 23 # include <asm/unistd_64.h> 24 24 # include <asm/unistd_64_x32.h> 25 25 # define __ARCH_WANT_COMPAT_SYS_TIME 26 - # define __ARCH_WANT_COMPAT_SYS_GETDENTS64 27 26 # define __ARCH_WANT_COMPAT_SYS_PREADV64 28 27 # define __ARCH_WANT_COMPAT_SYS_PWRITEV64 29 28 # define __ARCH_WANT_COMPAT_SYS_PREADV64V2
-91
fs/compat.c
··· 907 907 return error; 908 908 } 909 909 910 - #ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64 911 - 912 - struct compat_getdents_callback64 { 913 - struct dir_context ctx; 914 - struct linux_dirent64 __user *current_dir; 915 - struct linux_dirent64 __user *previous; 916 - int count; 917 - int error; 918 - }; 919 - 920 - static int compat_filldir64(struct dir_context *ctx, const char *name, 921 - int namlen, loff_t offset, u64 ino, 922 - unsigned int d_type) 923 - { 924 - struct linux_dirent64 __user *dirent; 925 - struct compat_getdents_callback64 *buf = 926 - container_of(ctx, struct compat_getdents_callback64, ctx); 927 - int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1, 928 - sizeof(u64)); 929 - u64 off; 930 - 931 - buf->error = -EINVAL; /* only used if we fail.. */ 932 - if (reclen > buf->count) 933 - return -EINVAL; 934 - dirent = buf->previous; 935 - 936 - if (dirent) { 937 - if (signal_pending(current)) 938 - return -EINTR; 939 - if (__put_user_unaligned(offset, &dirent->d_off)) 940 - goto efault; 941 - } 942 - dirent = buf->current_dir; 943 - if (__put_user_unaligned(ino, &dirent->d_ino)) 944 - goto efault; 945 - off = 0; 946 - if (__put_user_unaligned(off, &dirent->d_off)) 947 - goto efault; 948 - if (__put_user(reclen, &dirent->d_reclen)) 949 - goto efault; 950 - if (__put_user(d_type, &dirent->d_type)) 951 - goto efault; 952 - if (copy_to_user(dirent->d_name, name, namlen)) 953 - goto efault; 954 - if (__put_user(0, dirent->d_name + namlen)) 955 - goto efault; 956 - buf->previous = dirent; 957 - dirent = (void __user *)dirent + reclen; 958 - buf->current_dir = dirent; 959 - buf->count -= reclen; 960 - return 0; 961 - efault: 962 - buf->error = -EFAULT; 963 - return -EFAULT; 964 - } 965 - 966 - COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd, 967 - struct linux_dirent64 __user *, dirent, unsigned int, count) 968 - { 969 - struct fd f; 970 - struct linux_dirent64 __user * lastdirent; 971 - struct compat_getdents_callback64 buf = { 972 - .ctx.actor = compat_filldir64, 973 - .current_dir = dirent, 974 - .count = count 975 - }; 976 - int error; 977 - 978 - if (!access_ok(VERIFY_WRITE, dirent, count)) 979 - return -EFAULT; 980 - 981 - f = fdget_pos(fd); 982 - if (!f.file) 983 - return -EBADF; 984 - 985 - error = iterate_dir(f.file, &buf.ctx); 986 - if (error >= 0) 987 - error = buf.error; 988 - lastdirent = buf.previous; 989 - if (lastdirent) { 990 - typeof(lastdirent->d_off) d_off = buf.ctx.pos; 991 - if (__put_user_unaligned(d_off, &lastdirent->d_off)) 992 - error = -EFAULT; 993 - else 994 - error = count - buf.count; 995 - } 996 - fdput_pos(f); 997 - return error; 998 - } 999 - #endif /* __ARCH_WANT_COMPAT_SYS_GETDENTS64 */ 1000 - 1001 910 /* 1002 911 * Exactly like fs/open.c:sys_open(), except that it doesn't set the 1003 912 * O_LARGEFILE flag.
-5
include/linux/compat.h
··· 528 528 asmlinkage long compat_sys_getdents(unsigned int fd, 529 529 struct compat_linux_dirent __user *dirent, 530 530 unsigned int count); 531 - #ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64 532 - asmlinkage long compat_sys_getdents64(unsigned int fd, 533 - struct linux_dirent64 __user *dirent, 534 - unsigned int count); 535 - #endif 536 531 asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *, 537 532 unsigned int nr_segs, unsigned int flags); 538 533 asmlinkage long compat_sys_open(const char __user *filename, int flags,
+1 -2
include/uapi/asm-generic/unistd.h
··· 194 194 195 195 /* fs/readdir.c */ 196 196 #define __NR_getdents64 61 197 - #define __ARCH_WANT_COMPAT_SYS_GETDENTS64 198 - __SC_COMP(__NR_getdents64, sys_getdents64, compat_sys_getdents64) 197 + __SYSCALL(__NR_getdents64, sys_getdents64) 199 198 200 199 /* fs/read_write.c */ 201 200 #define __NR3264_lseek 62