From: Andrey Konovalov <andreyknvl@google.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Nick Terrell <terrelln@fb.com>, Chris Mason <clm@fb.com>,
Yury Norov <ynorov@caviumnetworks.com>,
Al Viro <viro@zeniv.linux.org.uk>,
"Luis R . Rodriguez" <mcgrof@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
Jeff Layton <jlayton@redhat.com>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
LKML <linux-kernel@vger.kernel.org>,
kasan-dev <kasan-dev@googlegroups.com>,
Linux Memory Management List <linux-mm@kvack.org>
Cc: Kostya Serebryany <kcc@google.com>,
Andrey Konovalov <andreyknvl@google.com>
Subject: Re: [PATCH 1/2] kasan: fix invalid-free test crashing the kernel
Date: Thu, 1 Mar 2018 18:28:52 +0100 [thread overview]
Message-ID: <CAAeHK+w86uMUrJjwV1Sei=N4udhfTmWab5e3FuT72=BEMcCu3A@mail.gmail.com> (raw)
In-Reply-To: <286eaefc0a6c3fa9b83b87e7d6dc0fbb5b5c9926.1519924383.git.andreyknvl@google.com>
On Thu, Mar 1, 2018 at 6:15 PM, Andrey Konovalov <andreyknvl@google.com> wrote:
> 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.
Note, that for this patch to fix the issue, it is supposed to go on
top of the "kasan, slub: fix handling of kasan_slab_free hook" patch I
sent recently.
https://patchwork.kernel.org/patch/10238179/
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> lib/test_kasan.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> index 98854a64b014..ec657105edbf 100644
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -567,7 +567,15 @@ static noinline void __init kmem_cache_invalid_free(void)
> 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);
> }
>
> --
> 2.16.2.395.g2e18187dfd-goog
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-03-01 17:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 17:15 [PATCH 0/2] kasan: a couple of test fixes Andrey Konovalov
2018-03-01 17:15 ` [PATCH 1/2] kasan: fix invalid-free test crashing the kernel Andrey Konovalov
2018-03-01 17:28 ` Andrey Konovalov [this message]
2018-03-02 12:11 ` Andrey Ryabinin
2018-03-01 17:15 ` [PATCH 2/2] kasan: disallow compiler to optimize away memset in tests Andrey Konovalov
2018-03-02 12:11 ` Andrey Ryabinin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAeHK+w86uMUrJjwV1Sei=N4udhfTmWab5e3FuT72=BEMcCu3A@mail.gmail.com' \
--to=andreyknvl@google.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=clm@fb.com \
--cc=dvyukov@google.com \
--cc=geert@linux-m68k.org \
--cc=glider@google.com \
--cc=jlayton@redhat.com \
--cc=kasan-dev@googlegroups.com \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=terrelln@fb.com \
--cc=viro@zeniv.linux.org.uk \
--cc=ynorov@caviumnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox