From: Wang Long Date: Wed, 9 Sep 2015 22:37:22 +0000 (-0700) Subject: lib/test_kasan.c: make kmalloc_oob_krealloc_less more correctly X-Git-Tag: firefly_0821_release~176^2~1085^2~51 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6b4a35fc19a9229080dead8a9c316e8857b3e94d;p=firefly-linux-kernel-4.4.55.git lib/test_kasan.c: make kmalloc_oob_krealloc_less more correctly In kmalloc_oob_krealloc_less, I think it is better to test the size2 boundary. If we do not call krealloc, the access of position size1 will still cause out-of-bounds and access of position size2 does not. After call krealloc, the access of position size2 cause out-of-bounds. So using size2 is more correct. Signed-off-by: Wang Long Cc: Andrey Ryabinin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 044c54dd43fd..c1efb1b61017 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -114,7 +114,7 @@ static noinline void __init kmalloc_oob_krealloc_less(void) kfree(ptr1); return; } - ptr2[size1] = 'x'; + ptr2[size2] = 'x'; kfree(ptr2); }