diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2014-03-05 12:55:06 +0100 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2014-03-06 16:30:47 +0100 |
commit | 9a205286bcca84b38d3ab1689f16236d1935af2d (patch) | |
tree | 22efb323509c3473f1a0af779194a72406cb819c /arch/s390/include | |
parent | 2f2728f6de9837abe4b354443a45be578fbbf942 (diff) | |
download | linux-9a205286bcca84b38d3ab1689f16236d1935af2d.tar.bz2 |
s390/compat: build error for large compat syscall args
Enforce 32 bit types for all compat syscall argument types.
This way we can make sure that all arguments get correct sign
or zero extension. Otherwise incorrect code would be generated.
E.g. for a 'long' type the COMPAT_SYSCALL_DEFINE macro wouldn't
generate code that would cause sign extension of the passed in 32
bit user space parameter.
This can cause quite subtle bugs like e.g. the one that was fixed
with dfd948e32af2e "fs/compat: fix parameter handling for compat
readv/writev syscalls".
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'arch/s390/include')
-rw-r--r-- | arch/s390/include/asm/compat.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h index 5d7e8cf83bd6..d350ed9d0fbb 100644 --- a/arch/s390/include/asm/compat.h +++ b/arch/s390/include/asm/compat.h @@ -8,7 +8,11 @@ #include <linux/thread_info.h> #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p(typeof(0?(t)0:0ULL), u64)) -#define __SC_DELOUSE(t,v) (t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)) + +#define __SC_DELOUSE(t,v) ({ \ + BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \ + (t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \ +}) #define PSW32_MASK_PER 0x40000000UL #define PSW32_MASK_DAT 0x04000000UL |