summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2016-08-31 16:04:21 -0700
committerAlex Shi <alex.shi@linaro.org>2016-10-05 13:11:53 +0200
commit1b4b2f16f6759bf5b0937a475e82f677e813f304 (patch)
tree812ec8cab455a9d5510d7e81b5606f00fab53756 /include/linux
parented67fb82b17db1f5e3c7818e10560814c7d2e019 (diff)
usercopy: fold builtin_const check into inline function
Instead of having each caller of check_object_size() need to remember to check for a const size parameter, move the check into check_object_size() itself. This actually matches the original implementation in PaX, though this commit cleans up the now-redundant builtin_const() calls in the various architectures. Signed-off-by: Kees Cook <keescook@chromium.org> (cherry picked from commit 81409e9e28058811c9ea865345e1753f8f677e44) Signed-off-by: Alex Shi <alex.shi@linaro.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/thread_info.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 0ae29ff9ccfd..eded095fe81e 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -161,7 +161,8 @@ extern void __check_object_size(const void *ptr, unsigned long n,
static inline void check_object_size(const void *ptr, unsigned long n,
bool to_user)
{
- __check_object_size(ptr, n, to_user);
+ if (!__builtin_constant_p(n))
+ __check_object_size(ptr, n, to_user);
}
#else
static inline void check_object_size(const void *ptr, unsigned long n,