The PTE loop stops only at addr == end. An unaligned end is never reached, so the loop keeps clearing past the range. An unaligned start clears the page below the range first. Both are caller bugs, and the damage is hard to attribute afterwards.
vmap only installs page aligned mappings, so an unaligned unmap request is never a legitimate teardown. Warn and bail out at the entry of __vunmap_range_noflush(), before any PTE is cleared. Reported-by: Sashiko <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Hao Ge <[email protected]> --- mm/vmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a168f6f20f4f..e2b63cb1592b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -523,6 +523,9 @@ void __vunmap_range_noflush(unsigned long start, unsigned long end, pgtbl_mod_mask mask = 0; BUG_ON(addr >= end); + if (WARN_ON_ONCE(!PAGE_ALIGNED(addr) || !PAGE_ALIGNED(end))) + return; + pgd = pgd_offset_k(addr); do { next = pgd_addr_end(addr, end); -- 2.25.1
