]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kasan: add test for SLAB_TYPESAFE_BY_RCU quarantine skipping
authorJann Horn <jannh@google.com>
Tue, 29 Jul 2025 16:49:40 +0000 (18:49 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:24:35 +0000 (17:24 -0700)
- 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 <jannh@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitriy 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

index 53d07d0bb1e144b4c6b3316818923d59d9a1c0e4..47ff5cd941c717b5bc9f9c26bf18b6d63c32b574 100644 (file)
@@ -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);
 }