The patch titled Subject: kasan: fix invalid-free test crashing the kernel has been added to the -mm tree. Its filename is kasan-fix-invalid-free-test-crashing-the-kernel.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kasan-fix-invalid-free-test-crashing-the-kernel.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kasan-fix-invalid-free-test-crashing-the-kernel.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Subject: kasan: fix invalid-free test crashing the kernel When an invalid-free is triggered by one of the KASAN tests, the object doesn't actually get freed. This later leads to a BUG failure in kmem_cache_destroy that checks that there are no allocated objects in the cache that is being destroyed. Fix this by calling kmem_cache_free with the proper object address after the call that triggers invalid-free. Link: http://lkml.kernel.org/r/286eaefc0a6c3fa9b83b87e7d6dc0fbb5b5c9926.1519924383.git.andreyknvl@xxxxxxxxxx Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: Nick Terrell <terrelln@xxxxxx> Cc: Chris Mason <clm@xxxxxx> Cc: Yury Norov <ynorov@xxxxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: "Luis R . Rodriguez" <mcgrof@xxxxxxxxxx> Cc: Palmer Dabbelt <palmer@xxxxxxxxxxx> Cc: "Paul E . McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> Cc: Jeff Layton <jlayton@xxxxxxxxxx> Cc: "Jason A . Donenfeld" <Jason@xxxxxxxxx> Cc: Kostya Serebryany <kcc@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/test_kasan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff -puN lib/test_kasan.c~kasan-fix-invalid-free-test-crashing-the-kernel lib/test_kasan.c --- a/lib/test_kasan.c~kasan-fix-invalid-free-test-crashing-the-kernel +++ a/lib/test_kasan.c @@ -567,7 +567,15 @@ static noinline void __init kmem_cache_i return; } + /* Trigger invalid free, the object doesn't get freed */ kmem_cache_free(cache, p + 1); + + /* + * Properly free the object to prevent the "Objects remaining in + * test_cache on __kmem_cache_shutdown" BUG failure. + */ + kmem_cache_free(cache, p); + kmem_cache_destroy(cache); } _ Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are kasan-slub-fix-handling-of-kasan_slab_free-hook.patch kasan-fix-invalid-free-test-crashing-the-kernel.patch kasan-disallow-compiler-to-optimize-away-memset-in-tests.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html