remove in-kernel syscall invocations (part 3 == remainder outside arch/)
Subsystems (28)
cover remove in-kernel syscall invocations (part 3 == remainder outside arch/)
Here is a third series of patches which reduce the number of syscall invocations from within the kernel. Once this long-term goal is achieved, the syscall entry path can be streamlined.
This series builds on top of
- part1 (random bits and pieces)
http://lkml.kernel.org/r/[email protected]
- part2 (net)
http://lkml.kernel.org/r/[email protected]
and replaces the RFC of a subset of this series. Most of the patches are just "mindless" conversions and helpers. If wrappers or helpers are limited to one subsystem, I have named them do_*(), kern_*() or __sys_*(), depending on what was used by the subsystem and/or what was still available. Otherwise, I have used ksys_*() to reflect that this is meant as a drop-in replacement for sys_*() within the kernel.
With this third series, *all* in-kernel callers of sys_*() and compat_sys_*() outside of arch/ are converted.[*] On top of this, three things may be attempted now:
- ptregs system call conversion for x86-64.
- re-work initramfs etc. code to not use in-kernel equivalents of syscalls, but operate on the VFS level instead.
- re-work SYSCALL_DEFINEx() / COMPAT_SYSCALL_DEFINEx() to do the right thing depending on arch-specific requirements on padding, long long handling, etc. (Al Viro).
Also thrown in are a patch by Michael Tautschnig to use proper SYSCALL_DEFINE0() macros on x86 and a patch by Howard McLauchlan to whitelist all syscalls for error injection.
The whole series, including part 1 and part 2, can be found at
https://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux.git syscalls-next
Thanks,
Dominik
[*] Within arch, only x86 is fully covered by these series.
Dominik Brodowski (43):
fs: add ksys_getdents64() helper; remove in-kernel calls to
sys_getdents64()
fs: add ksys_ioctl() helper; remove in-kernel calls to sys_ioctl()
fs: add ksys_lseek() helper; remove in-kernel calls to sys_lseek()
fs: add ksys_read() helper; remove in-kernel calls to sys_read()
fs: add ksys_sync() helper; remove in-kernel calls to sys_sync()
fs: add do_lookup_dcookie() helper; remove in-kernel call to syscall
fs: add do_vmsplice() helper; remove in-kernel call to syscall
fs: add kern_select() helper; remove in-kernel call to sys_select()
fs: add ksys_truncate() wrapper; remove in-kernel calls to
sys_truncate()
fs: add ksys_p{read,write}64() helpers; remove in-kernel calls to
syscalls
fs: add ksys_fallocate() wrapper; remove in-kernel calls to
sys_fallocate()
fs: add do_compat_fcntl64() helper; remove in-kernel call to comapt
syscall
fs: add do_compat_select() helper; remove in-kernel call to comapt
syscall
fs: add do_compat_signalfd4() helper; remove in-kernel call to comapt
syscall
fs: add do_compat_futimesat() helper; remove in-kernel call to comapt
syscall
inotify: add do_inotify_init() helper; remove in-kernel call to
syscall
fanotify: add do_fanotify_mark() helper; remove in-kernel call to
syscall
fs/quota: add kernel_quotactl() helper; remove in-kernel call to
syscall
fs/quota: use COMPAT_SYSCALL_DEFINE for sys32_quotactl()
kernel: add do_compat_sigaltstack() helper; remove in-kernel call to
compat syscall
kernel: add ksys_setsid() helper; remove in-kernel call to
sys_setsid()
kernel: provide ksys_*() wrappers for syscalls called by
kernel/uid16.c sched: add do_sched_yield() helper; remove in-kernel call to
sched_yield()
kexec: call do_kexec_load() in compat syscall directly
mm: add kernel_migrate_pages() helper, move compat syscall to
mm/mempolicy.c
mm: add kernel_move_pages() helper, move compat syscall to
mm/migrate.c
mm: add kernel_mbind() helper; remove in-kernel call to syscall
mm: add kernel_[sg]et_mempolicy() helpers; remove in-kernel calls to
syscalls
mm: add ksys_readahead() helper; remove in-kernel calls to
sys_readahead()
ipc: add semtimedop syscall/compat_syscall wrappers
ipc: add semget syscall wrapper
ipc: add semctl syscall/compat_syscall wrappers
ipc: add msgget syscall wrapper
ipc: add shmget syscall wrapper
ipc: add shmdt syscall wrapper
ipc: add shmctl syscall/compat_syscall wrappers
ipc: add msgctl syscall/compat_syscall wrappers
ipc: add msgrcv syscall/compat_syscall wrappers
ipc: add msgsnd syscall/compat_syscall wrappers
x86: use _do_fork() in compat_sys_x86_clone()
x86: remove compat_sys_x86_waitpid()
x86: fix sys_sigreturn() return type to be long, not unsigned long kernel/sys_ni: sort cond_syscall() entries
Howard McLauchlan (1):
bpf: whitelist all syscalls for error injection
Tautschnig, Michael (1):
x86/sigreturn: use SYSCALL_DEFINE0
arch/mips/kernel/linux32.c | 12 +- arch/parisc/kernel/sys_parisc.c | 16 +- arch/powerpc/kernel/sys_ppc32.c | 10 +- arch/s390/kernel/compat_linux.c | 14 +- arch/sh/kernel/sys_sh32.c | 4 +- arch/sparc/kernel/setup_32.c | 2 +- arch/sparc/kernel/sys_sparc32.c | 12 +- arch/x86/entry/syscalls/syscall_32.tbl | 4 +- arch/x86/ia32/sys_ia32.c | 26 +- arch/x86/include/asm/sys_ia32.h | 3 - arch/x86/include/asm/syscalls.h | 2 +- arch/x86/kernel/signal.c | 5 +- drivers/tty/sysrq.c | 2 +- fs/dcookies.c | 11 +- fs/fcntl.c | 12 +- fs/ioctl.c | 7 +- fs/notify/fanotify/fanotify_user.c | 14 +- fs/notify/inotify/inotify_user.c | 9 +- fs/open.c | 9 +- fs/quota/compat.c | 13 +- fs/quota/quota.c | 10 +- fs/read_write.c | 36 ++- fs/readdir.c | 11 +- fs/select.c | 29 +- fs/signalfd.c | 17 +- fs/splice.c | 12 +- fs/sync.c | 7 +- fs/utimes.c | 12 +- include/linux/compat.h | 6 + include/linux/quotaops.h | 3 + include/linux/syscalls.h | 27 +- init/do_mounts.c | 10 +- init/do_mounts_initrd.c | 4 +- init/do_mounts_md.c | 15 +- init/do_mounts_rd.c | 22 +- init/initramfs.c | 4 +- ipc/msg.c | 60 +++- ipc/sem.c | 44 ++- ipc/shm.c | 28 +- ipc/syscall.c | 58 ++-- ipc/util.h | 31 ++ kernel/compat.c | 55 ---- kernel/kexec.c | 50 +++- kernel/power/hibernate.c | 2 +- kernel/power/suspend.c | 2 +- kernel/power/user.c | 2 +- kernel/sched/core.c | 8 +- kernel/signal.c | 14 +- kernel/sys.c | 65 ++++- kernel/sys_ni.c | 506 +++++++++++++++++++++------------ kernel/uid16.c | 19 +- kernel/uid16.h | 14 + mm/mempolicy.c | 92 +++++- mm/migrate.c | 39 ++- mm/readahead.c | 7 +- 55 files changed, 1030 insertions(+), 478 deletions(-) create mode 100644 kernel/uid16.h
Signature · 1 line
2.16.2
PATCH 1/45 fs: add ksys_getdents64() helper; remove in-kernel calls to sys_getdents64()
Using this helper allows us to avoid the in-kernel calls to the sys_getdents64() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_getdents64().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/readdir.c | 11 +++++++++-- include/linux/syscalls.h | 2 ++ init/initramfs.c | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-)
fs/readdir.c +9 -2
@@ -292,8 +292,8 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,return -EFAULT ; } -SYSCALL_DEFINE3(getdents64, unsigned int, fd, - struct linux_dirent64 __user *, dirent, unsigned int, count) +int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent, +unsigned int count) {struct fd f;struct linux_dirent64 __user * lastdirent;
@@ -326,6 +326,13 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,return error; } + +SYSCALL_DEFINE3(getdents64, unsigned int, fd, + struct linux_dirent64 __user *, dirent, unsigned int, count) +{ +return ksys_getdents64 (fd, dirent, count); +} + #ifdef CONFIG_COMPAT struct compat_old_linux_dirent { compat_ulong_t d_ino;
include/linux/syscalls.h +2 -0
@@ -972,6 +972,8 @@ int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, unsigned int flags);int ksys_fchmod (unsigned int fd,umode_t mode);int ksys_fchown (unsigned int fd,uid_t user,gid_t group); +int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent, +unsigned int count);/* * The following kernel syscall equivalents are just wrappers to fs-internal
init/initramfs.c +2 -2
@@ -579,7 +579,7 @@ static void __init clean_rootfs(void) } dirp = buf; - num =sys_getdents64 (fd, dirp,BUF_SIZE ); + num =ksys_getdents64 (fd, dirp,BUF_SIZE );while (num >0 ) {while (num >0 ) {struct kstat st;
@@ -599,7 +599,7 @@ static void __init clean_rootfs(void) } dirp = buf;memset (buf,0 ,BUF_SIZE ); - num =sys_getdents64 (fd, dirp,BUF_SIZE ); + num =ksys_getdents64 (fd, dirp,BUF_SIZE ); }ksys_close (fd);
Signature · 1 line
2.16.2
PATCH 2/45 fs: add ksys_ioctl() helper; remove in-kernel calls to sys_ioctl()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel calls to the sys_ioctl() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_ioctl().
After careful review, at least some of these calls could be converted to do_vfs_ioctl() in future.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/ioctl.c | 7 ++++++- include/linux/syscalls.h | 1 + init/do_mounts.c | 8 ++++---- init/do_mounts_initrd.c | 2 +- init/do_mounts_md.c | 15 ++++++++------- init/do_mounts_rd.c | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-)
fs/ioctl.c +6 -1
@@ -689,7 +689,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,return error; } -SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) +int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg) {int error;struct fd f =fdget (fd);
@@ -702,3 +702,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)fdput (f);return error; } + +SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) +{ +return ksys_ioctl (fd, cmd, arg); +}
include/linux/syscalls.h +1 -0
@@ -974,6 +974,7 @@ int ksys_fchmod(unsigned int fd, umode_t mode);int ksys_fchown (unsigned int fd,uid_t user,gid_t group);int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent,unsigned int count); +int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg);/* * The following kernel syscall equivalents are just wrappers to fs-internal
init/do_mounts.c +4 -4
@@ -491,18 +491,18 @@ void __init change_floppy(char *fmt, ...)va_end (args); fd =ksys_open ("/dev/root" ,O_RDWR |O_NDELAY ,0 );if (fd >=0 ) { -sys_ioctl (fd,FDEJECT ,0 ); +ksys_ioctl (fd,FDEJECT ,0 );ksys_close (fd); }printk (KERN_NOTICE "VFS: Insert %s and press ENTER\n" , buf); fd =ksys_open ("/dev/console" ,O_RDWR ,0 );if (fd >=0 ) { -sys_ioctl (fd,TCGETS , (long )&termios); +ksys_ioctl (fd,TCGETS , (long )&termios); termios.c_lflag &= ~ICANON ; -sys_ioctl (fd,TCSETSF , (long )&termios); +ksys_ioctl (fd,TCSETSF , (long )&termios);sys_read (fd, &c,1 ); termios.c_lflag |=ICANON ; -sys_ioctl (fd,TCSETSF , (long )&termios); +ksys_ioctl (fd,TCSETSF , (long )&termios);ksys_close (fd); } }
init/do_mounts_initrd.c +1 -1
@@ -110,7 +110,7 @@ static void __init handle_initrd(void)if (fd <0 ) { error = fd; }else { - error =sys_ioctl (fd,BLKFLSBUF ,0 ); + error =ksys_ioctl (fd,BLKFLSBUF ,0 );ksys_close (fd); }printk (!error ?"okay\n" :"failed\n" );
init/do_mounts_md.c +8 -7
@@ -187,7 +187,7 @@ static void __init md_setup_drive(void) "array %s\n", name);continue ; } -if (sys_ioctl (fd,SET_ARRAY_INFO ,0 ) == -EBUSY ) { +if (ksys_ioctl (fd,SET_ARRAY_INFO ,0 ) == -EBUSY ) {printk (KERN_WARNING "md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n" , minor);
@@ -210,7 +210,7 @@ static void __init md_setup_drive(void) ainfo.state = (1 <<MD_SB_CLEAN ); ainfo.layout =0 ; ainfo.chunk_size = md_setup_args[ent].chunk; - err =sys_ioctl (fd,SET_ARRAY_INFO , (long )&ainfo); + err =ksys_ioctl (fd,SET_ARRAY_INFO , (long )&ainfo);for (i =0 ; !err && i <=MD_SB_DISKS ; i++) { dev = devices[i];if (!dev)
@@ -220,7 +220,8 @@ static void __init md_setup_drive(void) dinfo.state = (1 <<MD_DISK_ACTIVE )|(1 <<MD_DISK_SYNC ); dinfo.major =MAJOR (dev); dinfo.minor =MINOR (dev); - err =sys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); + err =ksys_ioctl (fd,ADD_NEW_DISK , + (long )&dinfo); } }else {/* persistent */
@@ -230,11 +231,11 @@ static void __init md_setup_drive(void)break ; dinfo.major =MAJOR (dev); dinfo.minor =MINOR (dev); -sys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); +ksys_ioctl (fd,ADD_NEW_DISK , (long )&dinfo); } }if (!err) - err =sys_ioctl (fd,RUN_ARRAY ,0 ); + err =ksys_ioctl (fd,RUN_ARRAY ,0 );if (err)printk (KERN_WARNING "md: starting md%d failed\n" , minor);else {
@@ -245,7 +246,7 @@ static void __init md_setup_drive(void)*/ ksys_close (fd); fd =ksys_open (name,0 ,0 ); -sys_ioctl (fd,BLKRRPART ,0 ); +ksys_ioctl (fd,BLKRRPART ,0 ); }ksys_close (fd); }
@@ -296,7 +297,7 @@ static void __init autodetect_raid(void) fd =ksys_open ("/dev/md0" ,0 ,0 );if (fd >=0 ) { -sys_ioctl (fd,RAID_AUTORUN , raid_autopart); +ksys_ioctl (fd,RAID_AUTORUN , raid_autopart);ksys_close (fd); } }
init/do_mounts_rd.c +2 -2
@@ -218,7 +218,7 @@ int __init rd_load_image(char *from)* NOTE NOTE: nblocks is not actually blocks but * the number of kibibytes of data to load into a ramdisk. */ -if (sys_ioctl (out_fd,BLKGETSIZE , (unsigned long )&rd_blocks) <0 ) +if (ksys_ioctl (out_fd,BLKGETSIZE , (unsigned long )&rd_blocks) <0 ) rd_blocks =0 ;else rd_blocks >>=1 ;
@@ -232,7 +232,7 @@ int __init rd_load_image(char *from)/* * OK, time to copy in the data */ -if (sys_ioctl (in_fd,BLKGETSIZE , (unsigned long )&devblocks) <0 ) +if (ksys_ioctl (in_fd,BLKGETSIZE , (unsigned long )&devblocks) <0 ) devblocks =0 ;else devblocks >>=1 ;
Signature · 1 line
2.16.2
PATCH 3/45 fs: add ksys_lseek() helper; remove in-kernel calls to sys_lseek()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel calls to the sys_lseek() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_lseek().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/read_write.c | 9 +++++++-- include/linux/syscalls.h | 1 + init/do_mounts_rd.c | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-)
fs/read_write.c +7 -2
@@ -301,7 +301,7 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int whence) }EXPORT_SYMBOL (vfs_llseek); -SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence) +off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence) {off_t retval;struct fd f =fdget_pos (fd);
@@ -319,10 +319,15 @@ SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence)return retval; } +SYSCALL_DEFINE3(lseek, unsigned int, fd, off_t, offset, unsigned int, whence) +{ +return ksys_lseek (fd, offset, whence); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE3(lseek, unsigned int, fd, compat_off_t, offset, unsigned int, whence) { -return sys_lseek (fd, offset, whence); +return ksys_lseek (fd, offset, whence); }#endif
include/linux/syscalls.h +1 -0
@@ -975,6 +975,7 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group);int ksys_getdents64 (unsigned int fd,struct linux_dirent64 __user *dirent,unsigned int count);int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg); +off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence);/* * The following kernel syscall equivalents are just wrappers to fs-internal
init/do_mounts_rd.c +4 -4
@@ -90,7 +90,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)/* * Read block 0 to test for compressed kernel */ -sys_lseek (fd, start_block *BLOCK_SIZE ,0 ); +ksys_lseek (fd, start_block *BLOCK_SIZE ,0 );sys_read (fd, buf, size); *decompressor =decompress_method (buf, size, &compress_name);
@@ -136,7 +136,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)/* * Read 512 bytes further to check if cramfs is padded */ -sys_lseek (fd, start_block *BLOCK_SIZE +0x200 ,0 ); +ksys_lseek (fd, start_block *BLOCK_SIZE +0x200 ,0 );sys_read (fd, buf, size);if (cramfsb->magic ==CRAMFS_MAGIC ) {
@@ -150,7 +150,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)/* * Read block 1 to test for minix and ext2 superblock */ -sys_lseek (fd, (start_block+1 ) *BLOCK_SIZE ,0 ); +ksys_lseek (fd, (start_block+1 ) *BLOCK_SIZE ,0 );sys_read (fd, buf, size);/* Try minix */
@@ -178,7 +178,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor) start_block); done: -sys_lseek (fd, start_block *BLOCK_SIZE ,0 ); +ksys_lseek (fd, start_block *BLOCK_SIZE ,0 );kfree (buf);return nblocks; }
Signature · 1 line
2.16.2
PATCH 4/45 fs: add ksys_read() helper; remove in-kernel calls to sys_read()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel calls to the sys_read() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_read().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/s390/kernel/compat_linux.c | 2 +- fs/read_write.c | 7 ++++++- include/linux/syscalls.h | 1 + init/do_mounts.c | 2 +- init/do_mounts_rd.c | 10 +++++----- 5 files changed, 14 insertions(+), 8 deletions(-)
arch/s390/kernel/compat_linux.c +1 -1
@@ -460,7 +460,7 @@ COMPAT_SYSCALL_DEFINE3(s390_read, unsigned int, fd, char __user *, buf, compat_sif ((compat_ssize_t ) count <0 )return -EINVAL ; -return sys_read (fd, buf, count); +return ksys_read (fd, buf, count); } COMPAT_SYSCALL_DEFINE3(s390_write, unsigned int, fd, const char __user *, buf, compat_size_t, count)
fs/read_write.c +6 -1
@@ -568,7 +568,7 @@ static inline void file_pos_write(struct file *file, loff_t pos) file->f_pos = pos; } -SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count) +ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count) {struct fd f =fdget_pos (fd);ssize_t ret = -EBADF ;
@@ -583,6 +583,11 @@ SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)return ret; } +SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count) +{ +return ksys_read (fd, buf, count); +} +ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count) {struct fd f =fdget_pos (fd);
include/linux/syscalls.h +1 -0
@@ -976,6 +976,7 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent, unsigned int count);int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg);off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence); +ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);/* * The following kernel syscall equivalents are just wrappers to fs-internal
init/do_mounts.c +1 -1
@@ -500,7 +500,7 @@ void __init change_floppy(char *fmt, ...)ksys_ioctl (fd,TCGETS , (long )&termios); termios.c_lflag &= ~ICANON ;ksys_ioctl (fd,TCSETSF , (long )&termios); -sys_read (fd, &c,1 ); +ksys_read (fd, &c,1 ); termios.c_lflag |=ICANON ;ksys_ioctl (fd,TCSETSF , (long )&termios);ksys_close (fd);
init/do_mounts_rd.c +5 -5
@@ -91,7 +91,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)* Read block 0 to test for compressed kernel */ ksys_lseek (fd, start_block *BLOCK_SIZE ,0 ); -sys_read (fd, buf, size); +ksys_read (fd, buf, size); *decompressor =decompress_method (buf, size, &compress_name);if (compress_name) {
@@ -137,7 +137,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)* Read 512 bytes further to check if cramfs is padded */ ksys_lseek (fd, start_block *BLOCK_SIZE +0x200 ,0 ); -sys_read (fd, buf, size); +ksys_read (fd, buf, size);if (cramfsb->magic ==CRAMFS_MAGIC ) { printk(KERN_NOTICE
@@ -151,7 +151,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)* Read block 1 to test for minix and ext2 superblock */ ksys_lseek (fd, (start_block+1 ) *BLOCK_SIZE ,0 ); -sys_read (fd, buf, size); +ksys_read (fd, buf, size);/* Try minix */ if (minixsb->s_magic == MINIX_SUPER_MAGIC ||
@@ -269,7 +269,7 @@ int __init rd_load_image(char *from) }printk ("Loading disk #%d... " , disk); } -sys_read (in_fd, buf,BLOCK_SIZE ); +ksys_read (in_fd, buf,BLOCK_SIZE );ksys_write (out_fd, buf,BLOCK_SIZE );#if !defined(CONFIG_S390 )if (!(i %16 )) {
@@ -307,7 +307,7 @@ static int crd_infd, crd_outfd;static long __init compr_fill (void *buf,unsigned long len) { -long r =sys_read (crd_infd, buf, len); +long r =ksys_read (crd_infd, buf, len);if (r <0 )printk (KERN_ERR "RAMDISK: error while reading compressed data" );else if (r ==0 )
Signature · 1 line
2.16.2
PATCH 5/45 fs: add ksys_sync() helper; remove in-kernel calls to sys_sync()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel calls to the sys_sync() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_sync().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/sparc/kernel/setup_32.c | 2 +- drivers/tty/sysrq.c | 2 +- fs/sync.c | 7 ++++++- include/linux/syscalls.h | 1 + kernel/power/hibernate.c | 2 +- kernel/power/suspend.c | 2 +- kernel/power/user.c | 2 +- 7 files changed, 12 insertions(+), 6 deletions(-)
arch/sparc/kernel/setup_32.c +1 -1
@@ -86,7 +86,7 @@ static void prom_sync_me(void)show_free_areas (0 ,NULL );if (!is_idle_task (current)) {local_irq_enable (); -sys_sync (); +ksys_sync ();local_irq_disable (); }prom_printf ("Returning to prom\n" );
drivers/tty/sysrq.c +1 -1
@@ -660,7 +660,7 @@ static void sysrq_do_reset(struct timer_list *t) state->reset_requested = true; -sys_sync (); +ksys_sync ();kernel_restart (NULL ); }
fs/sync.c +6 -1
@@ -105,7 +105,7 @@ static void fdatawait_one_bdev(struct block_device *bdev, void *arg)* just write metadata (such as inodes or bitmaps) to block device page cache * and do not sync it on their own in ->sync_fs(). */ -SYSCALL_DEFINE0 (sync) +void ksys_sync (void ) {int nowait =0 , wait =1 ;
@@ -117,6 +117,11 @@ SYSCALL_DEFINE0(sync)iterate_bdevs (fdatawait_one_bdev,NULL );if (unlikely (laptop_mode))laptop_sync_completion (); +} + +SYSCALL_DEFINE0 (sync) +{ +ksys_sync ();return 0 ; }
include/linux/syscalls.h +1 -0
@@ -977,6 +977,7 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,int ksys_ioctl (unsigned int fd,unsigned int cmd,unsigned long arg);off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count); +void ksys_sync (void );/* * The following kernel syscall equivalents are just wrappers to fs-internal
kernel/power/hibernate.c +1 -1
@@ -701,7 +701,7 @@ int hibernate(void) }pr_info ("Syncing filesystems ... \n" ); -sys_sync (); +ksys_sync ();pr_info ("done.\n" ); error =freeze_processes ();
kernel/power/suspend.c +1 -1
@@ -560,7 +560,7 @@ static int enter_state(suspend_state_t state)#ifndef CONFIG_SUSPEND_SKIP_SYNC trace_suspend_resume (TPS ("sync_filesystems" ),0 , true);pr_info ("Syncing filesystems ... " ); -sys_sync (); +ksys_sync ();pr_cont ("done.\n" );trace_suspend_resume (TPS ("sync_filesystems" ),0 , false);#endif
kernel/power/user.c +1 -1
@@ -224,7 +224,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,break ;printk ("Syncing filesystems ... " ); -sys_sync (); +ksys_sync ();printk ("done.\n" ); error =freeze_processes ();
Signature · 1 line
2.16.2
PATCH 6/45 fs: add do_lookup_dcookie() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the fs-internal do_lookup_dcookie() helper allows us to get rid of fs-internal calls to the sys_lookup_dcookie() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/dcookies.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/dcookies.c +8 -3
@@ -146,7 +146,7 @@ int get_dcookie(const struct path *path, unsigned long *cookie)/* And here is where the userspace process can look up the cookie value * to retrieve the path. */ -SYSCALL_DEFINE3(lookup_dcookie, u64, cookie64, char __user *, buf, size_t, len) +static int do_lookup_dcookie (u64 cookie64,char __user *buf,size_t len) {unsigned long cookie = (unsigned long )cookie64;int err = -EINVAL ;
@@ -203,13 +203,18 @@ SYSCALL_DEFINE3(lookup_dcookie, u64, cookie64, char __user *, buf, size_t, len)return err; } +SYSCALL_DEFINE3(lookup_dcookie, u64, cookie64, char __user *, buf, size_t, len) +{ +return do_lookup_dcookie (cookie64, buf, len); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE4(lookup_dcookie, u32, w0, u32, w1, char __user *, buf, compat_size_t, len) {#ifdef __BIG_ENDIAN -return sys_lookup_dcookie (((u64 )w0 <<32 ) | w1, buf, len); +return do_lookup_dcookie (((u64 )w0 <<32 ) | w1, buf, len);#else -return sys_lookup_dcookie (((u64 )w1 <<32 ) | w0, buf, len); +return do_lookup_dcookie (((u64 )w1 <<32 ) | w0, buf, len);#endif }#endif
Signature · 1 line
2.16.2
PATCH 7/45 fs: add do_vmsplice() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the fs-internal do_vmsplice() helper allows us to get rid of the fs-internal call to the sys_vmsplice() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/splice.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/splice.c +9 -3
@@ -1331,8 +1331,8 @@ static long vmsplice_to_pipe(struct file *file, const struct iovec __user *uiov,* Currently we punt and implement it as a normal copy, see pipe_to_user(). * */ -SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov, - unsigned long, nr_segs, unsigned int, flags) +static long do_vmsplice (int fd,const struct iovec __user *iov, +unsigned long nr_segs,unsigned int flags) {struct fd f;long error;
@@ -1358,6 +1358,12 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov,return error; } +SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov, + unsigned long, nr_segs, unsigned int, flags) +{ +return do_vmsplice (fd, iov, nr_segs, flags); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, iov32, unsigned int, nr_segs, unsigned int, flags)
@@ -1375,7 +1381,7 @@ COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, io put_user(v.iov_len, &iov[i].iov_len)) return -EFAULT; } -return sys_vmsplice (fd, iov, nr_segs, flags); +return do_vmsplice (fd, iov, nr_segs, flags); }#endif
Signature · 1 line
2.16.2
PATCH 8/45 fs: add kern_select() helper; remove in-kernel call to sys_select()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel call to the sys_umount() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/select.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/select.c +9 -3
@@ -675,8 +675,8 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,return ret; } -SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp, - fd_set __user *, exp, struct timeval __user *, tvp) +static int kern_select (int n,fd_set __user *inp,fd_set __user *outp, +fd_set __user *exp,struct timeval __user *tvp) {struct timespec64 end_time, *to =NULL ;struct timeval tv;
@@ -699,6 +699,12 @@ SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp,return ret; } +SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp, + fd_set __user *, exp, struct timeval __user *, tvp) +{ +return kern_select (n, inp, outp, exp, tvp); +} +static long do_pselect (int n,fd_set __user *inp,fd_set __user *outp,fd_set __user *exp,struct timespec __user *tsp,const sigset_t __user *sigmask,size_t sigsetsize)
@@ -784,7 +790,7 @@ SYSCALL_DEFINE1(old_select, struct sel_arg_struct __user *, arg)if (copy_from_user (&a, arg,sizeof (a)))return -EFAULT ; - return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp); + return kern_select(a.n, a.inp, a.outp, a.exp, a.tvp); }#endif
Signature · 1 line
2.16.2
PATCH 9/45 fs: add ksys_truncate() wrapper; remove in-kernel calls to sys_truncate()
In reply to Dominik BrodowskiUsing the ksys_truncate() wrapper allows us to get rid of in-kernel calls to the sys_truncate() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_truncate().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/mips/kernel/linux32.c | 2 +- arch/parisc/kernel/sys_parisc.c | 6 +++--- arch/powerpc/kernel/sys_ppc32.c | 2 +- arch/s390/kernel/compat_linux.c | 2 +- arch/sparc/kernel/sys_sparc32.c | 2 +- arch/x86/ia32/sys_ia32.c | 3 ++- fs/open.c | 2 +- include/linux/syscalls.h | 7 +++++++ 8 files changed, 17 insertions(+), 9 deletions(-)
arch/mips/kernel/linux32.c +1 -1
@@ -82,7 +82,7 @@ struct rlimit32 { SYSCALL_DEFINE4(32_truncate64, const char __user *, path, unsigned long, __dummy, unsigned long, a2, unsigned long, a3) { -return sys_truncate (path,merge_64 (a2, a3)); +return ksys_truncate (path,merge_64 (a2, a3)); } SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy,
arch/parisc/kernel/sys_parisc.c +3 -3
@@ -292,7 +292,7 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,asmlinkage long parisc_truncate64 (const char __user * path,unsigned int high,unsigned int low) { -return sys_truncate (path, (long )high <<32 | low); +return ksys_truncate (path, (long )high <<32 | low); } asmlinkage long parisc_ftruncate64(unsigned int fd,
@@ -305,7 +305,7 @@ asmlinkage long parisc_ftruncate64(unsigned int fd,* are identical on LP64 */ asmlinkage long sys_truncate64 (const char __user * path,unsigned long length) { -return sys_truncate (path, length); +return ksys_truncate (path, length); }asmlinkage long sys_ftruncate64 (unsigned int fd,unsigned long length) {
@@ -320,7 +320,7 @@ asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long argasmlinkage long parisc_truncate64 (const char __user * path,unsigned int high,unsigned int low) { -return sys_truncate64 (path, (loff_t )high <<32 | low); +return ksys_truncate (path, (loff_t )high <<32 | low); } asmlinkage long parisc_ftruncate64(unsigned int fd,
arch/powerpc/kernel/sys_ppc32.c +1 -1
@@ -94,7 +94,7 @@ compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 co asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,unsigned long high,unsigned long low) { -return sys_truncate (path, (high <<32 ) | low); +return ksys_truncate (path, (high <<32 ) | low); } asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
arch/s390/kernel/compat_linux.c +1 -1
@@ -302,7 +302,7 @@ COMPAT_SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, compat_ulong_t, second, COMPAT_SYSCALL_DEFINE3(s390_truncate64, const char __user *, path, u32, high, u32, low) { -return sys_truncate (path, (unsigned long )high <<32 | low); +return ksys_truncate (path, (unsigned long )high <<32 | low); } COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsigned int, fd, u32, high, u32, low)
arch/sparc/kernel/sys_sparc32.c +1 -1
@@ -57,7 +57,7 @@ asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, uif ((int )high <0 )return -EINVAL ;else -return sys_truncate (path, (high <<32 ) | low); +return ksys_truncate (path, (high <<32 ) | low); }asmlinkage long sys32_ftruncate64 (unsigned int fd,unsigned long high,unsigned long low)
arch/x86/ia32/sys_ia32.c +2 -1
@@ -54,7 +54,8 @@ COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename, unsigned long, offset_low, unsigned long, offset_high) { -return sys_truncate (filename, ((loff_t ) offset_high <<32 ) | offset_low); +return ksys_truncate (filename, + ((loff_t ) offset_high <<32 ) | offset_low); } COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd,
fs/open.c +1 -1
@@ -128,7 +128,7 @@ long vfs_truncate(const struct path *path, loff_t length) }EXPORT_SYMBOL_GPL (vfs_truncate); -static long do_sys_truncate (const char __user *pathname,loff_t length) +long do_sys_truncate (const char __user *pathname,loff_t length) {unsigned int lookup_flags =LOOKUP_FOLLOW ;struct path path;
include/linux/syscalls.h +7 -0
@@ -1045,6 +1045,13 @@ static inline long ksys_access(const char __user *filename, int mode)return do_faccessat (AT_FDCWD , filename, mode); } +extern long do_sys_truncate (const char __user *pathname,loff_t length); + +static inline long ksys_truncate (const char __user *pathname,loff_t length) +{ +return do_sys_truncate (pathname, length); +} +extern long do_sys_ftruncate (unsigned int fd,loff_t length,int small);static inline long ksys_ftruncate (unsigned int fd,unsigned long length)
Signature · 1 line
2.16.2
PATCH 10/45 fs: add ksys_p{read,write}64() helpers; remove in-kernel calls to syscalls
In reply to Dominik BrodowskiUsing the ksys_p{read,write}64() wrappers allows us to get rid of in-kernel calls to the sys_pread64() and sys_pwrite64() syscalls. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_p{read,write}64().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/mips/kernel/linux32.c | 4 ++-- arch/parisc/kernel/sys_parisc.c | 4 ++-- arch/powerpc/kernel/sys_ppc32.c | 4 ++-- arch/s390/kernel/compat_linux.c | 4 ++-- arch/sh/kernel/sys_sh32.c | 4 ++-- arch/sparc/kernel/sys_sparc32.c | 4 ++-- arch/x86/ia32/sys_ia32.c | 8 ++++---- fs/read_write.c | 20 ++++++++++++++++---- include/linux/syscalls.h | 4 ++++ 9 files changed, 36 insertions(+), 20 deletions(-)
arch/mips/kernel/linux32.c +2 -2
@@ -105,13 +105,13 @@ SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high, SYSCALL_DEFINE6(32_pread, unsigned long, fd, char __user *, buf, size_t, count, unsigned long, unused, unsigned long, a4, unsigned long, a5) { -return sys_pread64 (fd, buf, count,merge_64 (a4, a5)); +return ksys_pread64 (fd, buf, count,merge_64 (a4, a5)); } SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf, size_t, count, u32, unused, u64, a4, u64, a5) { -return sys_pwrite64 (fd, buf, count,merge_64 (a4, a5)); +return ksys_pwrite64 (fd, buf, count,merge_64 (a4, a5)); } SYSCALL_DEFINE1(32_personality, unsigned long, personality)
arch/parisc/kernel/sys_parisc.c +2 -2
@@ -333,13 +333,13 @@ asmlinkage long parisc_ftruncate64(unsigned int fd, asmlinkage ssize_t parisc_pread64(unsigned int fd, char __user *buf, size_t count,unsigned int high,unsigned int low) { -return sys_pread64 (fd, buf, count, (loff_t )high <<32 | low); +return ksys_pread64 (fd, buf, count, (loff_t )high <<32 | low); } asmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf,size_t count,unsigned int high,unsigned int low) { -return sys_pwrite64 (fd, buf, count, (loff_t )high <<32 | low); +return ksys_pwrite64 (fd, buf, count, (loff_t )high <<32 | low); } asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,
arch/powerpc/kernel/sys_ppc32.c +2 -2
@@ -77,13 +77,13 @@ unsigned long compat_sys_mmap2(unsigned long addr, size_t len,compat_ssize_t compat_sys_pread64 (unsigned int fd,char __user *ubuf,compat_size_t count,u32 reg6,u32 poshi,u32 poslo) { -return sys_pread64 (fd, ubuf, count, ((loff_t )poshi <<32 ) | poslo); +return ksys_pread64 (fd, ubuf, count, ((loff_t )poshi <<32 ) | poslo); }compat_ssize_t compat_sys_pwrite64 (unsigned int fd,const char __user *ubuf,compat_size_t count,u32 reg6,u32 poshi,u32 poslo) { -return sys_pwrite64 (fd, ubuf, count, ((loff_t )poshi <<32 ) | poslo); +return ksys_pwrite64 (fd, ubuf, count, ((loff_t )poshi <<32 ) | poslo); }compat_ssize_t compat_sys_readahead (int fd,u32 r4,u32 offhi,u32 offlo,u32 count)
arch/s390/kernel/compat_linux.c +2 -2
@@ -315,7 +315,7 @@ COMPAT_SYSCALL_DEFINE5(s390_pread64, unsigned int, fd, char __user *, ubuf, {if ((compat_ssize_t ) count <0 )return -EINVAL ; -return sys_pread64 (fd, ubuf, count, (unsigned long )high <<32 | low); +return ksys_pread64 (fd, ubuf, count, (unsigned long )high <<32 | low); } COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned int, fd, const char __user *, ubuf,
@@ -323,7 +323,7 @@ COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned int, fd, const char __user *, ubu {if ((compat_ssize_t ) count <0 )return -EINVAL ; -return sys_pwrite64 (fd, ubuf, count, (unsigned long )high <<32 | low); +return ksys_pwrite64 (fd, ubuf, count, (unsigned long )high <<32 | low); }COMPAT_SYSCALL_DEFINE4 (s390_readahead, int, fd, u32, high, u32, low, s32, count)
arch/sh/kernel/sys_sh32.c +2 -2
@@ -39,13 +39,13 @@ asmlinkage int sys_sh_pipe(void) asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char __user *buf,size_t count,long dummy,loff_t pos) { -return sys_pread64 (fd, buf, count, pos); +return ksys_pread64 (fd, buf, count, pos); } asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char __user *buf,size_t count,long dummy,loff_t pos) { -return sys_pwrite64 (fd, buf, count, pos); +return ksys_pwrite64 (fd, buf, count, pos); } asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
arch/sparc/kernel/sys_sparc32.c +2 -2
@@ -200,7 +200,7 @@ asmlinkage compat_ssize_t sys32_pread64(unsigned int fd, unsigned long poshi, unsigned long poslo) { -return sys_pread64 (fd, ubuf, count, (poshi <<32 ) | poslo); +return ksys_pread64 (fd, ubuf, count, (poshi <<32 ) | poslo); } asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd,
@@ -209,7 +209,7 @@ asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd, unsigned long poshi, unsigned long poslo) { -return sys_pwrite64 (fd, ubuf, count, (poshi <<32 ) | poslo); +return ksys_pwrite64 (fd, ubuf, count, (poshi <<32 ) | poslo); } asmlinkage long compat_sys_readahead(int fd,
arch/x86/ia32/sys_ia32.c +4 -4
@@ -179,15 +179,15 @@ COMPAT_SYSCALL_DEFINE3(x86_waitpid, compat_pid_t, pid, unsigned int __user *, COMPAT_SYSCALL_DEFINE5(x86_pread, unsigned int, fd, char __user *, ubuf, u32, count, u32, poslo, u32, poshi) { -return sys_pread64 (fd, ubuf, count, - ((loff_t )AA (poshi) <<32 ) |AA (poslo)); +return ksys_pread64 (fd, ubuf, count, + ((loff_t )AA (poshi) <<32 ) |AA (poslo)); } COMPAT_SYSCALL_DEFINE5(x86_pwrite, unsigned int, fd, const char __user *, ubuf, u32, count, u32, poslo, u32, poshi) { -return sys_pwrite64 (fd, ubuf, count, - ((loff_t )AA (poshi) <<32 ) |AA (poslo)); +return ksys_pwrite64 (fd, ubuf, count, + ((loff_t )AA (poshi) <<32 ) |AA (poslo)); }
fs/read_write.c +16 -4
@@ -610,8 +610,8 @@ SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf,return ksys_write (fd, buf, count); } -SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf, - size_t, count, loff_t, pos) +ssize_t ksys_pread64 (unsigned int fd,char __user *buf,size_t count, +loff_t pos) {struct fd f;ssize_t ret = -EBADF ;
@@ -630,8 +630,14 @@ SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf,return ret; } -SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf, - size_t, count, loff_t, pos) +SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf, + size_t, count, loff_t, pos) +{ +return ksys_pread64 (fd, buf, count, pos); +} + +ssize_t ksys_pwrite64 (unsigned int fd,const char __user *buf, +size_t count,loff_t pos) {struct fd f;ssize_t ret = -EBADF ;
@@ -650,6 +656,12 @@ SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf,return ret; } +SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf, + size_t, count, loff_t, pos) +{ +return ksys_pwrite64 (fd, buf, count, pos); +} +static ssize_t do_iter_readv_writev (struct file *filp,struct iov_iter *iter,loff_t *ppos,int type,rwf_t flags) {
include/linux/syscalls.h +4 -0
@@ -978,6 +978,10 @@ int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);off_t ksys_lseek (unsigned int fd,off_t offset,unsigned int whence);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);void ksys_sync (void ); +ssize_t ksys_pread64 (unsigned int fd,char __user *buf,size_t count, +loff_t pos); +ssize_t ksys_pwrite64 (unsigned int fd,const char __user *buf, +size_t count,loff_t pos);/* * The following kernel syscall equivalents are just wrappers to fs-internal
Signature · 1 line
2.16.2
PATCH 11/45 fs: add ksys_fallocate() wrapper; remove in-kernel calls to sys_fallocate()
In reply to Dominik BrodowskiUsing the ksys_fallocate() wrapper allows us to get rid of in-kernel calls to the sys_fallocate() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_fallocate().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/mips/kernel/linux32.c | 4 ++-- arch/parisc/kernel/sys_parisc.c | 4 ++-- arch/powerpc/kernel/sys_ppc32.c | 2 +- arch/s390/kernel/compat_linux.c | 4 ++-- arch/sparc/kernel/sys_sparc32.c | 4 ++-- arch/x86/ia32/sys_ia32.c | 4 ++-- fs/open.c | 7 ++++++- include/linux/syscalls.h | 1 + 8 files changed, 18 insertions(+), 12 deletions(-)
arch/mips/kernel/linux32.c +2 -2
@@ -157,6 +157,6 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,asmlinkage long sys32_fallocate (int fd,int mode,unsigned offset_a2,unsigned offset_a3,unsigned len_a4,unsigned len_a5) { -return sys_fallocate (fd, mode,merge_64 (offset_a2, offset_a3), -merge_64 (len_a4, len_a5)); +return ksys_fallocate (fd, mode,merge_64 (offset_a2, offset_a3), +merge_64 (len_a4, len_a5)); }
arch/parisc/kernel/sys_parisc.c +2 -2
@@ -367,8 +367,8 @@ asmlinkage long parisc_sync_file_range(int fd,asmlinkage long parisc_fallocate (int fd,int mode,u32 offhi,u32 offlo,u32 lenhi,u32 lenlo) { -return sys_fallocate (fd, mode, ((u64 )offhi <<32 ) | offlo, - ((u64 )lenhi <<32 ) | lenlo); +return ksys_fallocate (fd, mode, ((u64 )offhi <<32 ) | offlo, + ((u64 )lenhi <<32 ) | lenlo); }long parisc_personality (unsigned long personality)
arch/powerpc/kernel/sys_ppc32.c +1 -1
@@ -100,7 +100,7 @@ asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,asmlinkage long compat_sys_fallocate (int fd,int mode,u32 offhi,u32 offlo,u32 lenhi,u32 lenlo) { -return sys_fallocate (fd, mode, ((loff_t )offhi <<32 ) | offlo, +return ksys_fallocate (fd, mode, ((loff_t )offhi <<32 ) | offlo, ((loff_t )lenhi <<32 ) | lenlo); }
arch/s390/kernel/compat_linux.c +2 -2
@@ -517,6 +517,6 @@ COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,COMPAT_SYSCALL_DEFINE6 (s390_fallocate, int, fd, int, mode, u32, offhigh, u32, offlow, u32, lenhigh, u32, lenlow) { -return sys_fallocate (fd, mode, ((loff_t )offhigh <<32 ) + offlow, - ((u64 )lenhigh <<32 ) + lenlow); +return ksys_fallocate (fd, mode, ((loff_t )offhigh <<32 ) + offlow, + ((u64 )lenhigh <<32 ) + lenlow); }
arch/sparc/kernel/sys_sparc32.c +2 -2
@@ -250,6 +250,6 @@ long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned lonasmlinkage long compat_sys_fallocate (int fd,int mode,u32 offhi,u32 offlo,u32 lenhi,u32 lenlo) { -return sys_fallocate (fd, mode, ((loff_t )offhi <<32 ) | offlo, - ((loff_t )lenhi <<32 ) | lenlo); +return ksys_fallocate (fd, mode, ((loff_t )offhi <<32 ) | offlo, + ((loff_t )lenhi <<32 ) | lenlo); }
arch/x86/ia32/sys_ia32.c +2 -2
@@ -231,8 +231,8 @@ COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode, unsigned int, offset_lo, unsigned int, offset_hi, unsigned int, len_lo, unsigned int, len_hi) { - return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo, - ((u64)len_hi << 32) | len_lo); + return ksys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo, + ((u64)len_hi << 32) | len_lo); }/*
fs/open.c +6 -1
@@ -333,7 +333,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) }EXPORT_SYMBOL_GPL (vfs_fallocate); -SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) +int ksys_fallocate (int fd,int mode,loff_t offset,loff_t len) {struct fd f =fdget (fd);int error = -EBADF ;
@@ -345,6 +345,11 @@ SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)return error; } +SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len) +{ +return ksys_fallocate (fd, mode, offset, len); +} +/* * access() needs to use the real uid/gid, not the effective uid/gid. * We do this by temporarily clearing all FS-related capabilities and
include/linux/syscalls.h +1 -0
@@ -982,6 +982,7 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count, loff_t pos);ssize_t ksys_pwrite64 (unsigned int fd,const char __user *buf,size_t count,loff_t pos); +int ksys_fallocate (int fd,int mode,loff_t offset,loff_t len);/* * The following kernel syscall equivalents are just wrappers to fs-internal
Signature · 1 line
2.16.2
PATCH 12/45 fs: add do_compat_fcntl64() helper; remove in-kernel call to comapt syscall
In reply to Dominik BrodowskiUsing the fs-internal do_compat_fcntl64() helper allows us to get rid of the fs-internal call to the compat_sys_fcntl64() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/fcntl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/fcntl.c +9 -3
@@ -607,8 +607,8 @@ static int fixup_compat_flock(struct flock *flock)return 0 ; } -COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, - compat_ulong_t, arg) +static long do_compat_fcntl64 (unsigned int fd,unsigned int cmd, +compat_ulong_t arg) {struct fd f =fdget_raw (fd);struct flock flock;
@@ -672,6 +672,12 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,return err; } +COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, + compat_ulong_t, arg) +{ +return do_compat_fcntl64 (fd, cmd, arg); +} + COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, compat_ulong_t, arg) {
@@ -684,7 +690,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,case F_OFD_SETLKW : return -EINVAL; } -return compat_sys_fcntl64 (fd, cmd, arg); +return do_compat_fcntl64 (fd, cmd, arg); }#endif
Signature · 1 line
2.16.2
PATCH 13/45 fs: add do_compat_select() helper; remove in-kernel call to comapt syscall
In reply to Dominik BrodowskiUsing the fs-internal do_compat_select() helper allows us to get rid of the fs-internal call to the compat_sys_select() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/select.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/select.c +12 -5
@@ -1265,9 +1265,9 @@ static int compat_core_sys_select(int n, compat_ulong_t __user *inp,return ret; } -COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp, - compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, - struct compat_timeval __user *, tvp) +static int do_compat_select (int n,compat_ulong_t __user *inp, +compat_ulong_t __user *outp,compat_ulong_t __user *exp, +struct compat_timeval __user *tvp) {struct timespec64 end_time, *to =NULL ;struct compat_timeval tv;
@@ -1290,6 +1290,13 @@ COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,return ret; } +COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp, + compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, + struct compat_timeval __user *, tvp) +{ +return do_compat_select (n, inp, outp, exp, tvp); +} +struct compat_sel_arg_struct {compat_ulong_t n;compat_uptr_t inp;
@@ -1304,8 +1311,8 @@ COMPAT_SYSCALL_DEFINE1(old_select, struct compat_sel_arg_struct __user *, arg)if (copy_from_user (&a, arg,sizeof (a)))return -EFAULT ; -return compat_sys_select (a.n,compat_ptr (a.inp),compat_ptr (a.outp), -compat_ptr (a.exp),compat_ptr (a.tvp)); +return do_compat_select (a.n,compat_ptr (a.inp),compat_ptr (a.outp), +compat_ptr (a.exp),compat_ptr (a.tvp)); } static long do_compat_pselect(int n, compat_ulong_t __user *inp,
Signature · 1 line
2.16.2
PATCH 14/45 fs: add do_compat_signalfd4() helper; remove in-kernel call to comapt syscall
In reply to Dominik BrodowskiUsing the fs-internal do_compat_signalfd4() helper allows us to get rid of the fs-internal call to the compat_sys_signalfd4() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/signalfd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/signalfd.c +12 -5
@@ -323,10 +323,9 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask, }#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE4 (signalfd4, int, ufd, - const compat_sigset_t __user *,sigmask, - compat_size_t, sigsetsize, - int, flags) +static long do_compat_signalfd4 (int ufd, +const compat_sigset_t __user *sigmask, +compat_size_t sigsetsize,int flags) {sigset_t tmp;sigset_t __user *ksigmask;
@@ -342,10 +341,18 @@ COMPAT_SYSCALL_DEFINE4(signalfd4, int, ufd,return do_signalfd4 (ufd, ksigmask,sizeof (sigset_t), flags); } +COMPAT_SYSCALL_DEFINE4 (signalfd4, int, ufd, + const compat_sigset_t __user *, sigmask, + compat_size_t, sigsetsize, + int, flags) +{ +return do_compat_signalfd4 (ufd, sigmask, sigsetsize, flags); +} +COMPAT_SYSCALL_DEFINE3 (signalfd, int, ufd, const compat_sigset_t __user *,sigmask, compat_size_t, sigsetsize) { - return compat_sys_signalfd4(ufd, sigmask, sigsetsize, 0); +return do_compat_signalfd4 (ufd, sigmask, sigsetsize,0 ); }#endif
Signature · 1 line
2.16.2
PATCH 15/45 fs: add do_compat_futimesat() helper; remove in-kernel call to comapt syscall
In reply to Dominik BrodowskiUsing the fs-internal do_compat_futimesat() helper allows us to get rid of the fs-internal call to the compat_sys_futimesat() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/utimes.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
fs/utimes.c +10 -2
@@ -260,7 +260,8 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filenareturn do_utimes (dfd, filename, t ? tv :NULL , flags); } -COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t) +static long do_compat_futimesat (unsigned int dfd,const char __user *filename, +struct compat_timeval __user *t) {struct timespec64 tv[2 ];
@@ -279,8 +280,15 @@ COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filenareturn do_utimes (dfd, filename, t ? tv :NULL ,0 ); } +COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, + const char __user *, filename, + struct compat_timeval __user *, t) +{ +return do_compat_futimesat (dfd, filename, t); +} + COMPAT_SYSCALL_DEFINE2(utimes, const char __user *, filename, struct compat_timeval __user *, t) { - return compat_sys_futimesat(AT_FDCWD, filename, t); +return do_compat_futimesat (AT_FDCWD , filename, t); }#endif
Signature · 1 line
2.16.2
PATCH 16/45 inotify: add do_inotify_init() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the inotify-internal do_inotify_init() helper allows us to get rid of the in-kernel call to sys_inotify_init1() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/notify/inotify/inotify_user.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/notify/inotify/inotify_user.c +7 -2
@@ -635,7 +635,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)/* inotify syscalls */ -SYSCALL_DEFINE1(inotify_init1, int, flags) +static int do_inotify_init (int flags) {struct fsnotify_group *group;int ret;
@@ -660,9 +660,14 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)return ret; } +SYSCALL_DEFINE1(inotify_init1, int, flags) +{ +return do_inotify_init (flags); +} +SYSCALL_DEFINE0 (inotify_init) { -return sys_inotify_init1 (0 ); +return do_inotify_init (0 ); } SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
Signature · 1 line
2.16.2
PATCH 17/45 fanotify: add do_fanotify_mark() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the fs-internal do_fanotify_mark() helper allows us to get rid of the fs-internal call to the sys_fanotify_mark() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/notify/fanotify/fanotify_user.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
fs/notify/fanotify/fanotify_user.c +10 -4
@@ -820,9 +820,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)return fd; } -SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, - __u64, mask, int, dfd, - const char __user *, pathname) +static int do_fanotify_mark (int fanotify_fd,unsigned int flags,__u64 mask, +int dfd,const char __user *pathname) {struct inode *inode =NULL ;struct vfsmount *mnt =NULL ;
@@ -928,13 +927,20 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,return ret; } +SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, + __u64, mask, int, dfd, + const char __user *, pathname) +{ +return do_fanotify_mark (fanotify_fd, flags, mask, dfd, pathname); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE6 (fanotify_mark, int, fanotify_fd, unsigned int, flags, __u32, mask0, __u32, mask1, int, dfd, const char __user *, pathname) { - return sys_fanotify_mark(fanotify_fd, flags, + return do_fanotify_mark(fanotify_fd, flags, #ifdef __BIG_ENDIAN ((__u64)mask0 << 32) | mask1,#else
Signature · 1 line
2.16.2
PATCH 18/45 fs/quota: add kernel_quotactl() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the fs-internal kernel_quotactl() helper allows us to get rid of the fs-internal call to the sys_quotactl() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- fs/quota/compat.c | 8 ++++---- fs/quota/quota.c | 10 ++++++++-- include/linux/quotaops.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-)
fs/quota/compat.c +4 -4
@@ -59,7 +59,7 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,case Q_GETQUOTA : dqblk =compat_alloc_user_space (sizeof (struct if_dqblk )); compat_dqblk = addr; - ret =sys_quotactl (cmd, special, id, dqblk); + ret =kernel_quotactl (cmd, special, id, dqblk);if (ret)break ; if (copy_in_user(compat_dqblk, dqblk, sizeof(*compat_dqblk)) ||
@@ -75,12 +75,12 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,get_user (data, &compat_dqblk->dqb_valid) || put_user(data, &dqblk->dqb_valid)) break; - ret =sys_quotactl (cmd, special, id, dqblk); + ret =kernel_quotactl (cmd, special, id, dqblk);break ;case Q_XGETQSTAT : fsqstat =compat_alloc_user_space (sizeof (struct fs_quota_stat )); compat_fsqstat = addr; - ret =sys_quotactl (cmd, special, id, fsqstat); + ret =kernel_quotactl (cmd, special, id, fsqstat);if (ret)break ; ret = -EFAULT ;
@@ -113,7 +113,7 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special, ret =0 ;break ;default : - ret =sys_quotactl (cmd, special, id, addr); + ret =kernel_quotactl (cmd, special, id, addr); }return ret; }
fs/quota/quota.c +8 -2
@@ -833,8 +833,8 @@ static struct super_block *quotactl_block(const char __user *special, int cmd)* calls. Maybe we need to add the process quotas etc. in the future, * but we probably should use rlimits for that. */ -SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, - qid_t, id, void __user *, addr) +int kernel_quotactl (unsigned int cmd,const char __user *special, +qid_t id,void __user *addr) {uint cmds, type;struct super_block *sb =NULL ;
@@ -885,3 +885,9 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,path_put (pathp);return ret; } + +SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, + qid_t, id, void __user *, addr) +{ +return kernel_quotactl (cmd, special, id, addr); +}
include/linux/quotaops.h +3 -0
@@ -105,6 +105,9 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,int __dquot_transfer (struct inode *inode,struct dquot **transfer_to);int dquot_transfer (struct inode *inode,struct iattr *iattr); +int kernel_quotactl (unsigned int cmd,const char __user *special, +qid_t id,void __user *addr); +static inline struct mem_dqinfo *sb_dqinfo (struct super_block *sb,int type) {return sb_dqopt (sb)->info + type;
Signature · 1 line
2.16.2
PATCH 19/45 fs/quota: use COMPAT_SYSCALL_DEFINE for sys32_quotactl()
In reply to Dominik BrodowskiWhile sys32_quotactl() is only needed on x86, it can use the recommended COMPAT_SYSCALL_DEFINEx() machinery for its setup.
--- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- fs/quota/compat.c | 5 +++-- include/linux/compat.h | 3 +++ include/linux/syscalls.h | 4 +--- kernel/sys_ni.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
@@ -137,7 +137,7 @@ 128 i386 init_module sys_init_module 129 i386 delete_module sys_delete_module 130 i386 get_kernel_syms -131 i386 quotactl sys_quotactl sys32_quotactl +131 i386 quotactl sys_quotactl compat_sys_quotactl32 132 i386 getpgid sys_getpgid 133 i386 fchdir sys_fchdir 134 i386 bdflush sys_bdflush
fs/quota/compat.c +3 -2
@@ -41,8 +41,9 @@ struct compat_fs_quota_stat {__u16 qs_iwarnlimit; }; -asmlinkage long sys32_quotactl (unsigned int cmd,const char __user *special, -qid_t id,void __user *addr) +COMPAT_SYSCALL_DEFINE4(quotactl32, unsigned int, cmd, + const char __user *, special, qid_t, id, + void __user *, addr) {unsigned int cmds;struct if_dqblk __user *dqblk;
include/linux/compat.h +3 -0
@@ -461,6 +461,9 @@ asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,const struct compat_iovec __user *vec, compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); +asmlinkage long compat_sys_quotactl32 (unsigned int cmd, +const char __user *special,qid_t id,void __user *addr); +#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 asmlinkage long compat_sys_preadv64(unsigned long fd, const struct compat_iovec __user *vec,
include/linux/syscalls.h +1 -3
@@ -241,8 +241,6 @@ static inline void addr_limit_user_check(void)#endif } -asmlinkage long sys32_quotactl (unsigned int cmd,const char __user *special, -qid_t id,void __user *addr);asmlinkage long sys_time (time_t __user *tloc);asmlinkage long sys_stime (time_t __user *tptr); asmlinkage long sys_gettimeofday(struct timeval __user *tv,
@@ -625,7 +623,7 @@ asmlinkage long sys_chdir(const char __user *filename);asmlinkage long sys_fchdir (unsigned int fd);asmlinkage long sys_rmdir (const char __user *pathname);asmlinkage long sys_lookup_dcookie (u64 cookie64,char __user *buf,size_t len); -asmlinkage long sys_quotactl (unsigned int cmd,const char __user *special, +asmlinkage long sys_quotactl32 (unsigned int cmd,const char __user *special,qid_t id,void __user *addr); asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user *dirent,
kernel/sys_ni.c +1 -1
@@ -18,7 +18,7 @@ asmlinkage long sys_ni_syscall(void) }cond_syscall (sys_quotactl); -cond_syscall (sys32_quotactl); +cond_syscall (compat_sys_quotactl32);cond_syscall (sys_acct);cond_syscall (sys_lookup_dcookie);cond_syscall (compat_sys_lookup_dcookie);
Signature · 1 line
2.16.2
PATCH 20/45 kernel: add do_compat_sigaltstack() helper; remove in-kernel call to compat syscall
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel call to the compat_sys_sigaltstack() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/signal.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
kernel/signal.c +10 -4
@@ -3573,9 +3573,8 @@ int __save_altstack(stack_t __user *uss, unsigned long sp) }#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE2 (sigaltstack, - const compat_stack_t __user *, uss_ptr, - compat_stack_t __user *, uoss_ptr) +static int do_compat_sigaltstack (const compat_stack_t __user *uss_ptr, +compat_stack_t __user *uoss_ptr) {stack_t uss, uoss;int ret;
@@ -3602,9 +3601,16 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,return ret; } +COMPAT_SYSCALL_DEFINE2 (sigaltstack, + const compat_stack_t __user *, uss_ptr, + compat_stack_t __user *, uoss_ptr) +{ +return do_compat_sigaltstack (uss_ptr, uoss_ptr); +} +int compat_restore_altstack (const compat_stack_t __user *uss) { -int err =compat_sys_sigaltstack (uss,NULL ); +int err =do_compat_sigaltstack (uss,NULL );/* squash all but -EFAULT for now */ return err == -EFAULT ? err :0 ; }
Signature · 1 line
2.16.2
PATCH 21/45 kernel: add ksys_setsid() helper; remove in-kernel call to sys_setsid()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel call to the sys_setsid() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_setsid().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- include/linux/syscalls.h | 1 + init/do_mounts_initrd.c | 2 +- kernel/sys.c | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-)
include/linux/syscalls.h +1 -0
@@ -981,6 +981,7 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count,ssize_t ksys_pwrite64 (unsigned int fd,const char __user *buf,size_t count,loff_t pos);int ksys_fallocate (int fd,int mode,loff_t offset,loff_t len); +int ksys_setsid (void );/* * The following kernel syscall equivalents are just wrappers to fs-internal
init/do_mounts_initrd.c +1 -1
@@ -45,7 +45,7 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)ksys_chdir ("/root" );ksys_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL );ksys_chroot ("." ); -sys_setsid (); +ksys_setsid ();return 0 ; }
kernel/sys.c +6 -1
@@ -1108,7 +1108,7 @@ static void set_special_pids(struct pid *pid)change_pid (curr,PIDTYPE_PGID , pid); } -SYSCALL_DEFINE0 (setsid) +int ksys_setsid (void ) {struct task_struct *group_leader = current->group_leader;struct pid *sid =task_pid (group_leader);
@@ -1141,6 +1141,11 @@ SYSCALL_DEFINE0(setsid)return err; } +SYSCALL_DEFINE0 (setsid) +{ +return ksys_setsid (); +} +DECLARE_RWSEM (uts_sem);#ifdef COMPAT_UTS_MACHINE
Signature · 1 line
2.16.2
PATCH 22/45 kernel: provide ksys_*() wrappers for syscalls called by kernel/uid16.c
In reply to Dominik BrodowskiUsing these helpers allows us to avoid the in-kernel calls to these
syscalls: sys_setregid(), sys_setgid(), sys_setreuid(), sys_setuid(), sys_setresuid(), sys_setresgid(), sys_setfsuid(), and sys_setfsgid().
The ksys_ prefix denotes that these function are meant as a drop-in replacement for the syscall. In particular, they use the same calling convention.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/sys.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- kernel/uid16.c | 19 ++++++++++--------- kernel/uid16.h | 14 ++++++++++++++ 3 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 kernel/uid16.h
kernel/sys.c +50 -8
@@ -69,6 +69,8 @@#include <asm/io.h> #include <asm/unistd.h> +#include "uid16.h" +#ifndef SET_UNALIGN_CTL # define SET_UNALIGN_CTL (a, b) (-EINVAL)#endif
@@ -340,7 +342,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)* operations (as far as semantic preservation is concerned). */ #ifdef CONFIG_MULTIUSER -SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid) +long __sys_setregid (gid_t rgid,gid_t egid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -392,12 +394,17 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)return retval; } +SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid) +{ +return __sys_setregid (rgid, egid); +} +/* * setgid() is implemented like SysV w/ SAVED_IDS * * SMP: Same implicit races as above. */ -SYSCALL_DEFINE1(setgid, gid_t, gid) +long __sys_setgid (gid_t gid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -429,6 +436,11 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)return retval; } +SYSCALL_DEFINE1(setgid, gid_t, gid) +{ +return __sys_setgid (gid); +} +/* * change the user struct in a credentials set to match the new UID */
@@ -473,7 +485,7 @@ static int set_user(struct cred *new)* 100% compatible with BSD. A program which uses just setuid() will be * 100% compatible with POSIX with saved IDs. */ -SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) +long __sys_setreuid (uid_t ruid,uid_t euid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -533,6 +545,11 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)return retval; } +SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) +{ +return __sys_setreuid (ruid, euid); +} +/* * setuid() is implemented like SysV with SAVED_IDS *
@@ -544,7 +561,7 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)* will allow a root program to temporarily drop privileges and be able to * regain them by swapping the real and effective uid. */ -SYSCALL_DEFINE1(setuid, uid_t, uid) +long __sys_setuid (uid_t uid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -586,12 +603,17 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)return retval; } +SYSCALL_DEFINE1(setuid, uid_t, uid) +{ +return __sys_setuid (uid); +} +/* * This function implements a generic ability to update ruid, euid, * and suid. This allows you to implement the 4.4 compatible seteuid(). */ -SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) +long __sys_setresuid (uid_t ruid,uid_t euid,uid_t suid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -656,6 +678,11 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)return retval; } +SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) +{ +return __sys_setresuid (ruid, euid, suid); +} + SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t __user *, suidp) {const struct cred *cred =current_cred ();
@@ -678,7 +705,7 @@ SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t _/* * Same as above, but for rgid, egid, sgid. */ -SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) +long __sys_setresgid (gid_t rgid,gid_t egid,gid_t sgid) {struct user_namespace *ns =current_user_ns ();const struct cred *old;
@@ -730,6 +757,11 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)return retval; } +SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) +{ +return __sys_setresgid (rgid, egid, sgid); +} + SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t __user *, sgidp) {const struct cred *cred =current_cred ();
@@ -757,7 +789,7 @@ SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t _* whatever uid it wants to). It normally shadows "euid", except when * explicitly set by setfsuid() or for access.. */ -SYSCALL_DEFINE1(setfsuid, uid_t, uid) +long __sys_setfsuid (uid_t uid) {const struct cred *old;struct cred *new;
@@ -793,10 +825,15 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)return old_fsuid; } +SYSCALL_DEFINE1(setfsuid, uid_t, uid) +{ +return __sys_setfsuid (uid); +} +/* * Samma på svenska.. */ -SYSCALL_DEFINE1(setfsgid, gid_t, gid) +long __sys_setfsgid (gid_t gid) {const struct cred *old;struct cred *new;
@@ -830,6 +867,11 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)commit_creds (new);return old_fsgid; } + +SYSCALL_DEFINE1(setfsgid, gid_t, gid) +{ + return __sys_setfsgid(gid); +}#endif /* CONFIG_MULTIUSER */ /**
kernel/uid16.c +10 -9
@@ -18,6 +18,8 @@#include <linux/uaccess.h> +#include "uid16.h" + SYSCALL_DEFINE3(chown16, const char __user *, filename, old_uid_t, user, old_gid_t, group) {return ksys_chown (filename,low2highuid (user),low2highgid (group));
@@ -35,27 +37,27 @@ SYSCALL_DEFINE3(fchown16, unsigned int, fd, old_uid_t, user, old_gid_t, group) SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid) { -return sys_setregid (low2highgid (rgid),low2highgid (egid)); +return __sys_setregid (low2highgid (rgid),low2highgid (egid)); } SYSCALL_DEFINE1(setgid16, old_gid_t, gid) { -return sys_setgid (low2highgid (gid)); +return __sys_setgid (low2highgid (gid)); } SYSCALL_DEFINE2(setreuid16, old_uid_t, ruid, old_uid_t, euid) { -return sys_setreuid (low2highuid (ruid),low2highuid (euid)); +return __sys_setreuid (low2highuid (ruid),low2highuid (euid)); } SYSCALL_DEFINE1(setuid16, old_uid_t, uid) { -return sys_setuid (low2highuid (uid)); +return __sys_setuid (low2highuid (uid)); } SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid) { -return sys_setresuid (low2highuid (ruid),low2highuid (euid), +return __sys_setresuid (low2highuid (ruid),low2highuid (euid),low2highuid (suid)); }
@@ -78,11 +80,10 @@ SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euid SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid) { -return sys_setresgid (low2highgid (rgid),low2highgid (egid), +return __sys_setresgid (low2highgid (rgid),low2highgid (egid),low2highgid (sgid)); } - SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egidp, old_gid_t __user *, sgidp) {const struct cred *cred =current_cred ();
@@ -102,12 +103,12 @@ SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egid SYSCALL_DEFINE1(setfsuid16, old_uid_t, uid) { -return sys_setfsuid (low2highuid (uid)); +return __sys_setfsuid (low2highuid (uid)); } SYSCALL_DEFINE1(setfsgid16, old_gid_t, gid) { -return sys_setfsgid (low2highgid (gid)); +return __sys_setfsgid (low2highgid (gid)); } static int groups16_to_user(old_gid_t __user *grouplist,
kernel/uid16.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LINUX_UID16_H +#define LINUX_UID16_H + +long __sys_setuid (uid_t uid); +long __sys_setgid (gid_t gid); +long __sys_setreuid (uid_t ruid,uid_t euid); +long __sys_setregid (gid_t rgid,gid_t egid); +long __sys_setresuid (uid_t ruid,uid_t euid,uid_t suid); +long __sys_setresgid (gid_t rgid,gid_t egid,gid_t sgid); +long __sys_setfsuid (uid_t uid); +long __sys_setfsgid (gid_t gid); + +#endif /* LINUX_UID16_H */
Signature · 1 line
2.16.2
PATCH 23/45 sched: add do_sched_yield() helper; remove in-kernel call to sched_yield()
In reply to Dominik BrodowskiUsing the sched-internal do_sched_yield() helper allows us to get rid of the sched-internal call to the sys_sched_yield() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/sched/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/sched/core.c +6 -2
@@ -4892,7 +4892,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,* * Return: 0. */ -SYSCALL_DEFINE0 (sched_yield) +static void do_sched_yield (void ) {struct rq_flags rf;struct rq *rq;
@@ -4913,7 +4913,11 @@ SYSCALL_DEFINE0(sched_yield)sched_preempt_enable_no_resched ();schedule (); +} +SYSCALL_DEFINE0 (sched_yield) +{ +do_sched_yield ();return 0 ; }
@@ -4997,7 +5001,7 @@ EXPORT_SYMBOL(__cond_resched_softirq); void __sched yield(void) {set_current_state (TASK_RUNNING ); -sys_sched_yield (); +do_sched_yield (); }EXPORT_SYMBOL (yield);
Signature · 1 line
2.16.2
PATCH 24/45 kexec: call do_kexec_load() in compat syscall directly
In reply to Dominik Brodowskido_kexec_load() can be called directly by compat_sys_kexec() as long as the same parameters checks are completed which are currently handled (also) by sys_kexec(). Therefore, move those to kexec_load_check(), call that newly introduced helper function from both sys_kexec() and compat_sys_kexec(), and duplicate the remaining code from sys_kexec() in compat_sys_kexec().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/kexec.c | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-)
kernel/kexec.c +37 -13
@@ -192,11 +192,9 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,* that to happen you need to do that yourself. */ -SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, - struct kexec_segment __user *, segments, unsigned long, flags) +static inline int kexec_load_check (unsigned long nr_segments, +unsigned long flags) { -int result; -/* We only trust the superuser with rebooting the system. */ if (!capable (CAP_SYS_BOOT ) || kexec_load_disabled)return -EPERM ;
@@ -208,17 +206,29 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,if ((flags &KEXEC_FLAGS ) != (flags & ~KEXEC_ARCH_MASK ))return -EINVAL ; -/* Verify we are on the appropriate architecture */ -if (((flags &KEXEC_ARCH_MASK ) !=KEXEC_ARCH ) && - ((flags &KEXEC_ARCH_MASK ) !=KEXEC_ARCH_DEFAULT )) -return -EINVAL ; -/* Put an artificial cap on the number * of segments passed to kexec_load. */ if (nr_segments >KEXEC_SEGMENT_MAX )return -EINVAL ; +return 0 ; +} + +SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, + struct kexec_segment __user *, segments, unsigned long, flags) +{ +int result; + + result =kexec_load_check (nr_segments, flags); +if (result) +return result; + +/* Verify we are on the appropriate architecture */ +if (((flags &KEXEC_ARCH_MASK ) !=KEXEC_ARCH ) && + ((flags &KEXEC_ARCH_MASK ) !=KEXEC_ARCH_DEFAULT )) +return -EINVAL ; +/* Because we write directly to the reserved memory * region when loading crash kernels we need a mutex here to * prevent multiple crash kernels from attempting to load
@@ -247,15 +257,16 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,struct kexec_segment out,__user *ksegments;unsigned long i, result; + result =kexec_load_check (nr_segments, flags); +if (result) +return result; +/* Don't allow clients that don't understand the native * architecture to do anything. */ if ((flags &KEXEC_ARCH_MASK ) ==KEXEC_ARCH_DEFAULT )return -EINVAL ; -if (nr_segments >KEXEC_SEGMENT_MAX ) -return -EINVAL ; - ksegments =compat_alloc_user_space (nr_segments *sizeof (out));for (i =0 ; i < nr_segments; i++) { result =copy_from_user (&in, &segments[i],sizeof (in));
@@ -272,6 +283,19 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry, return -EFAULT; } -return sys_kexec_load (entry, nr_segments, ksegments, flags); +/* Because we write directly to the reserved memory +* region when loading crash kernels we need a mutex here to +* prevent multiple crash kernels from attempting to load +* simultaneously, and to prevent a crash kernel from loading +* over the top of a in use crash kernel. +* +* KISS: always take the mutex. +*/ +if (!mutex_trylock (&kexec_mutex)) +return -EBUSY ; + + result =do_kexec_load (entry, nr_segments, ksegments, flags); + +mutex_unlock (&kexec_mutex); }#endif
Signature · 1 line
2.16.2
PATCH 25/45 mm: add kernel_migrate_pages() helper, move compat syscall to mm/mempolicy.c
In reply to Dominik BrodowskiMove compat_sys_migrate_pages() to mm/mempolicy.c and make it call a newly introduced helper -- kernel_migrate_pages() -- instead of the syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/compat.c | 33 --------------------------------- mm/mempolicy.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 37 deletions(-)
kernel/compat.c +0 -33
@@ -508,39 +508,6 @@ COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages, }return sys_move_pages (pid, nr_pages, pages, nodes, status, flags); } - -COMPAT_SYSCALL_DEFINE4 (migrate_pages, compat_pid_t, pid, - compat_ulong_t, maxnode, - const compat_ulong_t __user *, old_nodes, - const compat_ulong_t __user *, new_nodes) -{ -unsigned long __user *old =NULL ; -unsigned long __user *new =NULL ; -nodemask_t tmp_mask; -unsigned long nr_bits; -unsigned long size; - - nr_bits = min_t(unsigned long, maxnode - 1, MAX_NUMNODES); - size =ALIGN (nr_bits,BITS_PER_LONG ) /8 ; -if (old_nodes) { -if (compat_get_bitmap (nodes_addr (tmp_mask), old_nodes, nr_bits)) -return -EFAULT ; - old =compat_alloc_user_space (new_nodes ? size *2 : size); -if (new_nodes) - new = old + size /sizeof (unsigned long ); -if (copy_to_user (old,nodes_addr (tmp_mask), size)) -return -EFAULT ; - } -if (new_nodes) { -if (compat_get_bitmap (nodes_addr (tmp_mask), new_nodes, nr_bits)) -return -EFAULT ; -if (new ==NULL ) - new =compat_alloc_user_space (size); -if (copy_to_user (new,nodes_addr (tmp_mask), size)) -return -EFAULT ; - } -return sys_migrate_pages (pid, nr_bits +1 , old, new); -}#endif /*
mm/mempolicy.c +44 -4
66 lines not on this page · raw message
Signature · 1 line
2.16.2
PATCH 26/45 mm: add kernel_move_pages() helper, move compat syscall to mm/migrate.c
In reply to Dominik BrodowskiMove compat_sys_move_pages() to mm/migrate.c and make it call a newly introduced helper -- kernel_move_pages() -- instead of the syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- kernel/compat.c | 22 ---------------------- mm/migrate.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 26 deletions(-)
kernel/compat.c +0 -22
@@ -488,28 +488,6 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat) }EXPORT_SYMBOL_GPL (get_compat_sigset); -#ifdef CONFIG_NUMA -COMPAT_SYSCALL_DEFINE6 (move_pages, pid_t, pid, compat_ulong_t, nr_pages, - compat_uptr_t __user *, pages32, - const int __user *, nodes, - int __user *, status, - int, flags) -{ -const void __user *__user *pages; -int i; - - pages =compat_alloc_user_space (nr_pages *sizeof (void *)); -for (i =0 ; i < nr_pages; i++) { -compat_uptr_t p; - -if (get_user (p, pages32 + i) || -put_user (compat_ptr (p), pages + i)) -return -EFAULT ; - } -return sys_move_pages (pid, nr_pages, pages, nodes, status, flags); -} -#endif -/* * Allocate user-space memory for the duration of a single system call, * in order to marshall parameters inside a compat thunk.
mm/migrate.c +35 -4
@@ -34,6 +34,7 @@#include <linux/backing-dev.h> #include <linux/compaction.h> #include <linux/syscalls.h> +#include <linux/compat.h> #include <linux/hugetlb.h> #include <linux/hugetlb_cgroup.h> #include <linux/gfp.h>
@@ -1745,10 +1746,10 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,* Move a list of pages in the address space of the currently executing * process. */ -SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, - const void __user * __user *, pages, - const int __user *, nodes, - int __user *, status, int, flags) +static int kernel_move_pages (pid_t pid,unsigned long nr_pages, +const void __user *__user *pages, +const int __user *nodes, +int __user *status,int flags) {struct task_struct *task;struct mm_struct *mm;
@@ -1807,6 +1808,36 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,return err; } +SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, + const void __user * __user *, pages, + const int __user *, nodes, + int __user *, status, int, flags) +{ +return kernel_move_pages (pid, nr_pages, pages, nodes, status, flags); +} + +#ifdef CONFIG_COMPAT +COMPAT_SYSCALL_DEFINE6 (move_pages, pid_t, pid, compat_ulong_t, nr_pages, + compat_uptr_t __user *, pages32, + const int __user *, nodes, + int __user *, status, + int, flags) +{ +const void __user *__user *pages; +int i; + + pages =compat_alloc_user_space (nr_pages *sizeof (void *)); +for (i =0 ; i < nr_pages; i++) { +compat_uptr_t p; + +if (get_user (p, pages32 + i) || +put_user (compat_ptr (p), pages + i)) +return -EFAULT ; + } +return kernel_move_pages (pid, nr_pages, pages, nodes, status, flags); +} +#endif /* CONFIG_COMPAT */ +#ifdef CONFIG_NUMA_BALANCING /* * Returns true if this is a safe migration target node for misplaced NUMA
Signature · 1 line
2.16.2
PATCH 27/45 mm: add kernel_mbind() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiUsing the mm-internal kernel_mbind() helper allows us to get rid of the mm-internal call to the sys_mbind() syscall.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- mm/mempolicy.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
mm/mempolicy.c +11 -4
@@ -1336,9 +1336,9 @@ static int copy_nodes_to_user(unsigned long __user *mask, unsigned long maxnode,return copy_to_user (mask,nodes_addr (*nodes), copy) ? -EFAULT :0 ; } -SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len, - unsigned long, mode, const unsigned long __user *, nmask, - unsigned long, maxnode, unsigned, flags) +static long kernel_mbind (unsigned long start,unsigned long len, +unsigned long mode,const unsigned long __user *nmask, +unsigned long maxnode,unsigned int flags) {nodemask_t nodes;int err;
@@ -1357,6 +1357,13 @@ SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len,return do_mbind (start, len, mode, mode_flags, &nodes, flags); } +SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len, + unsigned long, mode, const unsigned long __user *, nmask, + unsigned long, maxnode, unsigned int, flags) +{ +return kernel_mbind (start, len, mode, nmask, maxnode, flags); +} +/* Set the process memory policy */ SYSCALL_DEFINE3(set_mempolicy, int, mode, const unsigned long __user *, nmask, unsigned long, maxnode)
@@ -1575,7 +1582,7 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,return -EFAULT ; } -return sys_mbind (start, len, mode, nm, nr_bits+1 , flags); +return kernel_mbind (start, len, mode, nm, nr_bits+1 , flags); } COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
Signature · 1 line
2.16.2
PATCH 28/45 mm: add kernel_[sg]et_mempolicy() helpers; remove in-kernel calls to syscalls
In reply to Dominik BrodowskiUsing the mm-internal kernel_[sg]et_mempolicy() helper allows us to get rid of the mm-internal calls to the sys_[sg]et_mempolicy() syscalls.
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- mm/mempolicy.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
mm/mempolicy.c +22 -7
@@ -1365,8 +1365,8 @@ SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len, }/* Set the process memory policy */ -SYSCALL_DEFINE3(set_mempolicy, int, mode, const unsigned long __user *, nmask, - unsigned long, maxnode) +static long kernel_set_mempolicy (int mode,const unsigned long __user *nmask, +unsigned long maxnode) {int err;nodemask_t nodes;
@@ -1384,6 +1384,12 @@ SYSCALL_DEFINE3(set_mempolicy, int, mode, const unsigned long __user *, nmask,return do_set_mempolicy (mode, flags, &nodes); } +SYSCALL_DEFINE3(set_mempolicy, int, mode, const unsigned long __user *, nmask, + unsigned long, maxnode) +{ +return kernel_set_mempolicy (mode, nmask, maxnode); +} +static int kernel_migrate_pages (pid_t pid,unsigned long maxnode,const unsigned long __user *old_nodes,const unsigned long __user *new_nodes)
@@ -1485,9 +1491,11 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,/* Retrieve NUMA policy */ -SYSCALL_DEFINE5(get_mempolicy, int __user *, policy, - unsigned long __user *, nmask, unsigned long, maxnode, - unsigned long, addr, unsigned long, flags) +static int kernel_get_mempolicy (int __user *policy, +unsigned long __user *nmask, +unsigned long maxnode, +unsigned long addr, +unsigned long flags) {int err;int uninitialized_var (pval );
@@ -1510,6 +1518,13 @@ SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,return err; } +SYSCALL_DEFINE5(get_mempolicy, int __user *, policy, + unsigned long __user *, nmask, unsigned long, maxnode, + unsigned long, addr, unsigned long, flags) +{ +return kernel_get_mempolicy (policy, nmask, maxnode, addr, flags); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
@@ -1528,7 +1543,7 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,if (nmask) nm =compat_alloc_user_space (alloc_size); - err =sys_get_mempolicy (policy, nm, nr_bits+1 , addr, flags); + err =kernel_get_mempolicy (policy, nm, nr_bits+1 , addr, flags);if (!err && nmask) {unsigned long copy_size;
@@ -1560,7 +1575,7 @@ COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask,return -EFAULT ; } -return sys_set_mempolicy (mode, nm, nr_bits+1 ); +return kernel_set_mempolicy (mode, nm, nr_bits+1 ); } COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
Signature · 1 line
2.16.2
PATCH 29/45 mm: add ksys_readahead() helper; remove in-kernel calls to sys_readahead()
In reply to Dominik BrodowskiUsing this helper allows us to avoid the in-kernel calls to the sys_readahead() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_readahead().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/mips/kernel/linux32.c | 2 +- arch/parisc/kernel/sys_parisc.c | 2 +- arch/powerpc/kernel/sys_ppc32.c | 2 +- arch/s390/kernel/compat_linux.c | 2 +- arch/sparc/kernel/sys_sparc32.c | 2 +- arch/x86/ia32/sys_ia32.c | 2 +- include/linux/syscalls.h | 1 + mm/readahead.c | 7 ++++++- 8 files changed, 13 insertions(+), 7 deletions(-)
arch/mips/kernel/linux32.c +1 -1
@@ -131,7 +131,7 @@ SYSCALL_DEFINE1(32_personality, unsigned long, personality) asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,size_t count) { -return sys_readahead (fd,merge_64 (a2, a3), count); +return ksys_readahead (fd,merge_64 (a2, a3), count); } asmlinkage long sys32_sync_file_range(int fd, int __pad,
arch/parisc/kernel/sys_parisc.c +1 -1
@@ -345,7 +345,7 @@ asmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf, asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,size_t count) { -return sys_readahead (fd, (loff_t )high <<32 | low, count); +return ksys_readahead (fd, (loff_t )high <<32 | low, count); } asmlinkage long parisc_fadvise64_64(int fd,
arch/powerpc/kernel/sys_ppc32.c +1 -1
@@ -88,7 +88,7 @@ compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, comcompat_ssize_t compat_sys_readahead (int fd,u32 r4,u32 offhi,u32 offlo,u32 count) { -return sys_readahead (fd, ((loff_t )offhi <<32 ) | offlo, count); +return ksys_readahead (fd, ((loff_t )offhi <<32 ) | offlo, count); } asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
arch/s390/kernel/compat_linux.c +1 -1
@@ -328,7 +328,7 @@ COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned int, fd, const char __user *, ubu COMPAT_SYSCALL_DEFINE4(s390_readahead, int, fd, u32, high, u32, low, s32, count) { -return sys_readahead (fd, (unsigned long )high <<32 | low, count); +return ksys_readahead (fd, (unsigned long )high <<32 | low, count); }struct stat64_emu31 {
arch/sparc/kernel/sys_sparc32.c +1 -1
@@ -217,7 +217,7 @@ asmlinkage long compat_sys_readahead(int fd, unsigned long offlo, compat_size_t count) { -return sys_readahead (fd, (offhi <<32 ) | offlo, count); +return ksys_readahead (fd, (offhi <<32 ) | offlo, count); } long compat_sys_fadvise64(int fd,
arch/x86/ia32/sys_ia32.c +1 -1
@@ -208,7 +208,7 @@ COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low, COMPAT_SYSCALL_DEFINE4(x86_readahead, int, fd, unsigned int, off_lo, unsigned int, off_hi, size_t, count) { -return sys_readahead (fd, ((u64 )off_hi <<32 ) | off_lo, count); +return ksys_readahead (fd, ((u64 )off_hi <<32 ) | off_lo, count); } COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
include/linux/syscalls.h +1 -0
@@ -982,6 +982,7 @@ ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf, size_t count, loff_t pos);int ksys_fallocate (int fd,int mode,loff_t offset,loff_t len);int ksys_setsid (void ); +ssize_t ksys_readahead (int fd,loff_t offset,size_t count);/* * The following kernel syscall equivalents are just wrappers to fs-internal
mm/readahead.c +6 -1
@@ -573,7 +573,7 @@ do_readahead(struct address_space *mapping, struct file *filp,return force_page_cache_readahead (mapping, filp, index, nr); } -SYSCALL_DEFINE3(readahead, int, fd, loff_t, offset, size_t, count) +ssize_t ksys_readahead (int fd,loff_t offset,size_t count) {ssize_t ret;struct fd f;
@@ -592,3 +592,8 @@ SYSCALL_DEFINE3(readahead, int, fd, loff_t, offset, size_t, count) }return ret; } + +SYSCALL_DEFINE3(readahead, int, fd, loff_t, offset, size_t, count) +{ +return ksys_readahead (fd, offset, count); +}
Signature · 1 line
2.16.2
PATCH 30/45 ipc: add semtimedop syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_semtimedop() and compat_ksys_semtimedop() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_semtimedop() and compat_sys_semtimedop().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/sem.c | 23 ++++++++++++++++++----- ipc/syscall.c | 17 ++++++++++------- ipc/util.h | 13 +++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-)
ipc/sem.c +18 -5
@@ -2120,8 +2120,8 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,return error; } -SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, - unsigned, nsops, const struct timespec __user *, timeout) +long ksys_semtimedop (int semid,struct sembuf __user *tsops, +unsigned int nsops,const struct timespec __user *timeout) {if (timeout) {struct timespec64 ts;
@@ -2132,10 +2132,16 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,return do_semtimedop (semid, tsops, nsops,NULL ); } +SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, + unsigned int, nsops, const struct timespec __user *, timeout) +{ +return ksys_semtimedop (semid, tsops, nsops, timeout); +} +#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, - unsigned, nsops, - const struct compat_timespec __user *, timeout) +long compat_ksys_semtimedop (int semid,struct sembuf __user *tsems, +unsigned int nsops, +const struct compat_timespec __user *timeout) {if (timeout) {struct timespec64 ts;
@@ -2145,6 +2151,13 @@ COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, }return do_semtimedop (semid, tsems, nsops,NULL ); } + +COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, + unsigned int, nsops, + const struct compat_timespec __user *, timeout) +{ +return compat_ksys_semtimedop (semid, tsems, nsops, timeout); +}#endif SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops,
ipc/syscall.c +10 -7
@@ -7,6 +7,9 @@*/ #include <linux/unistd.h> #include <linux/syscalls.h> +#include <linux/security.h> +#include <linux/ipc_namespace.h> +#include "util.h" #ifdef __ARCH_WANT_SYS_IPC#include <linux/errno.h>
@@ -24,12 +27,12 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,switch (call) {case SEMOP : -return sys_semtimedop (first, (struct sembuf __user *)ptr, - second,NULL ); +return ksys_semtimedop (first, (struct sembuf __user *)ptr, + second,NULL );case SEMTIMEDOP : -return sys_semtimedop (first, (struct sembuf __user *)ptr, - second, - (const struct timespec __user *)fifth); +return ksys_semtimedop (first, (struct sembuf __user *)ptr, + second, + (const struct timespec __user *)fifth);case SEMGET :return sys_semget (first, second, third);
@@ -124,9 +127,9 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,switch (call) {case SEMOP :/* struct sembuf is the same on 32 and 64bit :)) */ -return sys_semtimedop (first,compat_ptr (ptr), second,NULL ); +return ksys_semtimedop (first,compat_ptr (ptr), second,NULL );case SEMTIMEDOP : -return compat_sys_semtimedop (first,compat_ptr (ptr), second, +return compat_ksys_semtimedop (first,compat_ptr (ptr), second,compat_ptr (fifth));case SEMGET :return sys_semget (first, second, third);
ipc/util.h +13 -0
@@ -235,4 +235,17 @@ static inline int compat_ipc_parse_version(int *cmd)#endif }#endif + +/* for __ARCH_WANT_SYS_IPC */ +long ksys_semtimedop (int semid,struct sembuf __user *tsops, +unsigned int nsops, +const struct timespec __user *timeout); + +/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ +#ifdef CONFIG_COMPAT +long compat_ksys_semtimedop (int semid,struct sembuf __user *tsems, +unsigned int nsops, +const struct compat_timespec __user *timeout); +#endif /* CONFIG_COMPAT */ +#endif
Signature · 1 line
2.16.2
PATCH 31/45 ipc: add semget syscall wrapper
In reply to Dominik BrodowskiProvide ksys_semget() wrapper to avoid in-kernel calls to this syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_semget().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/sem.c | 7 ++++++- ipc/syscall.c | 4 ++-- ipc/util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
ipc/sem.c +6 -1
@@ -556,7 +556,7 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,return 0 ; } -SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) +long ksys_semget (key_t key,int nsems,int semflg) {struct ipc_namespace *ns;static const struct ipc_ops sem_ops = {
@@ -578,6 +578,11 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)return ipcget (ns, &sem_ids (ns), &sem_ops, &sem_params); } +SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg) +{ +return ksys_semget (key, nsems, semflg); +} +/** * perform_atomic_semop[_slow] - Attempt to perform semaphore * operations on a given array.
ipc/syscall.c +2 -2
@@ -35,7 +35,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, (const struct timespec __user *)fifth);case SEMGET : -return sys_semget (first, second, third); +return ksys_semget (first, second, third);case SEMCTL : {unsigned long arg;if (!ptr)
@@ -132,7 +132,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return compat_ksys_semtimedop (first,compat_ptr (ptr), second,compat_ptr (fifth));case SEMGET : -return sys_semget (first, second, third); +return ksys_semget (first, second, third);case SEMCTL :if (!ptr)return -EINVAL ;
ipc/util.h +1 -0
@@ -240,6 +240,7 @@ static inline int compat_ipc_parse_version(int *cmd)long ksys_semtimedop (int semid,struct sembuf __user *tsops,unsigned int nsops,const struct timespec __user *timeout); +long ksys_semget (key_t key,int nsems,int semflg);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT
Signature · 1 line
2.16.2
PATCH 32/45 ipc: add semctl syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_semctl() and compat_ksys_semctl() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_semctl() and compat_sys_semctl().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/sem.c | 14 ++++++++++++-- ipc/syscall.c | 4 ++-- ipc/util.h | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-)
ipc/sem.c +12 -2
@@ -1581,7 +1581,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid,return err; } -SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, unsigned long, arg) +long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg) {int version;struct ipc_namespace *ns;
@@ -1635,6 +1635,11 @@ SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, unsigned long, arg) } } +SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, unsigned long, arg) +{ +return ksys_semctl (semid, semnum, cmd, arg); +} +#ifdef CONFIG_COMPAT struct compat_semid_ds {
@@ -1683,7 +1688,7 @@ static int copy_compat_semid_to_user(void __user *buf, struct semid64_ds *in, } } -COMPAT_SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, int, arg) +long compat_ksys_semctl (int semid,int semnum,int cmd,int arg) {void __user *p =compat_ptr (arg);struct ipc_namespace *ns;
@@ -1727,6 +1732,11 @@ COMPAT_SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, int, arg) return -EINVAL; } } + +COMPAT_SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, int, arg) +{ +return compat_ksys_semctl (semid, semnum, cmd, arg); +}#endif /* If the task doesn't already have a undo_list, then allocate one
ipc/syscall.c +2 -2
@@ -42,7 +42,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,return -EINVAL ;if (get_user (arg, (unsigned long __user *) ptr))return -EFAULT ; -return sys_semctl (first, second, third, arg); +return ksys_semctl (first, second, third, arg); }case MSGSND :
@@ -138,7 +138,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return -EINVAL ;if (get_user (pad, (u32 __user *)compat_ptr (ptr)))return -EFAULT ; -return compat_sys_semctl (first, second, third, pad); +return compat_ksys_semctl (first, second, third, pad);case MSGSND :return compat_sys_msgsnd (first, ptr, second, third);
ipc/util.h +2 -0
@@ -241,12 +241,14 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,unsigned int nsops, const struct timespec __user *timeout);long ksys_semget (key_t key,int nsems,int semflg); +long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT long compat_ksys_semtimedop (int semid,struct sembuf __user *tsems,unsigned int nsops,const struct compat_timespec __user *timeout); +long compat_ksys_semctl (int semid,int semnum,int cmd,int arg);#endif /* CONFIG_COMPAT */ #endif
Signature · 1 line
2.16.2
PATCH 33/45 ipc: add msgget syscall wrapper
In reply to Dominik BrodowskiProvide ksys_msgget() wrapper to avoid in-kernel calls to this syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_msgget().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/msg.c | 7 ++++++- ipc/syscall.c | 4 ++-- ipc/util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
ipc/msg.c +6 -1
@@ -263,7 +263,7 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)return security_msg_queue_associate (msq, msgflg); } -SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg) +long ksys_msgget (key_t key,int msgflg) {struct ipc_namespace *ns;static const struct ipc_ops msg_ops = {
@@ -280,6 +280,11 @@ SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)return ipcget (ns, &msg_ids (ns), &msg_ops, &msg_params); } +SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg) +{ +return ksys_msgget (key, msgflg); +} +static inline unsigned long copy_msqid_to_user (void __user *buf,struct msqid64_ds *in,int version) {
ipc/syscall.c +2 -2
@@ -68,7 +68,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, second, fifth, third); }case MSGGET : -return sys_msgget ((key_t ) first, second); +return ksys_msgget ((key_t ) first, second);case MSGCTL :return sys_msgctl (first, second, (struct msqid_ds __user *)ptr);
@@ -161,7 +161,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return compat_sys_msgrcv (first, ptr, second, fifth, third); }case MSGGET : -return sys_msgget (first, second); +return ksys_msgget (first, second);case MSGCTL :return compat_sys_msgctl (first, second,compat_ptr (ptr));
ipc/util.h +1 -0
@@ -242,6 +242,7 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops, const struct timespec __user *timeout);long ksys_semget (key_t key,int nsems,int semflg);long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg); +long ksys_msgget (key_t key,int msgflg);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT
Signature · 1 line
2.16.2
PATCH 34/45 ipc: add shmget syscall wrapper
In reply to Dominik BrodowskiProvide ksys_shmget() wrapper to avoid in-kernel calls to this syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_shmget().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/shm.c | 7 ++++++- ipc/syscall.c | 4 ++-- ipc/util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
ipc/shm.c +6 -1
@@ -656,7 +656,7 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,return 0 ; } -SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg) +long ksys_shmget (key_t key,size_t size,int shmflg) {struct ipc_namespace *ns;static const struct ipc_ops shm_ops = {
@@ -675,6 +675,11 @@ SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)return ipcget (ns, &shm_ids (ns), &shm_ops, &shm_params); } +SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg) +{ +return ksys_shmget (key, size, shmflg); +} +static inline unsigned long copy_shmid_to_user (void __user *buf,struct shmid64_ds *in,int version) {switch (version) {
ipc/syscall.c +2 -2
@@ -92,7 +92,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,case SHMDT :return sys_shmdt ((char __user *)ptr);case SHMGET : -return sys_shmget (first, second, third); +return ksys_shmget (first, second, third);case SHMCTL :return sys_shmctl (first, second, (struct shmid_ds __user *) ptr);
@@ -180,7 +180,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,case SHMDT :return sys_shmdt (compat_ptr (ptr));case SHMGET : -return sys_shmget (first, (unsigned )second, third); +return ksys_shmget (first, (unsigned int )second, third);case SHMCTL :return compat_sys_shmctl (first, second,compat_ptr (ptr)); }
ipc/util.h +1 -0
@@ -243,6 +243,7 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,long ksys_semget (key_t key,int nsems,int semflg);long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg);long ksys_msgget (key_t key,int msgflg); +long ksys_shmget (key_t key,size_t size,int shmflg);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT
Signature · 1 line
2.16.2
PATCH 35/45 ipc: add shmdt syscall wrapper
In reply to Dominik BrodowskiProvide ksys_shmdt() wrapper to avoid in-kernel calls to this syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_shmdt().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/shm.c | 7 ++++++- ipc/syscall.c | 4 ++-- ipc/util.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
ipc/shm.c +6 -1
@@ -1481,7 +1481,7 @@ COMPAT_SYSCALL_DEFINE3(shmat, int, shmid, compat_uptr_t, shmaddr, int, shmflg)* detach and kill segment if marked destroyed. * The work is done in shm_close. */ -SYSCALL_DEFINE1(shmdt, char __user *, shmaddr) +long ksys_shmdt (char __user *shmaddr) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma;
@@ -1588,6 +1588,11 @@ SYSCALL_DEFINE1(shmdt, char __user *, shmaddr)return retval; } +SYSCALL_DEFINE1(shmdt, char __user *, shmaddr) +{ +return ksys_shmdt (shmaddr); +} +#ifdef CONFIG_PROC_FS static int sysvipc_shm_proc_show (struct seq_file *s,void *it) {
ipc/syscall.c +2 -2
@@ -90,7 +90,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,return -EINVAL ; }case SHMDT : -return sys_shmdt ((char __user *)ptr); +return ksys_shmdt ((char __user *)ptr);case SHMGET :return ksys_shmget (first, second, third);case SHMCTL :
@@ -178,7 +178,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return put_user (raddr, (compat_ulong_t __user *)compat_ptr (third)); }case SHMDT : -return sys_shmdt (compat_ptr (ptr)); +return ksys_shmdt (compat_ptr (ptr));case SHMGET :return ksys_shmget (first, (unsigned int )second, third);case SHMCTL :
ipc/util.h +1 -0
@@ -244,6 +244,7 @@ long ksys_semget(key_t key, int nsems, int semflg);long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg);long ksys_msgget (key_t key,int msgflg);long ksys_shmget (key_t key,size_t size,int shmflg); +long ksys_shmdt (char __user *shmaddr);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT
Signature · 1 line
2.16.2
PATCH 36/45 ipc: add shmctl syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_shmctl() and compat_ksys_shmctl() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_shmctl() and compat_sys_shmctl().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/shm.c | 14 ++++++++++++-- ipc/syscall.c | 4 ++-- ipc/util.h | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-)
ipc/shm.c +12 -2
@@ -1045,7 +1045,7 @@ static int shmctl_do_lock(struct ipc_namespace *ns, int shmid, int cmd)return err; } -SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) +long ksys_shmctl (int shmid,int cmd,struct shmid_ds __user *buf) {int err, version;struct ipc_namespace *ns;
@@ -1099,6 +1099,11 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) } } +SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) +{ +return ksys_shmctl (shmid, cmd, buf); +} +#ifdef CONFIG_COMPAT struct compat_shmid_ds {
@@ -1218,7 +1223,7 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf, } } -COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) +long compat_ksys_shmctl (int shmid,int cmd,void __user *uptr) {struct ipc_namespace *ns;struct shmid64_ds sem64;
@@ -1273,6 +1278,11 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) }return err; } + +COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) +{ +return compat_ksys_shmctl (shmid, cmd, uptr); +}#endif /*
ipc/syscall.c +2 -2
@@ -94,7 +94,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,case SHMGET :return ksys_shmget (first, second, third);case SHMCTL : -return sys_shmctl (first, second, +return ksys_shmctl (first, second, (struct shmid_ds __user *) ptr);default :return -ENOSYS ;
@@ -182,7 +182,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,case SHMGET :return ksys_shmget (first, (unsigned int )second, third);case SHMCTL : -return compat_sys_shmctl (first, second,compat_ptr (ptr)); +return compat_ksys_shmctl (first, second,compat_ptr (ptr)); }return -ENOSYS ;
ipc/util.h +2 -0
@@ -245,6 +245,7 @@ long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg);long ksys_msgget (key_t key,int msgflg);long ksys_shmget (key_t key,size_t size,int shmflg);long ksys_shmdt (char __user *shmaddr); +long ksys_shmctl (int shmid,int cmd,struct shmid_ds __user *buf);/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ #ifdef CONFIG_COMPAT
@@ -252,6 +253,7 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,unsigned int nsops, const struct compat_timespec __user *timeout);long compat_ksys_semctl (int semid,int semnum,int cmd,int arg); +long compat_ksys_shmctl (int shmid,int cmd,void __user *uptr);#endif /* CONFIG_COMPAT */ #endif
Signature · 1 line
2.16.2
PATCH 37/45 ipc: add msgctl syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_msgctl() and compat_ksys_msgctl() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_msgctl() and compat_sys_msgctl().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/msg.c | 14 ++++++++++++-- ipc/syscall.c | 5 +++-- ipc/util.h | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-)
ipc/msg.c +12 -2
@@ -538,7 +538,7 @@ static int msgctl_stat(struct ipc_namespace *ns, int msqid,return err; } -SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) +long ksys_msgctl (int msqid,int cmd,struct msqid_ds __user *buf) {int version;struct ipc_namespace *ns;
@@ -581,6 +581,11 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) } } +SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) +{ +return ksys_msgctl (msqid, cmd, buf); +} +#ifdef CONFIG_COMPAT struct compat_msqid_ds {
@@ -651,7 +656,7 @@ static int copy_compat_msqid_to_user(void __user *buf, struct msqid64_ds *in, } } -COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr) +long compat_ksys_msgctl (int msqid,int cmd,void __user *uptr) {struct ipc_namespace *ns;int err;
@@ -692,6 +697,11 @@ COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr) return -EINVAL; } } + +COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr) +{ +return compat_ksys_msgctl (msqid, cmd, uptr); +}#endif static int testmsg (struct msg_msg *msg,long type,int mode)
ipc/syscall.c +3 -2
@@ -70,7 +70,8 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,case MSGGET :return ksys_msgget ((key_t ) first, second);case MSGCTL : -return sys_msgctl (first, second, (struct msqid_ds __user *)ptr); +return ksys_msgctl (first, second, + (struct msqid_ds __user *)ptr);case SHMAT :switch (version) {
@@ -163,7 +164,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,case MSGGET :return ksys_msgget (first, second);case MSGCTL : -return compat_sys_msgctl (first, second,compat_ptr (ptr)); +return compat_ksys_msgctl (first, second,compat_ptr (ptr));case SHMAT : {int err;
ipc/util.h +2 -0
@@ -243,6 +243,7 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,long ksys_semget (key_t key,int nsems,int semflg);long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg);long ksys_msgget (key_t key,int msgflg); +long ksys_msgctl (int msqid,int cmd,struct msqid_ds __user *buf);long ksys_shmget (key_t key,size_t size,int shmflg);long ksys_shmdt (char __user *shmaddr);long ksys_shmctl (int shmid,int cmd,struct shmid_ds __user *buf);
@@ -253,6 +254,7 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,unsigned int nsops, const struct compat_timespec __user *timeout);long compat_ksys_semctl (int semid,int semnum,int cmd,int arg); +long compat_ksys_msgctl (int msqid,int cmd,void __user *uptr);long compat_ksys_shmctl (int shmid,int cmd,void __user *uptr);#endif /* CONFIG_COMPAT */
Signature · 1 line
2.16.2
PATCH 38/45 ipc: add msgrcv syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_msgrcv() and compat_ksys_msgrcv() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_msgrcv() and compat_sys_msgrcv().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/msg.c | 19 ++++++++++++++++--- ipc/syscall.c | 8 ++++---- ipc/util.h | 4 ++++ 3 files changed, 24 insertions(+), 7 deletions(-)
ipc/msg.c +16 -3
@@ -1150,10 +1150,16 @@ static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, inreturn bufsz; } +long ksys_msgrcv (int msqid,struct msgbuf __user *msgp,size_t msgsz, +long msgtyp,int msgflg) +{ +return do_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); +} + SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, long, msgtyp, int, msgflg) { -return do_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); +return ksys_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg); }#ifdef CONFIG_COMPAT
@@ -1171,12 +1177,19 @@ static long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bureturn msgsz; } -COMPAT_SYSCALL_DEFINE5(msgrcv, int, msqid, compat_uptr_t, msgp, - compat_ssize_t, msgsz, compat_long_t, msgtyp, int, msgflg) +long compat_ksys_msgrcv (int msqid,compat_uptr_t msgp,compat_ssize_t msgsz, +compat_long_t msgtyp,int msgflg) {return do_msgrcv (msqid,compat_ptr (msgp), (ssize_t )msgsz, (long )msgtyp, msgflg, compat_do_msg_fill); } + +COMPAT_SYSCALL_DEFINE5 (msgrcv, int, msqid, compat_uptr_t, msgp, + compat_ssize_t, msgsz, compat_long_t, msgtyp, + int, msgflg) +{ +return compat_ksys_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg); +}#endif int msg_init_ns (struct ipc_namespace *ns)
ipc/syscall.c +4 -4
@@ -59,11 +59,11 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, (struct ipc_kludge __user *) ptr, sizeof(tmp)))return -EFAULT ; -return sys_msgrcv (first, tmp.msgp, second, +return ksys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third); }default : -return sys_msgrcv (first, +return ksys_msgrcv (first, (struct msgbuf __user *) ptr, second, fifth, third); }
@@ -156,10 +156,10 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return -EINVAL ;if (copy_from_user (&ipck, uptr,sizeof (ipck)))return -EFAULT ; -return compat_sys_msgrcv (first, ipck.msgp, second, +return compat_ksys_msgrcv (first, ipck.msgp, second, ipck.msgtyp, third); } -return compat_sys_msgrcv (first, ptr, second, fifth, third); +return compat_ksys_msgrcv (first, ptr, second, fifth, third); }case MSGGET :return ksys_msgget (first, second);
ipc/util.h +4 -0
@@ -244,6 +244,8 @@ long ksys_semget(key_t key, int nsems, int semflg);long ksys_semctl (int semid,int semnum,int cmd,unsigned long arg);long ksys_msgget (key_t key,int msgflg);long ksys_msgctl (int msqid,int cmd,struct msqid_ds __user *buf); +long ksys_msgrcv (int msqid,struct msgbuf __user *msgp,size_t msgsz, +long msgtyp,int msgflg);long ksys_shmget (key_t key,size_t size,int shmflg);long ksys_shmdt (char __user *shmaddr);long ksys_shmctl (int shmid,int cmd,struct shmid_ds __user *buf);
@@ -255,6 +257,8 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems, const struct compat_timespec __user *timeout);long compat_ksys_semctl (int semid,int semnum,int cmd,int arg);long compat_ksys_msgctl (int msqid,int cmd,void __user *uptr); +long compat_ksys_msgrcv (int msqid,compat_uptr_t msgp,compat_ssize_t msgsz, +compat_long_t msgtyp,int msgflg);long compat_ksys_shmctl (int shmid,int cmd,void __user *uptr);#endif /* CONFIG_COMPAT */
Signature · 1 line
2.16.2
PATCH 39/45 ipc: add msgsnd syscall/compat_syscall wrappers
In reply to Dominik BrodowskiProvide ksys_msgsnd() and compat_ksys_msgsnd() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_msgsnd() and compat_sys_msgsnd().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- ipc/msg.c | 20 ++++++++++++++++---- ipc/syscall.c | 4 ++-- ipc/util.h | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-)
ipc/msg.c +16 -4
@@ -867,8 +867,8 @@ static long do_msgsnd(int msqid, long mtype, void __user *mtext,return err; } -SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, - int, msgflg) +long ksys_msgsnd (int msqid,struct msgbuf __user *msgp,size_t msgsz, +int msgflg) {long mtype;
@@ -877,6 +877,12 @@ SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,return do_msgsnd (msqid, mtype, msgp->mtext, msgsz, msgflg); } +SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, + int, msgflg) +{ +return ksys_msgsnd (msqid, msgp, msgsz, msgflg); +} +#ifdef CONFIG_COMPAT struct compat_msgbuf {
@@ -884,8 +890,8 @@ struct compat_msgbuf {char mtext[1 ]; }; -COMPAT_SYSCALL_DEFINE4 (msgsnd, int, msqid, compat_uptr_t, msgp, - compat_ssize_t, msgsz, int, msgflg) +long compat_ksys_msgsnd (int msqid,compat_uptr_t msgp, +compat_ssize_t msgsz,int msgflg) {struct compat_msgbuf __user *up =compat_ptr (msgp);compat_long_t mtype;
@@ -894,6 +900,12 @@ COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp,return -EFAULT ;return do_msgsnd (msqid, mtype, up->mtext, (ssize_t )msgsz, msgflg); } + +COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp, + compat_ssize_t, msgsz, int, msgflg) +{ + return compat_ksys_msgsnd(msqid, msgp, msgsz, msgflg); +}#endif static inline int convert_mode (long *msgtyp,int msgflg)
ipc/syscall.c +2 -2
@@ -46,7 +46,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, }case MSGSND : -return sys_msgsnd (first, (struct msgbuf __user *) ptr, +return ksys_msgsnd (first, (struct msgbuf __user *) ptr, second, third);case MSGRCV :switch (version) {
@@ -142,7 +142,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,return compat_ksys_semctl (first, second, third, pad);case MSGSND : -return compat_sys_msgsnd (first, ptr, second, third); +return compat_ksys_msgsnd (first, ptr, second, third);case MSGRCV : {void __user *uptr =compat_ptr (ptr);
ipc/util.h +4 -0
@@ -246,6 +246,8 @@ long ksys_msgget(key_t key, int msgflg);long ksys_msgctl (int msqid,int cmd,struct msqid_ds __user *buf);long ksys_msgrcv (int msqid,struct msgbuf __user *msgp,size_t msgsz,long msgtyp,int msgflg); +long ksys_msgsnd (int msqid,struct msgbuf __user *msgp,size_t msgsz, +int msgflg);long ksys_shmget (key_t key,size_t size,int shmflg);long ksys_shmdt (char __user *shmaddr);long ksys_shmctl (int shmid,int cmd,struct shmid_ds __user *buf);
@@ -259,6 +261,8 @@ long compat_ksys_semctl(int semid, int semnum, int cmd, int arg);long compat_ksys_msgctl (int msqid,int cmd,void __user *uptr);long compat_ksys_msgrcv (int msqid,compat_uptr_t msgp,compat_ssize_t msgsz,compat_long_t msgtyp,int msgflg); +long compat_ksys_msgsnd (int msqid,compat_uptr_t msgp, +compat_ssize_t msgsz,int msgflg);long compat_ksys_shmctl (int shmid,int cmd,void __user *uptr);#endif /* CONFIG_COMPAT */
Signature · 1 line
2.16.2
PATCH 40/45 x86: use _do_fork() in compat_sys_x86_clone()
In reply to Dominik BrodowskiIt is trivial to directly call _do_fork() instead of the sys_clone() syscall in compat_sys_x86_clone().
This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
--- arch/x86/ia32/sys_ia32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/ia32/sys_ia32.c +2 -1
@@ -41,6 +41,7 @@#include <linux/highuid.h> #include <linux/sysctl.h> #include <linux/slab.h> +#include <linux/sched/task.h> #include <asm/mman.h> #include <asm/types.h> #include <linux/uaccess.h>
@@ -242,6 +243,6 @@ COMPAT_SYSCALL_DEFINE5(x86_clone, unsigned long, clone_flags, unsigned long, newsp, int __user *, parent_tidptr, unsigned long, tls_val, int __user *, child_tidptr) { - return sys_clone(clone_flags, newsp, parent_tidptr, child_tidptr, + return _do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr,tls_val ); }
Signature · 1 line
2.16.2
PATCH 41/45 x86: remove compat_sys_x86_waitpid()
In reply to Dominik Brodowskicompat_sys_x86_waitpid() is not needed, as it takes the same parameters (int, *int, int) as the native syscall.
--- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- arch/x86/ia32/sys_ia32.c | 6 ------ arch/x86/include/asm/sys_ia32.h | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-)
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
@@ -13,7 +13,7 @@ 4 i386 write sys_write 5 i386 open sys_open compat_sys_open 6 i386 close sys_close -7 i386 waitpid sys_waitpid compat_sys_x86_waitpid +7 i386 waitpid sys_waitpid 8 i386 creat sys_creat 9 i386 link sys_link 10 i386 unlink sys_unlink
arch/x86/ia32/sys_ia32.c +0 -6
@@ -170,12 +170,6 @@ COMPAT_SYSCALL_DEFINE1(x86_mmap, struct mmap_arg_struct32 __user *, arg) a.offset>>PAGE_SHIFT); } -COMPAT_SYSCALL_DEFINE3(x86_waitpid, compat_pid_t, pid, unsigned int __user *, - stat_addr, int, options) -{ -return compat_sys_wait4 (pid, stat_addr, options,NULL ); -} -/* warning: next two assume little endian */ COMPAT_SYSCALL_DEFINE5(x86_pread, unsigned int, fd, char __user *, ubuf, u32, count, u32, poslo, u32, poshi)
arch/x86/include/asm/sys_ia32.h +0 -3
@@ -35,9 +35,6 @@ asmlinkage long compat_sys_x86_fstatat(unsigned int, const char __user *,struct mmap_arg_struct32 ;asmlinkage long compat_sys_x86_mmap (struct mmap_arg_struct32 __user *); -asmlinkage long compat_sys_x86_waitpid (compat_pid_t ,unsigned int __user *, -int ); -asmlinkage long compat_sys_x86_pread (unsigned int ,char __user *,u32 ,u32 ,u32 ); asmlinkage long compat_sys_x86_pwrite(unsigned int, const char __user *, u32,
Signature · 1 line
2.16.2
PATCH 42/45 x86: fix sys_sigreturn() return type to be long, not unsigned long
In reply to Dominik BrodowskiSame as with other system calls, sys_sigreturn() should return a value of type long, not unsigned long. This also matches the behaviour for IA32_EMULATION, see sys32_sigreturn() in arch/x86/ia32/ia32_signal.c .
--- arch/x86/include/asm/syscalls.h | 2 +- arch/x86/kernel/signal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/syscalls.h +1 -1
@@ -35,7 +35,7 @@ asmlinkage long sys_get_thread_area(struct user_desc __user *);#ifdef CONFIG_X86_32 /* kernel/signal.c */ -asmlinkage unsigned long sys_sigreturn (void ); +asmlinkage long sys_sigreturn (void );/* kernel/vm86_32.c */ struct vm86_struct ;
arch/x86/kernel/signal.c +1 -1
@@ -601,7 +601,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,* Do a signal return; undo the signal stack. */ #ifdef CONFIG_X86_32 -asmlinkage unsigned long sys_sigreturn (void ) +asmlinkage long sys_sigreturn (void ) {struct pt_regs *regs =current_pt_regs ();struct sigframe __user *frame;
Signature · 1 line
2.16.2
PATCH 43/45 x86/sigreturn: use SYSCALL_DEFINE0
In reply to Dominik BrodowskiFrom: "Tautschnig, Michael" <[email protected]>
All definitions of syscalls in x86 except for those patched here have already been using the appropriate SYSCALL_DEFINE*.
--- arch/x86/kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/signal.c +3 -2
@@ -25,6 +25,7 @@#include <linux/user-return-notifier.h> #include <linux/uprobes.h> #include <linux/context_tracking.h> +#include <linux/syscalls.h> #include <asm/processor.h> #include <asm/ucontext.h>
@@ -601,7 +602,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,* Do a signal return; undo the signal stack. */ #ifdef CONFIG_X86_32 -asmlinkage long sys_sigreturn (void ) +SYSCALL_DEFINE0 (sigreturn) {struct pt_regs *regs =current_pt_regs ();struct sigframe __user *frame;
@@ -633,7 +634,7 @@ asmlinkage long sys_sigreturn(void) }#endif /* CONFIG_X86_32 */ -asmlinkage long sys_rt_sigreturn (void ) +SYSCALL_DEFINE0 (rt_sigreturn) {struct pt_regs *regs =current_pt_regs ();struct rt_sigframe __user *frame;
Signature · 1 line
2.16.2
PATCH 44/45 kernel/sys_ni: sort cond_syscall() entries
In reply to Dominik BrodowskiShuffle the cond_syscall() entries in kernel/sys_ni.c around so that they are kept in the same order as in include/uapi/asm-generic/unistd.h. For better structuring, add the same comments as in that file, but keep a few additional comments and extend the commentary where it seems useful.
--- kernel/sys_ni.c | 506 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 332 insertions(+), 174 deletions(-)
kernel/sys_ni.c +332 -174
@@ -17,245 +17,403 @@ asmlinkage long sys_ni_syscall(void)return -ENOSYS ; } -cond_syscall (sys_quotactl); -cond_syscall (compat_sys_quotactl32); -cond_syscall (sys_acct); +/* +* This list is kept in the same order as include/uapi/asm-generic/unistd.h. +* Architecture specific entries go below, followed by deprecated or obsolete +* system calls. +*/ + +cond_syscall (sys_io_setup); +cond_syscall (compat_sys_io_setup); +cond_syscall (sys_io_destroy); +cond_syscall (sys_io_submit); +cond_syscall (compat_sys_io_submit); +cond_syscall (sys_io_cancel); +cond_syscall (sys_io_getevents); +cond_syscall (compat_sys_io_getevents); + +/* fs/xattr.c */ + +/* fs/dcache.c */ + +/* fs/cookies.c */ cond_syscall (sys_lookup_dcookie);cond_syscall (compat_sys_lookup_dcookie); -cond_syscall (sys_swapon); -cond_syscall (sys_swapoff); + +/* fs/eventfd.c */ +cond_syscall (sys_eventfd2); + +/* fs/eventfd.c */ +cond_syscall (sys_epoll_create1); +cond_syscall (sys_epoll_ctl); +cond_syscall (sys_epoll_pwait); +cond_syscall (compat_sys_epoll_pwait); + +/* fs/fcntl.c */ + +/* fs/inotify_user.c */ +cond_syscall (sys_inotify_init1); +cond_syscall (sys_inotify_add_watch); +cond_syscall (sys_inotify_rm_watch); + +/* fs/ioctl.c */ + +/* fs/ioprio.c */ +cond_syscall (sys_ioprio_set); +cond_syscall (sys_ioprio_get); + +/* fs/locks.c */ +cond_syscall (sys_flock); + +/* fs/namei.c */ + +/* fs/namespace.c */ + +/* fs/nfsctl.c */ + +/* fs/open.c */ + +/* fs/pipe.c */ + +/* fs/quota.c */ +cond_syscall (sys_quotactl); + +/* fs/readdir.c */ + +/* fs/read_write.c */ + +/* fs/sendfile.c */ + +/* fs/select.c */ + +/* fs/signalfd.c */ +cond_syscall (sys_signalfd4); +cond_syscall (compat_sys_signalfd4); + +/* fs/splice.c */ + +/* fs/stat.c */ + +/* fs/sync.c */ + +/* fs/timerfd.c */ +cond_syscall (sys_timerfd_create); +cond_syscall (sys_timerfd_settime); +cond_syscall (compat_sys_timerfd_settime); +cond_syscall (sys_timerfd_gettime); +cond_syscall (compat_sys_timerfd_gettime); + +/* fs/utimes.c */ + +/* kernel/acct.c */ +cond_syscall (sys_acct); + +/* kernel/capability.c */ +cond_syscall (sys_capget); +cond_syscall (sys_capset); + +/* kernel/exec_domain.c */ + +/* kernel/exit.c */ + +/* kernel/fork.c */ + +/* kernel/futex.c */ +cond_syscall (sys_futex); +cond_syscall (compat_sys_futex); +cond_syscall (sys_set_robust_list); +cond_syscall (compat_sys_set_robust_list); +cond_syscall (sys_get_robust_list); +cond_syscall (compat_sys_get_robust_list); + +/* kernel/hrtimer.c */ + +/* kernel/itimer.c */ + +/* kernel/kexec.c */ cond_syscall (sys_kexec_load);cond_syscall (compat_sys_kexec_load); -cond_syscall (sys_kexec_file_load); + +/* kernel/module.c */ cond_syscall (sys_init_module); -cond_syscall (sys_finit_module);cond_syscall (sys_delete_module); + +/* kernel/posix-timers.c */ + +/* kernel/printk.c */ +cond_syscall (sys_syslog); + +/* kernel/ptrace.c */ + +/* kernel/sched/core.c */ + +/* kernel/signal.c */ + +/* kernel/sys.c */ +cond_syscall (sys_setregid); +cond_syscall (sys_setgid); +cond_syscall (sys_setreuid); +cond_syscall (sys_setuid); +cond_syscall (sys_setresuid); +cond_syscall (sys_getresuid); +cond_syscall (sys_setresgid); +cond_syscall (sys_getresgid); +cond_syscall (sys_setfsuid); +cond_syscall (sys_setfsgid); +cond_syscall (sys_setgroups); +cond_syscall (sys_getgroups); + +/* kernel/time.c */ + +/* kernel/timer.c */ + +/* ipc/mqueue.c */ +cond_syscall (sys_mq_open); +cond_syscall (compat_sys_mq_open); +cond_syscall (sys_mq_unlink); +cond_syscall (sys_mq_timedsend); +cond_syscall (compat_sys_mq_timedsend); +cond_syscall (sys_mq_timedreceive); +cond_syscall (compat_sys_mq_timedreceive); +cond_syscall (sys_mq_notify); +cond_syscall (compat_sys_mq_notify); +cond_syscall (sys_mq_getsetattr); +cond_syscall (compat_sys_mq_getsetattr); + +/* ipc/msg.c */ +cond_syscall (sys_msgget); +cond_syscall (sys_msgctl); +cond_syscall (compat_sys_msgctl); +cond_syscall (sys_msgrcv); +cond_syscall (compat_sys_msgrcv); +cond_syscall (sys_msgsnd); +cond_syscall (compat_sys_msgsnd); + +/* ipc/sem.c */ +cond_syscall (sys_semget); +cond_syscall (sys_semctl); +cond_syscall (compat_sys_semctl); +cond_syscall (sys_semtimedop); +cond_syscall (compat_sys_semtimedop); +cond_syscall (sys_semop); + +/* ipc/shm.c */ +cond_syscall (sys_shmget); +cond_syscall (sys_shmctl); +cond_syscall (compat_sys_shmctl); +cond_syscall (sys_shmat); +cond_syscall (compat_sys_shmat); +cond_syscall (sys_shmdt); + +/* net/socket.c */ +cond_syscall (sys_socket);cond_syscall (sys_socketpair);cond_syscall (sys_bind);cond_syscall (sys_listen);cond_syscall (sys_accept); -cond_syscall (sys_accept4);cond_syscall (sys_connect);cond_syscall (sys_getsockname);cond_syscall (sys_getpeername); -cond_syscall (sys_sendto); -cond_syscall (sys_send); -cond_syscall (sys_recvfrom); -cond_syscall (sys_recv); -cond_syscall (sys_socket);cond_syscall (sys_setsockopt);cond_syscall (compat_sys_setsockopt);cond_syscall (sys_getsockopt);cond_syscall (compat_sys_getsockopt); +cond_syscall (sys_sendto);cond_syscall (sys_shutdown); +cond_syscall (sys_recvfrom); +cond_syscall (compat_sys_recvfrom);cond_syscall (sys_sendmsg); -cond_syscall (sys_sendmmsg);cond_syscall (compat_sys_sendmsg); -cond_syscall (compat_sys_sendmmsg);cond_syscall (sys_recvmsg); -cond_syscall (sys_recvmmsg);cond_syscall (compat_sys_recvmsg); -cond_syscall (compat_sys_recv); -cond_syscall (compat_sys_recvfrom); -cond_syscall (compat_sys_recvmmsg); -cond_syscall (sys_socketcall); -cond_syscall (sys_futex); -cond_syscall (compat_sys_futex); -cond_syscall (sys_set_robust_list); -cond_syscall (compat_sys_set_robust_list); -cond_syscall (sys_get_robust_list); -cond_syscall (compat_sys_get_robust_list); -cond_syscall (sys_epoll_create); -cond_syscall (sys_epoll_create1); -cond_syscall (sys_epoll_ctl); -cond_syscall (sys_epoll_wait); -cond_syscall (sys_epoll_pwait); -cond_syscall (compat_sys_epoll_pwait); -cond_syscall (sys_semget); -cond_syscall (sys_semop); -cond_syscall (sys_semtimedop); -cond_syscall (compat_sys_semtimedop); -cond_syscall (sys_semctl); -cond_syscall (compat_sys_semctl); -cond_syscall (sys_msgget); -cond_syscall (sys_msgsnd); -cond_syscall (compat_sys_msgsnd); -cond_syscall (sys_msgrcv); -cond_syscall (compat_sys_msgrcv); -cond_syscall (sys_msgctl); -cond_syscall (compat_sys_msgctl); -cond_syscall (sys_shmget); -cond_syscall (sys_shmat); -cond_syscall (compat_sys_shmat); -cond_syscall (sys_shmdt); -cond_syscall (sys_shmctl); -cond_syscall (compat_sys_shmctl); -cond_syscall (sys_mq_open); -cond_syscall (sys_mq_unlink); -cond_syscall (sys_mq_timedsend); -cond_syscall (sys_mq_timedreceive); -cond_syscall (sys_mq_notify); -cond_syscall (sys_mq_getsetattr); -cond_syscall (compat_sys_mq_open); -cond_syscall (compat_sys_mq_timedsend); -cond_syscall (compat_sys_mq_timedreceive); -cond_syscall (compat_sys_mq_notify); -cond_syscall (compat_sys_mq_getsetattr); -cond_syscall (sys_mbind); -cond_syscall (sys_get_mempolicy); -cond_syscall (sys_set_mempolicy); -cond_syscall (compat_sys_mbind); -cond_syscall (compat_sys_get_mempolicy); -cond_syscall (compat_sys_set_mempolicy); + +/* mm/filemap.c */ + +/* mm/nommu.c, also with MMU */ +cond_syscall (sys_mremap); + +/* security/keys/keyctl.c */ cond_syscall (sys_add_key);cond_syscall (sys_request_key);cond_syscall (sys_keyctl);cond_syscall (compat_sys_keyctl); -cond_syscall (compat_sys_socketcall); -cond_syscall (sys_inotify_init); -cond_syscall (sys_inotify_init1); -cond_syscall (sys_inotify_add_watch); -cond_syscall (sys_inotify_rm_watch); -cond_syscall (sys_migrate_pages); -cond_syscall (sys_move_pages); -cond_syscall (sys_chown16); -cond_syscall (sys_fchown16); -cond_syscall (sys_getegid16); -cond_syscall (sys_geteuid16); -cond_syscall (sys_getgid16); -cond_syscall (sys_getgroups16); -cond_syscall (sys_getresgid16); -cond_syscall (sys_getresuid16); -cond_syscall (sys_getuid16); -cond_syscall (sys_lchown16); -cond_syscall (sys_setfsgid16); -cond_syscall (sys_setfsuid16); -cond_syscall (sys_setgid16); -cond_syscall (sys_setgroups16); -cond_syscall (sys_setregid16); -cond_syscall (sys_setresgid16); -cond_syscall (sys_setresuid16); -cond_syscall (sys_setreuid16); -cond_syscall (sys_setuid16); -cond_syscall (sys_sgetmask); -cond_syscall (sys_ssetmask); -cond_syscall (sys_vm86old); -cond_syscall (sys_vm86); -cond_syscall (sys_modify_ldt); -cond_syscall (sys_ipc); -cond_syscall (compat_sys_ipc); -cond_syscall (compat_sys_sysctl); -cond_syscall (sys_flock); -cond_syscall (sys_io_setup); -cond_syscall (sys_io_destroy); -cond_syscall (sys_io_submit); -cond_syscall (sys_io_cancel); -cond_syscall (sys_io_getevents); -cond_syscall (compat_sys_io_setup); -cond_syscall (compat_sys_io_submit); -cond_syscall (compat_sys_io_getevents); -cond_syscall (sys_sysfs); -cond_syscall (sys_syslog); -cond_syscall (sys_process_vm_readv); -cond_syscall (sys_process_vm_writev); -cond_syscall (compat_sys_process_vm_readv); -cond_syscall (compat_sys_process_vm_writev); -cond_syscall (sys_uselib); -cond_syscall (sys_fadvise64); -cond_syscall (sys_fadvise64_64); -cond_syscall (sys_madvise); -cond_syscall (sys_setuid); -cond_syscall (sys_setregid); -cond_syscall (sys_setgid); -cond_syscall (sys_setreuid); -cond_syscall (sys_setresuid); -cond_syscall (sys_getresuid); -cond_syscall (sys_setresgid); -cond_syscall (sys_getresgid); -cond_syscall (sys_setgroups); -cond_syscall (sys_getgroups); -cond_syscall (sys_setfsuid); -cond_syscall (sys_setfsgid); -cond_syscall (sys_capget); -cond_syscall (sys_capset); -cond_syscall (sys_copy_file_range); -/* arch-specific weak syscall entries */ -cond_syscall (sys_pciconfig_read); -cond_syscall (sys_pciconfig_write); -cond_syscall (sys_pciconfig_iobase); -cond_syscall (compat_sys_s390_ipc); -cond_syscall (ppc_rtas); -cond_syscall (sys_spu_run); -cond_syscall (sys_spu_create); -cond_syscall (sys_subpage_prot); -cond_syscall (sys_s390_pci_mmio_read); -cond_syscall (sys_s390_pci_mmio_write); +/* arch/example/kernel/sys_example.c */ -/* mmu depending weak syscall entries */ +/* mm/fadvise.c */ +cond_syscall (sys_fadvise64_64); + +/* mm/, CONFIG_MMU only */ +cond_syscall (sys_swapon); +cond_syscall (sys_swapoff);cond_syscall (sys_mprotect);cond_syscall (sys_msync);cond_syscall (sys_mlock);cond_syscall (sys_munlock);cond_syscall (sys_mlockall);cond_syscall (sys_munlockall); -cond_syscall (sys_mlock2);cond_syscall (sys_mincore);cond_syscall (sys_madvise); -cond_syscall (sys_mremap);cond_syscall (sys_remap_file_pages); -cond_syscall (compat_sys_move_pages); +cond_syscall (sys_mbind); +cond_syscall (compat_sys_mbind); +cond_syscall (sys_get_mempolicy); +cond_syscall (compat_sys_get_mempolicy); +cond_syscall (sys_set_mempolicy); +cond_syscall (compat_sys_set_mempolicy); +cond_syscall (sys_migrate_pages);cond_syscall (compat_sys_migrate_pages); +cond_syscall (sys_move_pages); +cond_syscall (compat_sys_move_pages); -/* block-layer dependent */ -cond_syscall (sys_bdflush); -cond_syscall (sys_ioprio_set); -cond_syscall (sys_ioprio_get); - -/* New file descriptors */ -cond_syscall (sys_signalfd); -cond_syscall (sys_signalfd4); -cond_syscall (compat_sys_signalfd); -cond_syscall (compat_sys_signalfd4); -cond_syscall (sys_timerfd_create); -cond_syscall (sys_timerfd_settime); -cond_syscall (sys_timerfd_gettime); -cond_syscall (compat_sys_timerfd_settime); -cond_syscall (compat_sys_timerfd_gettime); -cond_syscall (sys_eventfd); -cond_syscall (sys_eventfd2); -cond_syscall (sys_memfd_create); -cond_syscall (sys_userfaultfd); - -/* performance counters: */ cond_syscall (sys_perf_event_open); +cond_syscall (sys_accept4); +cond_syscall (sys_recvmmsg); +cond_syscall (compat_sys_recvmmsg); + +/* +* Architecture specific syscalls: see further below +*/ -/* fanotify! */ +/* fanotify */ cond_syscall (sys_fanotify_init);cond_syscall (sys_fanotify_mark); -cond_syscall (compat_sys_fanotify_mark);/* open by handle */ cond_syscall (sys_name_to_handle_at);cond_syscall (sys_open_by_handle_at);cond_syscall (compat_sys_open_by_handle_at); +cond_syscall (sys_sendmmsg); +cond_syscall (compat_sys_sendmmsg); +cond_syscall (sys_process_vm_readv); +cond_syscall (compat_sys_process_vm_readv); +cond_syscall (sys_process_vm_writev); +cond_syscall (compat_sys_process_vm_writev); +/* compare kernel pointers */ cond_syscall (sys_kcmp); +cond_syscall (sys_finit_module); +/* operate on Secure Computing state */ cond_syscall (sys_seccomp); +cond_syscall (sys_memfd_create); +/* access BPF programs and maps */ cond_syscall (sys_bpf);/* execveat */ cond_syscall (sys_execveat); +cond_syscall (sys_userfaultfd); +/* membarrier */ cond_syscall (sys_membarrier); +cond_syscall (sys_mlock2); + +cond_syscall (sys_copy_file_range); +/* memory protection keys */ cond_syscall (sys_pkey_mprotect);cond_syscall (sys_pkey_alloc);cond_syscall (sys_pkey_free); + + +/* +* Architecture specific weak syscall entries. +*/ + +/* pciconfig: alpha, arm, arm64, ia64, sparc */ +cond_syscall (sys_pciconfig_read); +cond_syscall (sys_pciconfig_write); +cond_syscall (sys_pciconfig_iobase); + +/* sys_socketcall: arm, mips, x86, ... */ +cond_syscall (sys_socketcall); +cond_syscall (compat_sys_socketcall); + +/* compat syscalls for arm64, x86, ... */ +cond_syscall (compat_sys_sysctl); +cond_syscall (compat_sys_fanotify_mark); + +/* x86 */ +cond_syscall (sys_vm86old); +cond_syscall (sys_modify_ldt); +cond_syscall (compat_sys_quotactl32); +cond_syscall (sys_vm86); +cond_syscall (sys_kexec_file_load); + +/* s390 */ +cond_syscall (sys_s390_pci_mmio_read); +cond_syscall (sys_s390_pci_mmio_write); +cond_syscall (compat_sys_s390_ipc); + +/* powerpc */ +cond_syscall (ppc_rtas); +cond_syscall (sys_spu_run); +cond_syscall (sys_spu_create); +cond_syscall (sys_subpage_prot); + + +/* +* Deprecated system calls which are still defined in +* include/uapi/asm-generic/unistd.h and wanted by >= 1 arch +*/ + +/* __ARCH_WANT_SYSCALL_NO_FLAGS */ +cond_syscall (sys_epoll_create); +cond_syscall (sys_inotify_init); +cond_syscall (sys_eventfd); +cond_syscall (sys_signalfd); +cond_syscall (compat_sys_signalfd); + +/* __ARCH_WANT_SYSCALL_OFF_T */ +cond_syscall (sys_fadvise64); + +/* __ARCH_WANT_SYSCALL_DEPRECATED */ +cond_syscall (sys_epoll_wait); +cond_syscall (sys_recv); +cond_syscall (compat_sys_recv); +cond_syscall (sys_send); +cond_syscall (sys_bdflush); +cond_syscall (sys_uselib); + + +/* +* The syscalls below are not found in include/uapi/asm-generic/unistd.h +*/ + +/* obsolete: SGETMASK_SYSCALL */ +cond_syscall (sys_sgetmask); +cond_syscall (sys_ssetmask); + +/* obsolete: SYSFS_SYSCALL */ +cond_syscall (sys_sysfs); + +/* obsolete: __ARCH_WANT_SYS_IPC */ +cond_syscall (sys_ipc); +cond_syscall (compat_sys_ipc); + +/* obsolete: UID16 */ +cond_syscall (sys_chown16); +cond_syscall (sys_fchown16); +cond_syscall (sys_getegid16); +cond_syscall (sys_geteuid16); +cond_syscall (sys_getgid16); +cond_syscall (sys_getgroups16); +cond_syscall (sys_getresgid16); +cond_syscall (sys_getresuid16); +cond_syscall (sys_getuid16); +cond_syscall (sys_lchown16); +cond_syscall (sys_setfsgid16); +cond_syscall (sys_setfsuid16); +cond_syscall (sys_setgid16); +cond_syscall (sys_setgroups16); +cond_syscall (sys_setregid16); +cond_syscall (sys_setresgid16); +cond_syscall (sys_setresuid16); +cond_syscall (sys_setreuid16); +cond_syscall (sys_setuid16);
Signature · 1 line
2.16.2
PATCH 45/45 bpf: whitelist all syscalls for error injection
In reply to Dominik BrodowskiFrom: Howard McLauchlan <[email protected]>
Error injection is a useful mechanism to fail arbitrary kernel functions. However, it is often hard to guarantee an error propagates appropriately to user space programs. By injecting into syscalls, we can return arbitrary values to user space directly; this increases flexibility and robustness in testing, allowing us to test user space error paths effectively.
The following script, for example, fails calls to sys_open() from a given pid:
from bcc import BPF
from sys import argv
pid = argv[1]
prog = r"""
int kprobe__SyS_open(struct pt_regs *ctx, const char *pathname, int flags)
{
u32 pid = bpf_get_current_pid_tgid();
if (pid == %s)
bpf_override_return(ctx, -ENOMEM);
return 0;
}""" % pid
b = BPF(text=prog)
while 1:
b.perf_buffer_poll()
This patch whitelists all syscalls defined with SYSCALL_DEFINE and COMPAT_SYSCALL_DEFINE for error injection. These changes are not intended to be considered stable, and would normally be configured off.
--- include/linux/compat.h | 3 +++ include/linux/syscalls.h | 3 +++ 2 files changed, 6 insertions(+)
include/linux/compat.h +3 -0
@@ -33,6 +33,8 @@#endif #define COMPAT_SYSCALL_DEFINE0 (name) \ + asmlinkage long compat_sys_##name(void); \ + ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \ asmlinkage long compat_sys_##name(void)#define COMPAT_SYSCALL_DEFINE1 (name, ...) \
@@ -51,6 +53,7 @@#define COMPAT_SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\ __attribute__((alias(__stringify(compat_SyS##name)))); \ + ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \ static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\ asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
include/linux/syscalls.h +3 -0
@@ -191,6 +191,8 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)#define SYSCALL_DEFINE0 (sname) \ SYSCALL_METADATA(_##sname, 0); \ + asmlinkage long sys_##sname(void); \ + ALLOW_ERROR_INJECTION(sys_##sname, ERRNO); \ asmlinkage long sys_##sname(void)#define SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
@@ -210,6 +212,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)#define __SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ __attribute__((alias(__stringify(SyS##name)))); \ + ALLOW_ERROR_INJECTION(sys##name, ERRNO); \ static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
Signature · 1 line
2.16.2
Re: [PATCH 40/45] x86: use _do_fork() in compat_sys_x86_clone()
In reply to Dominik BrodowskiQuoted 10 lines · Dominik Brodowski
It is trivial to directly call
_do_fork()instead of thesys_clone()syscall incompat_sys_x86_clone().This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
Cc Ingo Molnar <[email protected]>Cc Jiri Slaby <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Re: [PATCH 41/45] x86: remove compat_sys_x86_waitpid()
In reply to Dominik BrodowskiQuoted 8 lines · Dominik Brodowski
compat_sys_x86_waitpid()is not needed, as it takes the same parameters (int, *int, int) as the native syscall.Suggested-by Al Viro <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Slaby <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Re: [PATCH 42/45] x86: fix sys_sigreturn() return type to be long, not unsigned long
In reply to Dominik BrodowskiQuoted 10 lines · Dominik Brodowski
Same as with other system calls,
sys_sigreturn()should return a value of type long, not unsigned long. This also matches the behaviour forIA32_EMULATION, seesys32_sigreturn()inarch/x86/ia32/ia32_signal.c.Cc Andi Kleen <[email protected]>Cc Ingo Molnar <[email protected]>Cc Jiri Slaby <[email protected]>Cc Michael Tautschnig <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Re: [PATCH 43/45] x86/sigreturn: use SYSCALL_DEFINE0
In reply to Dominik BrodowskiQuoted 5 lines · Dominik Brodowski
From: "Tautschnig, Michael" <[email protected]>
All definitions of syscalls in x86 except for those patched here have already been using the appropriate SYSCALL_DEFINE*.
Quoted 8 lines
Signed-off-by Michael Tautschnig <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Jaswinder Singh <[email protected]>Cc Andi Kleen <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Any chance that kernel/uid6.c can go? [Was: [PATCH 22/45] kernel: provide ksys_*() wrappers for syscalls called by kernel/uid16.c]
In reply to Dominik BrodowskiQuoted 11 lines · Dominik Brodowski
Using these helpers allows us to avoid the in-kernel calls to these
syscalls:sys_setregid(),sys_setgid(),sys_setreuid(),sys_setuid(),sys_setresuid(),sys_setresgid(),sys_setfsuid(), andsys_setfsgid().The
ksys_prefix denotes that these function are meant as a drop-in replacement for the syscall. In particular, they use the same calling convention.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
Quoted 7 lines
Cc Al Viro <[email protected]>Cc Eric W. Biederman <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>--- kernel/sys.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- kernel/uid16.c | 19 ++++++++++---------
In its header, kernel/uid16.c says, since 2.3.39 was released in January 2000:
* Wrapper functions for 16bit uid back compatibility. All nicely tied
* together in the faint hope we can take the out in five years time.
Are we any closer to removing these wrappers?
Thanks,
Dominik
Peter Zijlstra
maintainerRe: [PATCH 23/45] sched: add do_sched_yield() helper; remove in-kernel call to sched_yield()
In reply to Dominik BrodowskiQuoted 5 lines · Dominik Brodowski
Using the sched-internal
do_sched_yield()helper allows us to get rid of the sched-internal call to thesys_sched_yield()syscall.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
But why !? Either Cc me on more of the series such that the whole makes sense, or better yet, write a proper Changelog.
Re: [PATCH 23/45] sched: add do_sched_yield() helper; remove in-kernel call to sched_yield()
Quoted 9 lines · Peter Zijlstra
Quoted 5 lines · Dominik Brodowski
Using the sched-internal
do_sched_yield()helper allows us to get rid of the sched-internal call to thesys_sched_yield()syscall.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
But why !? Either Cc me on more of the series such that the whole makes sense, or better yet, write a proper Changelog.
Well, the summary is right there in the changelog: Kernel code simply should not pretend to be userspace and call a syscall function. For a more
detailled description, see, for instance, Linus' explanation in
http://lkml.kernel.org/r/CA+55aFwo7yA1gm8AUYMEQA8ZNY-9GGF8Oup09jJFvEa4J7C+jA@mail.gmail.com :
| On x86-64, we'd like to just pass the 'struct pt_regs *' pointer, and | have the sys_xyz() function itself just pick out the arguments it | needs from there. | | That has a few reasons for it: | | - we can clear all registers at system call entry, which helps defeat | some of the "pass seldom used register with user-controlled value that | survives deep into the callchain" things that people used to leak | information | | - we can streamline the low-level system call code, which needs to | pass around 'struct pt_regs *' anyway, and the system call only picks | up the values it actually needs
I can add such a long description to all these patches, but that seems to be a bit... longwinded.
Thanks,
Dominik
Re: [PATCH 23/45] sched: add do_sched_yield() helper; remove in-kernel call to sched_yield()
In reply to Peter ZijlstraQuoted 3 lines · Peter Zijlstra
But why !? Either Cc me on more of the series such that the whole makes sense, or better yet, write a proper Changelog.
This is a common issue. We should encourage people to always send at least the cover-page to everybody who gets cc'd, even if they don't get the whole series.
Anyway, to repeat: the calling convention for x86-64 system call wrappers will be to just pass in "struct pt_regs", and the system call wrapper itself will take the arguments from there.
That means that we won't have random user space contents in registers that can leak deep down the call chain. The registers are cleared at system call entry, and only the actual real arguments are reloaded.
(It also makes do_syscall_64() generate better code, natch).
Anyway, that means that you *CANNOT* call "sys_xyz() from kernel code. Not that you really should have anyway, but there are tons of historical reasons why we do. But now it fundamentally won't work, because you'd need to literally do
{ struct pt_regs regs;
regs.rdi = (unsigned long) firstarg;
regs.rsi = (unsigned long) second;
...
sys_xyz(®s); }to do it on x86-64.
Anyway, there's a longer discussion about why this is the case elsewhere, and why we want to do it, but just take it as granted: you will not be able to call sys_xyz() directly, and that's just a fact.
Making people able to do it would make real system calls (that are a hell of a lot more important) slower. So it's simply not going to be allowed.
Linus
Re: Any chance that kernel/uid6.c can go? [Was: [PATCH 22/45] kernel: provide ksys_*() wrappers for syscalls called by kernel/uid16.c]
In reply to Dominik BrodowskiQuoted 8 lines · Dominik Brodowski
In its header,
kernel/uid16.csays, since 2.3.39 was released in January 2000:* Wrapper functions for 16bit uid back compatibility. All nicely tied
* together in the faint hope we can take the out in five years time.Are we any closer to removing these wrappers?
Honestly, I don't see any real upside to getting rid of them.
We used to still run some of the _original_ binaries from the old floppy disk distributions just a few years ago. I honestly hope we still do. And those old uid system calls would be very much part of it.
Sadly, I don't know where those old binaries are. Anybody know where the bash binary from 1991 is? There was a "bash.Z" as part of the 0.01 release.
(Ok, that one is almost certainly broken, but Alan Cox reported running some really old binaries from the early times long ago before he turned to even *older* retrocomputing and started concentrating on the old 8-bit machines ;)
Linus
Quoted 3 lines · Dominik Brodowski
Here is a third series of patches which reduce the number of syscall invocations from within the kernel. Once this long-term goal is achieved, the syscall entry path can be streamlined.
Looks good to me.
Linus
git send-email and sending the cover-letter to all cc addresses found in a patch series
In reply to Linus TorvaldsQuoted 8 lines · Linus Torvalds
Quoted 3 lines · Peter Zijlstra
But why !? Either Cc me on more of the series such that the whole makes sense, or better yet, write a proper Changelog.
This is a common issue. We should encourage people to always send at least the cover-page to everybody who gets cc'd, even if they don't get the whole series.
Will try to do that in future. Does git send-email have such an option? Or do I have to specify all cc addresses in the cover letter manually? I found some reference to an unresolved discussion on git@ of that topic in 2016, so I might not be the only one who could make use of that feature...
Thanks,
Dominik
Re: git send-email and sending the cover-letter to all cc addresses found in a patch series
Quoted 6 lines · Dominik Brodowski
Quoted 5 lines · Linus Torvalds
Quoted 3 lines · Peter Zijlstra
But why !? Either Cc me on more of the series such that the whole makes sense, or better yet, write a proper Changelog.
Quoted 8 lines
Quoted 3 lines
This is a common issue. We should encourage people to always send at least the cover-page to everybody who gets cc'd, even if they don't get the whole series.
Will try to do that in future. Does git send-email have such an option? Or do I have to specify all cc addresses in the cover letter manually? I found some reference to an unresolved discussion on git@ of that topic in 2016, so I might not be the only one who could make use of that feature...
The main problem might be the quantity of recipients.
Many spam filters look at how many recipients on an email to eliminate likely spam.
kernel.org mailing lists have a maximum email header size. Too many recipients aren't delivered to the lists.
Using BCC could work, but replies then don't go to all of the recipients.
Generally, I send only to listed the 0/n patch only to lists and individual patches to maintainers.
Re: [PATCH 16/45] inotify: add do_inotify_init() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiQuoted 10 lines · Dominik Brodowski
Using the inotify-internal
do_inotify_init()helper allows us to get rid of the in-kernel call tosys_inotify_init1()syscall.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
Cc Jan Kara <[email protected]>Cc Amir Goldstein <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 36 lines
--- fs/notify/inotify/inotify_user.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)fs/notify/inotify/inotify_user.c +7
-2@@ -635,7 +635,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)/* inotify syscalls */ -SYSCALL_DEFINE1(inotify_init1, int, flags) +static int do_inotify_init (int flags) {struct fsnotify_group *group;int ret;@@ -660,9 +660,14 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)return ret; } +SYSCALL_DEFINE1(inotify_init1, int, flags) +{ +return do_inotify_init (flags); +} +SYSCALL_DEFINE0 (inotify_init) { -return sys_inotify_init1 (0 ); +return do_inotify_init (0 ); } SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,Signature · 1 line
2.16.2
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 17/45] fanotify: add do_fanotify_mark() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiQuoted 9 lines · Dominik Brodowski
Using the fs-internal
do_fanotify_mark()helper allows us to get rid of the fs-internal call to thesys_fanotify_mark()syscall.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
Cc Jan Kara <[email protected]>Cc Amir Goldstein <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 45 lines
--- fs/notify/fanotify/fanotify_user.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)fs/notify/fanotify/fanotify_user.c +10
-4@@ -820,9 +820,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)return fd; } -SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, - __u64, mask, int, dfd, - const char __user *, pathname) +static int do_fanotify_mark (int fanotify_fd,unsigned int flags,__u64 mask, +int dfd,const char __user *pathname) {struct inode *inode =NULL ;struct vfsmount *mnt =NULL ;@@ -928,13 +927,20 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,return ret; } +SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, + __u64, mask, int, dfd, + const char __user *, pathname) +{ +return do_fanotify_mark (fanotify_fd, flags, mask, dfd, pathname); +} +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE6 (fanotify_mark, int, fanotify_fd, unsigned int, flags, __u32, mask0, __u32, mask1, int, dfd, const char __user *, pathname) { - return sys_fanotify_mark(fanotify_fd, flags, + return do_fanotify_mark(fanotify_fd, flags, #ifdef __BIG_ENDIAN ((__u64)mask0 << 32) | mask1,#else Signature · 1 line
2.16.2
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 18/45] fs/quota: add kernel_quotactl() helper; remove in-kernel call to syscall
In reply to Dominik BrodowskiQuoted 8 lines · Dominik Brodowski
Using the fs-internal
kernel_quotactl()helper allows us to get rid of the fs-internal call to thesys_quotactl()syscall.This patch is part of a series which tries to remove in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined.
Cc Jan Kara <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 86 lines
--- fs/quota/compat.c | 8 ++++---- fs/quota/quota.c | 10 ++++++++-- include/linux/quotaops.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-)fs/quota/compat.c +4
-4@@ -59,7 +59,7 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,case Q_GETQUOTA : dqblk =compat_alloc_user_space (sizeof (struct if_dqblk )); compat_dqblk = addr; - ret =sys_quotactl (cmd, special, id, dqblk); + ret =kernel_quotactl (cmd, special, id, dqblk);if (ret)break ; if (copy_in_user(compat_dqblk, dqblk, sizeof(*compat_dqblk)) ||@@ -75,12 +75,12 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,get_user (data, &compat_dqblk->dqb_valid) || put_user(data, &dqblk->dqb_valid)) break; - ret =sys_quotactl (cmd, special, id, dqblk); + ret =kernel_quotactl (cmd, special, id, dqblk);break ;case Q_XGETQSTAT : fsqstat =compat_alloc_user_space (sizeof (struct fs_quota_stat )); compat_fsqstat = addr; - ret =sys_quotactl (cmd, special, id, fsqstat); + ret =kernel_quotactl (cmd, special, id, fsqstat);if (ret)break ; ret = -EFAULT ;@@ -113,7 +113,7 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special, ret =0 ;break ;default : - ret =sys_quotactl (cmd, special, id, addr); + ret =kernel_quotactl (cmd, special, id, addr); }return ret; }fs/quota/quota.c +8
-2@@ -833,8 +833,8 @@ static struct super_block *quotactl_block(const char __user *special, int cmd)* calls. Maybe we need to add the process quotas etc. in the future, * but we probably should use rlimits for that. */ -SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, - qid_t, id, void __user *, addr) +int kernel_quotactl (unsigned int cmd,const char __user *special, +qid_t id,void __user *addr) {uint cmds, type;struct super_block *sb =NULL ;@@ -885,3 +885,9 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,path_put (pathp);return ret; } + +SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special, + qid_t, id, void __user *, addr) +{ +return kernel_quotactl (cmd, special, id, addr); +}include/linux/quotaops.h +3
-0@@ -105,6 +105,9 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,int __dquot_transfer (struct inode *inode,struct dquot **transfer_to);int dquot_transfer (struct inode *inode,struct iattr *iattr); +int kernel_quotactl (unsigned int cmd,const char __user *special, +qid_t id,void __user *addr); +static inline struct mem_dqinfo *sb_dqinfo (struct super_block *sb,int type) {return sb_dqopt (sb)->info + type;Signature · 1 line
2.16.2
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 19/45] fs/quota: use COMPAT_SYSCALL_DEFINE for sys32_quotactl()
In reply to Dominik BrodowskiQuoted 6 lines · Dominik Brodowski
While
sys32_quotactl()is only needed on x86, it can use the recommendedCOMPAT_SYSCALL_DEFINEx()machinery for its setup.Cc Jan Kara <[email protected]>Cc Christoph Hellwig <[email protected]>Signed-off-by Dominik Brodowski <[email protected]>
Looks good AFAICT. You can add:
Honza
Quoted 90 lines
--- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- fs/quota/compat.c | 5 +++-- include/linux/compat.h | 3 +++ include/linux/syscalls.h | 4 +--- kernel/sys_ni.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)arch/x86/entry/syscalls/syscall_32.tbl +1
-1@@ -137,7 +137,7 @@ 128 i386 init_module sys_init_module 129 i386 delete_module sys_delete_module 130 i386 get_kernel_syms -131 i386 quotactl sys_quotactl sys32_quotactl +131 i386 quotactl sys_quotactl compat_sys_quotactl32 132 i386 getpgid sys_getpgid 133 i386 fchdir sys_fchdir 134 i386 bdflush sys_bdflushfs/quota/compat.c +3
-2@@ -41,8 +41,9 @@ struct compat_fs_quota_stat {__u16 qs_iwarnlimit; }; -asmlinkage long sys32_quotactl (unsigned int cmd,const char __user *special, -qid_t id,void __user *addr) +COMPAT_SYSCALL_DEFINE4(quotactl32, unsigned int, cmd, + const char __user *, special, qid_t, id, + void __user *, addr) {unsigned int cmds;struct if_dqblk __user *dqblk;include/linux/compat.h +3
-0@@ -461,6 +461,9 @@ asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,const struct compat_iovec __user *vec, compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); +asmlinkage long compat_sys_quotactl32 (unsigned int cmd, +const char __user *special,qid_t id,void __user *addr); +#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 asmlinkage long compat_sys_preadv64(unsigned long fd, const struct compat_iovec __user *vec,include/linux/syscalls.h +1
-3@@ -241,8 +241,6 @@ static inline void addr_limit_user_check(void)#endif } -asmlinkage long sys32_quotactl (unsigned int cmd,const char __user *special, -qid_t id,void __user *addr);asmlinkage long sys_time (time_t __user *tloc);asmlinkage long sys_stime (time_t __user *tptr); asmlinkage long sys_gettimeofday(struct timeval __user *tv,@@ -625,7 +623,7 @@ asmlinkage long sys_chdir(const char __user *filename);asmlinkage long sys_fchdir (unsigned int fd);asmlinkage long sys_rmdir (const char __user *pathname);asmlinkage long sys_lookup_dcookie (u64 cookie64,char __user *buf,size_t len); -asmlinkage long sys_quotactl (unsigned int cmd,const char __user *special, +asmlinkage long sys_quotactl32 (unsigned int cmd,const char __user *special,qid_t id,void __user *addr); asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user *dirent,kernel/sys_ni.c +1
-1@@ -18,7 +18,7 @@ asmlinkage long sys_ni_syscall(void) }cond_syscall (sys_quotactl); -cond_syscall (sys32_quotactl); +cond_syscall (compat_sys_quotactl32);cond_syscall (sys_acct);cond_syscall (sys_lookup_dcookie);cond_syscall (compat_sys_lookup_dcookie);Signature · 1 line
2.16.2
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR