why do we still keep __{get,put}_user_unaligned()?
Subsystems (5)
Al Viro
maintainer Right now we have no users of __get_user_unaligned() outside ofarch/* and only 4 users of __put_user_unaligned() outside of arch/*.
All 4 are in compat_sys_getdents64(). For storing
->d_ino and ->d_off in
struct linux_dirent64 {
u64 d_ino;
s64 d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[0];
};in case 32bit userland has weaker alignment requirements for that thing and passes us a pointer that would've been aligned for 32bit, but not for 64bit ABI. Which architecture would that be, though?
arm, mips, powerpc, sparc and s390 have that thing 64bit-aligned
in 32bit ABI (both of them in case of mips). And since native getdents() does *not* maintain more than that when padding an entry, we'd better have put_user() of 64bit values work for any 64bit-aligned pointer. I hadn't checked actual cross-compile for tile, but judging by their compat.h they are not suffering from that kind of braindamage either.
x86 does, indeed, have weaker alignment in 32bit ABI. It also
has __put_user_unaligned defined as __put_user.
Is there any reason to keep those around? As it is, the only places
that need those are m68k and arm binfmt-flat, and these boil down to "can this CPU flavour do unaligned access?", with "use __get_user/__put_user" and "use __copy_from_user/__copy_to_user" as outcomes. Nothing more fancy...
Al Viro
maintainerPATCH 1/1 remove compat_sys_getdents64() (was Re: [RFC] why do we still keep __{get,put}_user_unaligned()?)
Quoted 23 lines · Al Viro
Right now we have no users of
__get_user_unaligned()outside ofarch/*and only 4 users of__put_user_unaligned()outside ofarch/*.All 4 are in
compat_sys_getdents64(). For storing
->d_ino and ->d_off instruct linux_dirent64 { u64 d_ino; s64 d_off; unsigned short d_reclen; unsigned char d_type; char d_name[0]; };in case 32bit userland has weaker alignment requirements for that thing and passes us a pointer that would've been aligned for 32bit, but not for 64bit ABI. Which architecture would that be, though?
arm, mips, powerpc, sparc and s390 have that thing 64bit-aligned
in 32bit ABI (both of them in case of mips). And since nativegetdents()does *not* maintain more than that when padding an entry, we'd better haveput_user()of 64bit values work for any 64bit-aligned pointer. I hadn't checked actual cross-compile for tile, but judging by theircompat.hthey are not suffering from that kind of braindamage either.
Quoted 7 lines
x86 does, indeed, have weaker alignment in 32bit ABI. It also
has__put_user_unaligneddefined as__put_user.Is there any reason to keep those around? As it is, the only places
that need those are m68k and arm binfmt-flat, and these boil down to "can this CPU flavour do unaligned access?", with "use __get_user/__put_user" and "use __copy_from_user/__copy_to_user" as outcomes. Nothing more fancy...
Looking at the pre-2.6.12 history, it's even more ridiculous.compat_sys_getdents64() had been introduced for (and only ever needed by) biarch support on itanic. arm64 use of that thing is, AFAICS, not needed at all and appeared when arm biarch support went in; looks like an oversight when putting together a list of syscalls ("compat variant is there, probably ought to use it for some reason", at a guess).
Use in include/asm-generic/unistd.h appears to be a similar mistake
by tile folks. amd64 one is definitely an accident - "[PATCH] x86_64: Use compat readdir and aio functions" had converted old_readdir, getdents, io_getevents and io_submit from amd64-specific wrappers to generic compat variants and switched getdents64 to compat wrapper at the same time - from native sys_getdents64. Might've assumed that the lack of wrapper for that one had been a bug...
Let's at least remove compat_sys_getdents64()... Linus, do you
have any problems with the following?
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.
arch/arm64/include/asm/unistd.h +0 -1
@@ -14,7 +14,6 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef CONFIG_COMPAT -#define __ARCH_WANT_COMPAT_SYS_GETDENTS64#define __ARCH_WANT_COMPAT_STAT64#define __ARCH_WANT_SYS_GETHOSTNAME#define __ARCH_WANT_SYS_PAUSE
arch/arm64/include/asm/unistd32.h +1 -1
@@ -456,7 +456,7 @@ __SYSCALL(__NR_setfsuid32, sys_setfsuid)#define __NR_setfsgid32 216 __SYSCALL(__NR_setfsgid32, sys_setfsgid)#define __NR_getdents64 217 -__SYSCALL(__NR_getdents64, compat_sys_getdents64) +__SYSCALL(__NR_getdents64, sys_getdents64)#define __NR_pivot_root 218 __SYSCALL(__NR_pivot_root, sys_pivot_root)#define __NR_mincore 219
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
@@ -226,7 +226,7 @@ 217 i386 pivot_root sys_pivot_root 218 i386 mincore sys_mincore 219 i386 madvise sys_madvise -220 i386 getdents64 sys_getdents64 compat_sys_getdents64 +220 i386 getdents64 sys_getdents64 221 i386 fcntl64 sys_fcntl64 compat_sys_fcntl64 # 222 is unused # 223 is unused
arch/x86/include/asm/unistd.h +0 -1
@@ -23,7 +23,6 @@# include <asm/unistd_64.h> # include <asm/unistd_64_x32.h> # define __ARCH_WANT_COMPAT_SYS_TIME -# define __ARCH_WANT_COMPAT_SYS_GETDENTS64# define __ARCH_WANT_COMPAT_SYS_PREADV64# define __ARCH_WANT_COMPAT_SYS_PWRITEV64# define __ARCH_WANT_COMPAT_SYS_PREADV64V2
fs/compat.c +0 -91
97 lines not on this page · raw message
include/linux/compat.h +0 -5
@@ -528,11 +528,6 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,asmlinkage long compat_sys_getdents (unsigned int fd,struct compat_linux_dirent __user *dirent,unsigned int count); -#ifdef __ARCH_WANT_COMPAT_SYS_GETDENTS64 -asmlinkage long compat_sys_getdents64 (unsigned int fd, -struct linux_dirent64 __user *dirent, -unsigned int count); -#endif asmlinkage long compat_sys_vmsplice (int fd,const struct compat_iovec __user *,unsigned int nr_segs,unsigned int flags); asmlinkage long compat_sys_open(const char __user *filename, int flags,
include/uapi/asm-generic/unistd.h +1 -2
@@ -194,8 +194,7 @@ __SYSCALL(__NR_quotactl, sys_quotactl)/* fs/readdir.c */ #define __NR_getdents64 61 -#define __ARCH_WANT_COMPAT_SYS_GETDENTS64 -__SC_COMP (__NR_getdents64, sys_getdents64, compat_sys_getdents64) +__SYSCALL (__NR_getdents64, sys_getdents64) /* fs/read_write.c */#define __NR3264_lseek 62
Re: [PATCH] remove compat_sys_getdents64() (was Re: [RFC] why do we still keep __{get,put}_user_unaligned()?)
Quoted 3 lines · Al Viro
Let's at least remove
compat_sys_getdents64()... Linus, do you
have any problems with the following?
Hmm. Trying to compare compat_sys_getdents64n and sys_getdents64 side by side, I think you're right. The patch looks sane.
Linus