diff options
author | Kees Cook <keescook@chromium.org> | 2021-11-05 13:36:12 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-11-06 13:30:33 -0700 |
commit | d73dad4eb5ad8c31ac9cf358eb5a55825bafe706 (patch) | |
tree | 34585db952518be749bae401a60156977f93b540 /lib/test_kasan_module.c | |
parent | 8772716f96704c67b1e2a6ba175605b4fce2a252 (diff) | |
download | linux-d73dad4eb5ad8c31ac9cf358eb5a55825bafe706.tar.gz linux-d73dad4eb5ad8c31ac9cf358eb5a55825bafe706.tar.bz2 linux-d73dad4eb5ad8c31ac9cf358eb5a55825bafe706.zip |
kasan: test: bypass __alloc_size checks
Intentional overflows, as performed by the KASAN tests, are detected at
compile time[1] (instead of only at run-time) with the addition of
__alloc_size. Fix this by forcing the compiler into not being able to
trust the size used following the kmalloc()s.
[1] https://lore.kernel.org/lkml/20211005184717.65c6d8eb39350395e387b71f@linux-foundation.org
Link: https://lkml.kernel.org/r/20211006181544.1670992-1-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/test_kasan_module.c')
-rw-r--r-- | lib/test_kasan_module.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/test_kasan_module.c b/lib/test_kasan_module.c index 7ebf433edef3..b112cbc835e9 100644 --- a/lib/test_kasan_module.c +++ b/lib/test_kasan_module.c @@ -35,6 +35,8 @@ static noinline void __init copy_user_test(void) return; } + OPTIMIZER_HIDE_VAR(size); + pr_info("out-of-bounds in copy_from_user()\n"); unused = copy_from_user(kmem, usermem, size + 1); |