aboutsummaryrefslogtreecommitdiffstats
path: root/fs/read_write.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-03-31 17:32:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-03-31 17:32:17 -0400
commit190f918660a69d1c56fd05dc8c6cbb8336a8a0af (patch)
tree2320b4aab7f048d97c35ac6ade5b7dedc71da89d /fs/read_write.c
parent176ab02d4916f09d5d8cb63372d142df4378cdea (diff)
parent1e4ec6217dcf4b26cf959b70298a3b990479c955 (diff)
Merge branch 'compat' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 compat wrapper rework from Heiko Carstens: "S390 compat system call wrapper simplification work. The intention of this work is to get rid of all hand written assembly compat system call wrappers on s390, which perform proper sign or zero extension, or pointer conversion of compat system call parameters. Instead all of this should be done with C code eg by using Al's COMPAT_SYSCALL_DEFINEx() macro. Therefore all common code and s390 specific compat system calls have been converted to the COMPAT_SYSCALL_DEFINEx() macro. In order to generate correct code all compat system calls may only have eg compat_ulong_t parameters, but no unsigned long parameters. Those patches which change parameter types from unsigned long to compat_ulong_t parameters are separate in this series, but shouldn't cause any harm. The only compat system calls which intentionally have 64 bit parameters (preadv64 and pwritev64) in support of the x86/32 ABI haven't been changed, but are now only available if an architecture defines __ARCH_WANT_COMPAT_SYS_PREADV64/PWRITEV64. System calls which do not have a compat variant but still need proper zero extension on s390, like eg "long sys_brk(unsigned long brk)" will get a proper wrapper function with the new s390 specific COMPAT_SYSCALL_WRAPx() macro: COMPAT_SYSCALL_WRAP1(brk, unsigned long, brk); which generates the following code (simplified): asmlinkage long sys_brk(unsigned long brk); asmlinkage long compat_sys_brk(long brk) { return sys_brk((u32)brk); } Given that the C file which contains all the COMPAT_SYSCALL_WRAP lines includes both linux/syscall.h and linux/compat.h, it will generate build errors, if the declaration of sys_brk() doesn't match, or if there exists a non-matching compat_sys_brk() declaration. In addition this will intentionally result in a link error if somewhere else a compat_sys_brk() function exists, which probably should have been used instead. Two more BUILD_BUG_ONs make sure the size and type of each compat syscall parameter can be handled correctly with the s390 specific macros. I converted the compat system calls step by step to verify the generated code is correct and matches the previous code. In fact it did not always match, however that was always a bug in the hand written asm code. In result we get less code, less bugs, and much more sanity checking" * 'compat' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (44 commits) s390/compat: add copyright statement compat: include linux/unistd.h within linux/compat.h s390/compat: get rid of compat wrapper assembly code s390/compat: build error for large compat syscall args mm/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types kexec/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types net/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types ipc/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types fs/compat: convert to COMPAT_SYSCALL_DEFINE with changing parameter types ipc/compat: convert to COMPAT_SYSCALL_DEFINE fs/compat: convert to COMPAT_SYSCALL_DEFINE security/compat: convert to COMPAT_SYSCALL_DEFINE mm/compat: convert to COMPAT_SYSCALL_DEFINE net/compat: convert to COMPAT_SYSCALL_DEFINE kernel/compat: convert to COMPAT_SYSCALL_DEFINE fs/compat: optional preadv64/pwrite64 compat system calls ipc/compat_sys_msgrcv: change msgtyp type from long to compat_long_t s390/compat: partial parameter conversion within syscall wrappers s390/compat: automatic zero, sign and pointer conversion of syscalls s390/compat: add sync_file_range and fallocate compat syscalls ...
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 28cc9c810744..31c6efa43183 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -994,9 +994,9 @@ COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
994 return ret; 994 return ret;
995} 995}
996 996
997COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd, 997static long __compat_sys_preadv64(unsigned long fd,
998 const struct compat_iovec __user *,vec, 998 const struct compat_iovec __user *vec,
999 unsigned long, vlen, loff_t, pos) 999 unsigned long vlen, loff_t pos)
1000{ 1000{
1001 struct fd f; 1001 struct fd f;
1002 ssize_t ret; 1002 ssize_t ret;
@@ -1013,12 +1013,22 @@ COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
1013 return ret; 1013 return ret;
1014} 1014}
1015 1015
1016#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
1017COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
1018 const struct compat_iovec __user *,vec,
1019 unsigned long, vlen, loff_t, pos)
1020{
1021 return __compat_sys_preadv64(fd, vec, vlen, pos);
1022}
1023#endif
1024
1016COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd, 1025COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd,
1017 const struct compat_iovec __user *,vec, 1026 const struct compat_iovec __user *,vec,
1018 compat_ulong_t, vlen, u32, pos_low, u32, pos_high) 1027 compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
1019{ 1028{
1020 loff_t pos = ((loff_t)pos_high << 32) | pos_low; 1029 loff_t pos = ((loff_t)pos_high << 32) | pos_low;
1021 return compat_sys_preadv64(fd, vec, vlen, pos); 1030
1031 return __compat_sys_preadv64(fd, vec, vlen, pos);
1022} 1032}
1023 1033
1024static size_t compat_writev(struct file *file, 1034static size_t compat_writev(struct file *file,
@@ -1061,9 +1071,9 @@ COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
1061 return ret; 1071 return ret;
1062} 1072}
1063 1073
1064COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd, 1074static long __compat_sys_pwritev64(unsigned long fd,
1065 const struct compat_iovec __user *,vec, 1075 const struct compat_iovec __user *vec,
1066 unsigned long, vlen, loff_t, pos) 1076 unsigned long vlen, loff_t pos)
1067{ 1077{
1068 struct fd f; 1078 struct fd f;
1069 ssize_t ret; 1079 ssize_t ret;
@@ -1080,12 +1090,22 @@ COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
1080 return ret; 1090 return ret;
1081} 1091}
1082 1092
1093#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
1094COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
1095 const struct compat_iovec __user *,vec,
1096 unsigned long, vlen, loff_t, pos)
1097{
1098 return __compat_sys_pwritev64(fd, vec, vlen, pos);
1099}
1100#endif
1101
1083COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd, 1102COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
1084 const struct compat_iovec __user *,vec, 1103 const struct compat_iovec __user *,vec,
1085 compat_ulong_t, vlen, u32, pos_low, u32, pos_high) 1104 compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
1086{ 1105{
1087 loff_t pos = ((loff_t)pos_high << 32) | pos_low; 1106 loff_t pos = ((loff_t)pos_high << 32) | pos_low;
1088 return compat_sys_pwritev64(fd, vec, vlen, pos); 1107
1108 return __compat_sys_pwritev64(fd, vec, vlen, pos);
1089} 1109}
1090#endif 1110#endif
1091 1111