diff options
| author | Alexander Potapenko <glider@google.com> | 2026-01-13 10:11:51 +0100 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-01-26 20:02:32 -0800 |
| commit | 737dfe7d95263ae8e47e07a528e3676ffad6f59a (patch) | |
| tree | 315ec1559016b95feaa9d76a39d5ca19ab357049 | |
| parent | 79ffad20ebc05eb4e5dc942cdedbfbf0796c18c9 (diff) | |
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>
| -rw-r--r-- | mm/kmsan/kmsan_test.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mm/kmsan/kmsan_test.c b/mm/kmsan/kmsan_test.c index ba44bf2072bb..81e642db6e23 100644 --- a/mm/kmsan/kmsan_test.c +++ b/mm/kmsan/kmsan_test.c @@ -378,6 +378,20 @@ static void test_uaf(struct kunit *test) KUNIT_EXPECT_TRUE(test, report_matches(&expect)); } +static void test_uninit_page(struct kunit *test) +{ + EXPECTATION_UNINIT_VALUE(expect); + struct page *page; + int *ptr; + + kunit_info(test, "uninitialized page allocation (UMR report)\n"); + page = alloc_pages(GFP_KERNEL, 0); + ptr = page_address(page); + USE(*ptr); + __free_pages(page, 0); + KUNIT_EXPECT_TRUE(test, report_matches(&expect)); +} + static volatile char *test_uaf_pages_helper(int order, int offset) { struct page *page; @@ -727,6 +741,7 @@ static struct kunit_case kmsan_test_cases[] = { KUNIT_CASE(test_uninit_kmsan_check_memory), KUNIT_CASE(test_init_kmsan_vmap_vunmap), KUNIT_CASE(test_init_vmalloc), + KUNIT_CASE(test_uninit_page), KUNIT_CASE(test_uaf), KUNIT_CASE(test_uaf_pages), KUNIT_CASE(test_uaf_high_order_pages), |
