Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
From: Barry Song
Date: Thu Dec 03 2026 - 01:04:28 EST
On Thu, Dec 3, 2026 at 4:01 AM Elkin Cruz <elkin@xxxxxxxxxx> 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>
> ---
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>