From: Jann Horn Date: Tue, 29 Jul 2025 16:49:40 +0000 (+0200) Subject: kasan: add test for SLAB_TYPESAFE_BY_RCU quarantine skipping X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3c1a4ecb3f471cf95e3cc01b176adef4cb003b80;p=users%2Fjedix%2Flinux-maple.git kasan: add test for SLAB_TYPESAFE_BY_RCU quarantine skipping - disable migration to ensure that all SLUB operations use the same percpu state (vbabka) - use EXPECT instead of ASSERT for pointer equality check so that expectation failure doesn't terminate the test with migration still disabled Link: https://lkml.kernel.org/r/20250729-kasan-tsbrcu-noquarantine-test-v2-1-d16bd99309c9@google.com Signed-off-by: Jann Horn Acked-by: Vlastimil Babka Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Dmitriy Vyukov Cc: Vincenzo Frascino Signed-off-by: Andrew Morton --- diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c index 53d07d0bb1e14..47ff5cd941c71 100644 --- a/mm/kasan/kasan_test_c.c +++ b/mm/kasan/kasan_test_c.c @@ -1088,23 +1088,25 @@ static void kmem_cache_rcu_reuse(struct kunit *test) NULL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cache); + migrate_disable(); p = kmem_cache_alloc(cache, GFP_KERNEL); if (!p) { kunit_err(test, "Allocation failed: %s\n", __func__); - kmem_cache_destroy(cache); - return; + goto out; } kmem_cache_free(cache, p); p2 = kmem_cache_alloc(cache, GFP_KERNEL); if (!p2) { kunit_err(test, "Allocation failed: %s\n", __func__); - kmem_cache_destroy(cache); - return; + goto out; } - KUNIT_ASSERT_PTR_EQ(test, p, p2); + KUNIT_EXPECT_PTR_EQ(test, p, p2); kmem_cache_free(cache, p2); + +out: + migrate_enable(); kmem_cache_destroy(cache); }