mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kasan/test: only do kmalloc_double_kzfree for generic mode
@ 2026-05-17  7:17 Wang Wensheng
  2026-05-20 18:19 ` Andrey Konovalov
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Wensheng @ 2026-05-17  7:17 UTC (permalink / raw)
  To: ryabinin.a.a, glider, andreyknvl, dvyukov, vincenzo.frascino,
	akpm, kasan-dev, linux-mm, linux-kernel
  Cc: wsw9603

kmalloc_double_kzfree() would corrupt kernel memory when the just
freed memory were allocated by another thread before the second
call to kfree_sensitive().

This could not happen in GENERIC mode as it uses quarantine.

Signed-off-by: Wang Wensheng <wsw9603@163.com>
---
 mm/kasan/kasan_test_c.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c
index 32d06cbf6a31..02e43ccc9f21 100644
--- a/mm/kasan/kasan_test_c.c
+++ b/mm/kasan/kasan_test_c.c
@@ -874,6 +874,12 @@ static void kmalloc_double_kzfree(struct kunit *test)
 	char *ptr;
 	size_t size = 16;
 
+	/*
+	 * Only generic KASAN uses quarantine, which could prevent the just freed
+	 * memory from being allocated soon.
+	 */
+	KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_GENERIC);
+
 	ptr = kmalloc(size, GFP_KERNEL);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-24  3:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-17  7:17 [PATCH] kasan/test: only do kmalloc_double_kzfree for generic mode Wang Wensheng
2026-05-20 18:19 ` Andrey Konovalov
2026-05-24  3:17   ` wangwensheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®