diff options
author | Kees Cook <keescook@chromium.org> | 2016-06-23 15:10:13 -0700 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2016-07-26 14:41:52 -0700 |
commit | 9d9208a15800f9f06f102f9aac1e8b323c3b8575 (patch) | |
tree | 45ec25224b6dae6634bb6fadc7e679c4cae2a404 /arch/sparc/include/asm/uaccess_32.h | |
parent | 1d3c1324746fed0e34a5b94d3ed303e7521ed603 (diff) | |
download | blackbird-op-linux-9d9208a15800f9f06f102f9aac1e8b323c3b8575.tar.gz blackbird-op-linux-9d9208a15800f9f06f102f9aac1e8b323c3b8575.zip |
sparc/uaccess: Enable hardened usercopy
Enables CONFIG_HARDENED_USERCOPY checks on sparc.
Based on code from PaX and grsecurity.
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'arch/sparc/include/asm/uaccess_32.h')
-rw-r--r-- | arch/sparc/include/asm/uaccess_32.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h index 57aca2792d29..341a5a133f48 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h @@ -248,22 +248,28 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { - if (n && __access_ok((unsigned long) to, n)) + if (n && __access_ok((unsigned long) to, n)) { + if (!__builtin_constant_p(n)) + check_object_size(from, n, true); return __copy_user(to, (__force void __user *) from, n); - else + } else return n; } static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) { + if (!__builtin_constant_p(n)) + check_object_size(from, n, true); return __copy_user(to, (__force void __user *) from, n); } static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) { - if (n && __access_ok((unsigned long) from, n)) + if (n && __access_ok((unsigned long) from, n)) { + if (!__builtin_constant_p(n)) + check_object_size(to, n, false); return __copy_user((__force void __user *) to, from, n); - else + } else return n; } |