diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-27 10:10:53 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-06 02:08:06 -0400 |
commit | f0a955f4eeec0f16bdbdd0fb15d8ec0937d1de23 (patch) | |
tree | 1e77a3e2c8d597c699ea50ac16f1e2d83a232b26 /arch/mips/include/asm/uaccess.h | |
parent | 054838bc019c90511d034fb796dc8c7715460fc2 (diff) |
mips: sanitize __access_ok()
for one thing, the last argument is always __access_mask and had been such
since 2.4.0-test3pre8; for another, it can bloody well be a static inline -
-O2 or -Os, __builtin_constant_p() propagates through static inline calls.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/mips/include/asm/uaccess.h')
-rw-r--r-- | arch/mips/include/asm/uaccess.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index 70ca8eee166a..0c59911349ce 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h @@ -128,23 +128,14 @@ static inline bool eva_kernel_access(void) * this function, memory access functions may still return -EFAULT. */ -#define __access_mask get_fs().seg - -#define __access_ok(addr, size, mask) \ -({ \ - unsigned long __addr = (unsigned long) (addr); \ - unsigned long __size = size; \ - unsigned long __mask = mask; \ - unsigned long __ok; \ - \ - __chk_user_ptr(addr); \ - __ok = (signed long)(__mask & (__addr | (__addr + __size) | \ - __ua_size(__size))); \ - __ok == 0; \ -}) +static inline int __access_ok(const void __user *p, unsigned long size) +{ + unsigned long addr = (unsigned long)p; + return (get_fs().seg & (addr | (addr + size) | __ua_size(size))) == 0; +} #define access_ok(type, addr, size) \ - likely(__access_ok((addr), (size), __access_mask)) + likely(__access_ok((addr), (size))) /* * put_user: - Write a simple value into user space. |