Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: kmsan: add test_uninit_page

Test that pages allocated with alloc_page() are uninitialized by default.

Link: https://lkml.kernel.org/r/20260113091151.4035013-2-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Alexander Potapenko and committed by
Andrew Morton
737dfe7d 79ffad20

+15
+15
mm/kmsan/kmsan_test.c
··· 378 378 KUNIT_EXPECT_TRUE(test, report_matches(&expect)); 379 379 } 380 380 381 + static void test_uninit_page(struct kunit *test) 382 + { 383 + EXPECTATION_UNINIT_VALUE(expect); 384 + struct page *page; 385 + int *ptr; 386 + 387 + kunit_info(test, "uninitialized page allocation (UMR report)\n"); 388 + page = alloc_pages(GFP_KERNEL, 0); 389 + ptr = page_address(page); 390 + USE(*ptr); 391 + __free_pages(page, 0); 392 + KUNIT_EXPECT_TRUE(test, report_matches(&expect)); 393 + } 394 + 381 395 static volatile char *test_uaf_pages_helper(int order, int offset) 382 396 { 383 397 struct page *page; ··· 741 727 KUNIT_CASE(test_uninit_kmsan_check_memory), 742 728 KUNIT_CASE(test_init_kmsan_vmap_vunmap), 743 729 KUNIT_CASE(test_init_vmalloc), 730 + KUNIT_CASE(test_uninit_page), 744 731 KUNIT_CASE(test_uaf), 745 732 KUNIT_CASE(test_uaf_pages), 746 733 KUNIT_CASE(test_uaf_high_order_pages),