* [merged mm-stable] kasan-test-only-do-kmalloc_double_kzfree-for-generic-mode.patch removed from -mm tree
@ 2026-06-02 22:26 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-06-02 22:26 UTC (permalink / raw)
To: mm-commits, vincenzo.frascino, ryabinin.a.a, glider, dvyukov,
andreyknvl, wsw9603, akpm
The quilt patch titled
Subject: kasan/test: only do kmalloc_double_kzfree for generic mode
has been removed from the -mm tree. Its filename was
kasan-test-only-do-kmalloc_double_kzfree-for-generic-mode.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Wang Wensheng <wsw9603@163.com>
Subject: kasan/test: only do kmalloc_double_kzfree for generic mode
Date: Sun, 24 May 2026 11:10:53 +0800
kmalloc_double_kzfree() would corrupt kernel memory when the just freed
memory were allocated by another thread before the second call to
kfree_sensitive() and the new allocation tag happened to match the old
one.
This could not happen in GENERIC mode as it uses quarantine.
Link: https://lore.kernel.org/20260524031053.381776-1-wsw9603@163.com
Signed-off-by: Wang Wensheng <wsw9603@163.com>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/kasan/kasan_test_c.c | 10 ++++++++++
1 file changed, 10 insertions(+)
--- a/mm/kasan/kasan_test_c.c~kasan-test-only-do-kmalloc_double_kzfree-for-generic-mode
+++ a/mm/kasan/kasan_test_c.c
@@ -874,6 +874,16 @@ static void kmalloc_double_kzfree(struct
char *ptr;
size_t size = 16;
+ /*
+ * With the tag-based KASAN modes, if the memory happens to be
+ * reallocated between the two frees and the new allocation tag happens
+ * to match the old one, the second free will cause a memory corruption.
+ * Resolving https://bugzilla.kernel.org/show_bug.cgi?id=212177 would
+ * help to deal with this. With Generic KASAN, it's effectively
+ * impossible for the memory to get reallocated due to the quarantine.
+ */
+ KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_GENERIC);
+
ptr = kmalloc(size, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
_
Patches currently in -mm which might be from wsw9603@163.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-02 22:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 22:26 [merged mm-stable] kasan-test-only-do-kmalloc_double_kzfree-for-generic-mode.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.