[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1462869209-21096-1-git-send-email-aryabinin@virtuozzo.com>
Date: Tue, 10 May 2016 11:33:29 +0300
From: Andrey Ryabinin <aryabinin@...tuozzo.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: Ingo Molnar <mingo@...nel.org>, <kasan-dev@...glegroups.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>, <x86@...nel.org>,
Andrey Ryabinin <aryabinin@...tuozzo.com>
Subject: [PATCH] x86-kasan-instrument-user-memory-access-api-fix
Move kasan check under the condition, otherwise we may fail and not
do a user copy.
Reported-by: Ingo Molnar <mingo@...nel.org>
Signed-off-by: Andrey Ryabinin <aryabinin@...tuozzo.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
Powered by blists - more mailing lists