aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Long <long.wanglong@huawei.com>2015-11-05 18:51:18 -0800
committerAlex Shi <alex.shi@linaro.org>2016-04-11 22:59:43 +0800
commit776dee31a8e0d8b4424827ba338f14ecd318debd (patch)
treea7ba253b2ce42b9ce9abb9723737ee9d60cefcd4
parent0c0922ebaba9d173d54740f12aaffe8d868abf7c (diff)
downloadlinux-linaro-stable-776dee31a8e0d8b4424827ba338f14ecd318debd.tar.gz
kasan: Fix a type conversion error
The current KASAN code can not find the following out-of-bounds bugs: char *ptr; ptr = kmalloc(8, GFP_KERNEL); memset(ptr+7, 0, 2); the cause of the problem is the type conversion error in *memory_is_poisoned_n* function. So this patch fix that. Signed-off-by: Wang Long <long.wanglong@huawei.com> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit e0d57714394f5e2ce4e2f9bbebf48e3c7a7fd3be) Signed-off-by: Alex Shi <alex.shi@linaro.org>
-rw-r--r--mm/kasan/kasan.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index c5a1e264610d..1a665070fbe9 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -203,7 +203,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned long addr,
s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
if (unlikely(ret != (unsigned long)last_shadow ||
- ((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
+ ((long)(last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
return true;
}
return false;