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

From: David Hildenbrand (Arm)

Date: Wed Dec 02 2026 - 08:34:38 EST


On 12/2/26 02:52, Elkin Cruz wrote:
> On Thu, Nov 26, 2026 at 3:23 AM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
>> For the code here, couldn't we do something like
>>
>> if (addr < vma->vm_start ||
>> addr + HPAGE_PMD_SIZE >= vma->vm_end )
>>
>> ... not sure if we'd have to care about overflows.
>
> Sorry for the belated reply.
>
> I have checked with help of an AI agent and they argue that
> vma->vm_end is exclusive
> (addr + HPAGE_PMD_SIZE == vma->vm_end). Thus ">= would reject the
> last PMD/PUD of every aligned VMA with VM_FAULT_SIGBUS", so it has
> to be >.
>
> I can send a new v2 if you want with:
>
> if (addr < vma->vm_start ||
> addr + HPAGE_PMD_SIZE > vma->vm_end )

Yeah that's what I meant.

--
Cheers,

David