Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()

From: Baolin Wang

Date: Fri Dec 04 2026 - 03:55:43 EST




On 12/3/26 4:00 AM, Elkin Cruz wrote:
insert_pmd() and insert_pud() currently check only that addr lies within
[vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
mapping fits below vma->vm_end.

All current in-tree callers already validate VMA end alignment/bounds,
so no existing user triggers this. Harden both helpers defensively by
requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().

Signed-off-by: Elkin Cruz <elkin@xxxxxxxxxx>
---

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>