diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2018-03-11 06:34:54 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2018-04-02 14:16:00 -0400 |
commit | 411d9475cf901b5a6d2996b46cb5726184a4fa50 (patch) | |
tree | 9edd781b00784cd4f178e44d684c5ab4092cd551 | |
parent | 55731b3cda3a85ee888dac3bf1f36489f275c187 (diff) |
fs: add ksys_ftruncate() wrapper; remove in-kernel calls to sys_ftruncate()
Using the ksys_ftruncate() wrapper allows us to get rid of in-kernel
calls to the sys_ftruncate() 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_ftruncate().
This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r-- | arch/mips/kernel/linux32.c | 2 | ||||
-rw-r--r-- | arch/parisc/kernel/sys_parisc.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/sys_ppc32.c | 2 | ||||
-rw-r--r-- | arch/s390/kernel/compat_linux.c | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc32.c | 2 | ||||
-rw-r--r-- | arch/x86/ia32/sys_ia32.c | 2 | ||||
-rw-r--r-- | fs/internal.h | 1 | ||||
-rw-r--r-- | fs/open.c | 2 | ||||
-rw-r--r-- | include/linux/syscalls.h | 7 | ||||
-rw-r--r-- | init/initramfs.c | 2 |
10 files changed, 17 insertions, 9 deletions
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index b332f6fc1e72..3c90449742a0 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
@@ -88,7 +88,7 @@ SYSCALL_DEFINE4(32_truncate64, const char __user *, path, | |||
88 | SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy, | 88 | SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy, |
89 | unsigned long, a2, unsigned long, a3) | 89 | unsigned long, a2, unsigned long, a3) |
90 | { | 90 | { |
91 | return sys_ftruncate(fd, merge_64(a2, a3)); | 91 | return ksys_ftruncate(fd, merge_64(a2, a3)); |
92 | } | 92 | } |
93 | 93 | ||
94 | SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high, | 94 | SYSCALL_DEFINE5(32_llseek, unsigned int, fd, unsigned int, offset_high, |
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 378a754ca186..6d2a64859c22 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c | |||
@@ -298,7 +298,7 @@ asmlinkage long parisc_truncate64(const char __user * path, | |||
298 | asmlinkage long parisc_ftruncate64(unsigned int fd, | 298 | asmlinkage long parisc_ftruncate64(unsigned int fd, |
299 | unsigned int high, unsigned int low) | 299 | unsigned int high, unsigned int low) |
300 | { | 300 | { |
301 | return sys_ftruncate(fd, (long)high << 32 | low); | 301 | return ksys_ftruncate(fd, (long)high << 32 | low); |
302 | } | 302 | } |
303 | 303 | ||
304 | /* stubs for the benefit of the syscall_table since truncate64 and truncate | 304 | /* stubs for the benefit of the syscall_table since truncate64 and truncate |
@@ -309,7 +309,7 @@ asmlinkage long sys_truncate64(const char __user * path, unsigned long length) | |||
309 | } | 309 | } |
310 | asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length) | 310 | asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length) |
311 | { | 311 | { |
312 | return sys_ftruncate(fd, length); | 312 | return ksys_ftruncate(fd, length); |
313 | } | 313 | } |
314 | asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg) | 314 | asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg) |
315 | { | 315 | { |
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c index 15f216d022e2..e0c9b7f1bf38 100644 --- a/arch/powerpc/kernel/sys_ppc32.c +++ b/arch/powerpc/kernel/sys_ppc32.c | |||
@@ -107,7 +107,7 @@ asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo, | |||
107 | asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high, | 107 | asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high, |
108 | unsigned long low) | 108 | unsigned long low) |
109 | { | 109 | { |
110 | return sys_ftruncate(fd, (high << 32) | low); | 110 | return ksys_ftruncate(fd, (high << 32) | low); |
111 | } | 111 | } |
112 | 112 | ||
113 | long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low, | 113 | long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low, |
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index 9a9bb395359c..9c5e975f71a6 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c | |||
@@ -307,7 +307,7 @@ COMPAT_SYSCALL_DEFINE3(s390_truncate64, const char __user *, path, u32, high, u3 | |||
307 | 307 | ||
308 | COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsigned int, fd, u32, high, u32, low) | 308 | COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsigned int, fd, u32, high, u32, low) |
309 | { | 309 | { |
310 | return sys_ftruncate(fd, (unsigned long)high << 32 | low); | 310 | return ksys_ftruncate(fd, (unsigned long)high << 32 | low); |
311 | } | 311 | } |
312 | 312 | ||
313 | COMPAT_SYSCALL_DEFINE5(s390_pread64, unsigned int, fd, char __user *, ubuf, | 313 | COMPAT_SYSCALL_DEFINE5(s390_pread64, unsigned int, fd, char __user *, ubuf, |
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c index 6d964bdefbaa..d64b425fff93 100644 --- a/arch/sparc/kernel/sys_sparc32.c +++ b/arch/sparc/kernel/sys_sparc32.c | |||
@@ -65,7 +65,7 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned | |||
65 | if ((int)high < 0) | 65 | if ((int)high < 0) |
66 | return -EINVAL; | 66 | return -EINVAL; |
67 | else | 67 | else |
68 | return sys_ftruncate(fd, (high << 32) | low); | 68 | return ksys_ftruncate(fd, (high << 32) | low); |
69 | } | 69 | } |
70 | 70 | ||
71 | static int cp_compat_stat64(struct kstat *stat, | 71 | static int cp_compat_stat64(struct kstat *stat, |
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c index 23a5260eae67..1979e5b4ad9a 100644 --- a/arch/x86/ia32/sys_ia32.c +++ b/arch/x86/ia32/sys_ia32.c | |||
@@ -61,7 +61,7 @@ COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename, | |||
61 | COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd, | 61 | COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd, |
62 | unsigned long, offset_low, unsigned long, offset_high) | 62 | unsigned long, offset_low, unsigned long, offset_high) |
63 | { | 63 | { |
64 | return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low); | 64 | return ksys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low); |
65 | } | 65 | } |
66 | 66 | ||
67 | /* | 67 | /* |
diff --git a/fs/internal.h b/fs/internal.h index c797480cbd6f..980d005b21b4 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -119,6 +119,7 @@ extern struct file *do_filp_open(int dfd, struct filename *pathname, | |||
119 | extern struct file *do_file_open_root(struct dentry *, struct vfsmount *, | 119 | extern struct file *do_file_open_root(struct dentry *, struct vfsmount *, |
120 | const char *, const struct open_flags *); | 120 | const char *, const struct open_flags *); |
121 | 121 | ||
122 | long do_sys_ftruncate(unsigned int fd, loff_t length, int small); | ||
122 | long do_faccessat(int dfd, const char __user *filename, int mode); | 123 | long do_faccessat(int dfd, const char __user *filename, int mode); |
123 | int do_fchmodat(int dfd, const char __user *filename, umode_t mode); | 124 | int do_fchmodat(int dfd, const char __user *filename, umode_t mode); |
124 | int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, | 125 | int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, |
@@ -162,7 +162,7 @@ COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, compat_off_t, length | |||
162 | } | 162 | } |
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | static long do_sys_ftruncate(unsigned int fd, loff_t length, int small) | 165 | long do_sys_ftruncate(unsigned int fd, loff_t length, int small) |
166 | { | 166 | { |
167 | struct inode *inode; | 167 | struct inode *inode; |
168 | struct dentry *dentry; | 168 | struct dentry *dentry; |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index df0d1e818a6e..41023177c8ec 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -1038,4 +1038,11 @@ static inline long ksys_lchown(const char __user *filename, uid_t user, | |||
1038 | AT_SYMLINK_NOFOLLOW); | 1038 | AT_SYMLINK_NOFOLLOW); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | extern long do_sys_ftruncate(unsigned int fd, loff_t length, int small); | ||
1042 | |||
1043 | static inline long ksys_ftruncate(unsigned int fd, unsigned long length) | ||
1044 | { | ||
1045 | return do_sys_ftruncate(fd, length, 1); | ||
1046 | } | ||
1047 | |||
1041 | #endif | 1048 | #endif |
diff --git a/init/initramfs.c b/init/initramfs.c index 35173bef7c00..0d3b001b0dc5 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
@@ -346,7 +346,7 @@ static int __init do_name(void) | |||
346 | ksys_fchown(wfd, uid, gid); | 346 | ksys_fchown(wfd, uid, gid); |
347 | ksys_fchmod(wfd, mode); | 347 | ksys_fchmod(wfd, mode); |
348 | if (body_len) | 348 | if (body_len) |
349 | sys_ftruncate(wfd, body_len); | 349 | ksys_ftruncate(wfd, body_len); |
350 | vcollected = kstrdup(collected, GFP_KERNEL); | 350 | vcollected = kstrdup(collected, GFP_KERNEL); |
351 | state = CopyFile; | 351 | state = CopyFile; |
352 | } | 352 | } |