diff options
author | David S. Miller <davem@davemloft.net> | 2009-12-11 08:05:23 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-11 08:05:23 +0100 |
commit | fb34035e7b4bb3edc7c2dc0683cfe21f57a9574d (patch) | |
tree | ddde17e5690d77f4f61c6271fc8b6f520c746851 /arch/sparc/include/asm/uaccess_32.h | |
parent | sparc64: Add some missing __kprobes annotations to kernel fault paths. (diff) | |
download | linux-fb34035e7b4bb3edc7c2dc0683cfe21f57a9574d.tar.xz linux-fb34035e7b4bb3edc7c2dc0683cfe21f57a9574d.zip |
sparc: Use __builtin_object_size() to validate the buffer size for copy_from_user()
This mirrors x86 commit 9f0cf4adb6aa0bfccf675c938124e68f7f06349d
(x86: Use __builtin_object_size() to validate the buffer size for copy_from_user())
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/include/asm/uaccess_32.h')
-rw-r--r-- | arch/sparc/include/asm/uaccess_32.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h index 8303ac481034..489d2ba92bcb 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h @@ -260,8 +260,23 @@ static inline unsigned long __copy_to_user(void __user *to, const void *from, un return __copy_user(to, (__force void __user *) from, n); } +extern void copy_from_user_overflow(void) +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS + __compiletime_error("copy_from_user() buffer size is not provably correct") +#else + __compiletime_warning("copy_from_user() buffer size is not provably correct") +#endif +; + static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) { + int sz = __compiletime_object_size(to); + + if (unlikely(sz != -1 && sz < n)) { + copy_from_user_overflow(); + return -EFAULT; + } + if (n && __access_ok((unsigned long) from, n)) return __copy_user((__force void __user *) to, from, n); else |