Re: [PATCH v4] mm: vmalloc: WARN_ON if mapping size is not PAGE_SIZE aligned

From: Dev Jain
Date: Fri Oct 10 2025 - 01:46:44 EST



On 10/10/25 7:13 am, Yadong Qi wrote:
In mm/vmalloc.c, the function vmap_pte_range() assumes that the
mapping size is aligned to PAGE_SIZE. If this assumption is
violated, the loop will become infinite because the termination
condition (`addr != end`) will never be met. This can lead to
overwriting other VA ranges and/or random pages physically follow
the page table.

It's the caller's responsibility to ensure that the mapping size
is aligned to PAGE_SIZE. However, the memory corruption is hard
to root cause. To identify the programming error in the caller
easier, check whether the mapping size is PAGE_SIZE aligned with
WARN_ON_ONCE().

Signed-off-by: Yadong Qi <yadong.qi@xxxxxxxxxxxxxxxxx>
Reviewed-by: Huang Ying <ying.huang@xxxxxxxxxxxxxxxxx>
---

This should work.

Reviewed-by: Dev Jain <dev.jain@xxxxxxx>