From: Andrey Konovalov <andreyknvl@gmail.com>
To: Marco Elver <elver@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Vlastimil Babka <vbabka@suse.cz>,
kasan-dev <kasan-dev@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH 2/2] kasan: test: add test case for double-kmem_cache_destroy()
Date: Fri, 19 Nov 2021 15:36:06 +0100 [thread overview]
Message-ID: <CA+fCnZdKLrniF4ru8G5=hkm4M6YYm3RJz6wFcNqD2hPC8Trj-g@mail.gmail.com> (raw)
In-Reply-To: <20211119142219.1519617-2-elver@google.com>
On Fri, Nov 19, 2021 at 3:22 PM Marco Elver <elver@google.com> wrote:
>
> Add a test case for double-kmem_cache_destroy() detection.
>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
> lib/test_kasan.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/lib/test_kasan.c b/lib/test_kasan.c
> index 40f7274297c1..4da4b214ed06 100644
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -866,6 +866,16 @@ static void kmem_cache_invalid_free(struct kunit *test)
> kmem_cache_destroy(cache);
> }
>
> +static void kmem_cache_double_destroy(struct kunit *test)
> +{
> + struct kmem_cache *cache;
> +
> + cache = kmem_cache_create("test_cache", 200, 0, 0, NULL);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cache);
> + kmem_cache_destroy(cache);
> + KUNIT_EXPECT_KASAN_FAIL(test, kmem_cache_destroy(cache));
> +}
> +
> static void kasan_memchr(struct kunit *test)
> {
> char *ptr;
> @@ -1183,6 +1193,7 @@ static struct kunit_case kasan_kunit_test_cases[] = {
> KUNIT_CASE(ksize_uaf),
> KUNIT_CASE(kmem_cache_double_free),
> KUNIT_CASE(kmem_cache_invalid_free),
> + KUNIT_CASE(kmem_cache_double_destroy),
> KUNIT_CASE(kasan_memchr),
> KUNIT_CASE(kasan_memcmp),
> KUNIT_CASE(kasan_strings),
> --
> 2.34.0.rc2.393.gf8c9666880-goog
>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Thanks!
next prev parent reply other threads:[~2021-11-19 14:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 14:22 [PATCH 1/2] kasan: add ability to detect double-kmem_cache_destroy() Marco Elver
2021-11-19 14:22 ` [PATCH 2/2] kasan: test: add test case for double-kmem_cache_destroy() Marco Elver
2021-11-19 14:36 ` Andrey Konovalov [this message]
2021-11-19 14:25 ` [PATCH 1/2] kasan: add ability to detect double-kmem_cache_destroy() Vlastimil Babka
2021-11-19 14:36 ` Andrey Konovalov
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='CA+fCnZdKLrniF4ru8G5=hkm4M6YYm3RJz6wFcNqD2hPC8Trj-g@mail.gmail.com' \
--to=andreyknvl@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=ryabinin.a.a@gmail.com \
--cc=vbabka@suse.cz \
/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