Messages in this thread Patch in this message | | | From | Andrey Ryabinin <> | Subject | [PATCH] x86-kasan-instrument-user-memory-access-api-fix | Date | Tue, 10 May 2016 11:33:29 +0300 |
| |
Move kasan check under the condition, otherwise we may fail and not do a user copy.
Reported-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> --- lib/strncpy_from_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index e3472b0..33f655e 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -104,13 +104,13 @@ long strncpy_from_user(char *dst, const char __user *src, long count) if (unlikely(count <= 0)) return 0; - kasan_check_write(dst, count); max_addr = user_addr_max(); src_addr = (unsigned long)src; if (likely(src_addr < max_addr)) { unsigned long max = max_addr - src_addr; long retval; + kasan_check_write(dst, count); user_access_begin(); retval = do_strncpy_from_user(dst, src, count, max); user_access_end(); -- 2.7.3
| |