mm-kasan-kunit-extend-vmalloc-oob-tests-to-cover-vrealloc.patch removed from -mm tree
The quilt patch titled
Subject: mm/kasan/kunit: extend vmalloc OOB tests to cover vrealloc()
has been removed from the -mm tree. Its filename was
mm-kasan-kunit-extend-vmalloc-oob-tests-to-cover-vrealloc.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Andrey Ryabinin <[email protected]>
Subject: mm/kasan/kunit: extend vmalloc OOB tests to cover vrealloc()
Date: Tue, 13 Jan 2026 20:15:16 +0100
Extend the vmalloc_oob() test to validate OOB detection after resizing vmalloc allocations with vrealloc().
The test now verifies that KASAN correctly poisons and unpoisons vmalloc memory when allocations are shrunk and expanded, ensuring OOB accesses are reliably detected after each resize.
---
mm/kasan/kasan_test_c.c | 50 ++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-)
mm/kasan/kasan_test_c.c renamed from mm/kasan/kasan_test_c.c~mm-kasan-kunit-extend-vmalloc-oob-tests-to-cover-vrealloc +35 -15
@@ -1840,6 +1840,29 @@ static void vmalloc_helpers_tags(structvfree (ptr); } +static void vmalloc_oob_helper (struct kunit *test,char *v_ptr,size_t size) +{ +/* +* We have to be careful not to hit the guard page in vmalloc tests. +* The MMU will catch that and crash us. +*/ + +/* Make sure in-bounds accesses are valid. */ + v_ptr[0 ] =0 ; + v_ptr[size -1 ] =0 ; + +/* +* An unaligned access past the requested vmalloc size. +* Only generic KASAN can precisely detect these. +*/ +if (IS_ENABLED (CONFIG_KASAN_GENERIC )) +KUNIT_EXPECT_KASAN_FAIL (test, ((volatile char *)v_ptr)[size]); + +/* An aligned access into the first out-of-bounds granule. */ + size =round_up (size,KASAN_GRANULE_SIZE ); +KUNIT_EXPECT_KASAN_FAIL_READ (test, ((volatile char *)v_ptr)[size]); +} +static void vmalloc_oob (struct kunit *test) {char *v_ptr, *p_ptr;
@@ -1856,24 +1879,21 @@ static void vmalloc_oob(struct kunit *teOPTIMIZER_HIDE_VAR (v_ptr); -/* -* We have to be careful not to hit the guard page in vmalloc tests. -* The MMU will catch that and crash us. -*/ +vmalloc_oob_helper (test, v_ptr, size); -/* Make sure in-bounds accesses are valid. */ - v_ptr[0 ] =0 ; - v_ptr[size -1 ] =0 ; + size -=KASAN_GRANULE_SIZE +1 ; + v_ptr =vrealloc (v_ptr, size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, v_ptr); -/* -* An unaligned access past the requested vmalloc size. -* Only generic KASAN can precisely detect these. -*/ -if (IS_ENABLED (CONFIG_KASAN_GENERIC )) -KUNIT_EXPECT_KASAN_FAIL (test, ((volatile char *)v_ptr)[size]); +OPTIMIZER_HIDE_VAR (v_ptr); -/* An aligned access into the first out-of-bounds granule. */ -KUNIT_EXPECT_KASAN_FAIL_READ (test, ((volatile char *)v_ptr)[size +5 ]); +vmalloc_oob_helper (test, v_ptr, size); + + size +=2 *KASAN_GRANULE_SIZE +2 ; + v_ptr =vrealloc (v_ptr, size,GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, v_ptr); + +vmalloc_oob_helper (test, v_ptr, size);/* Check that in-bounds accesses to the physical page are valid. */ page =vmalloc_to_page (v_ptr);
_
Patches currently in -mm which might be from [email protected] are