Re: [PATCH v2 18/35] hugetlbfs: don't overflow the end of the unmap range on 32-bit

From: Jose A. Perez de Azpillaga

Date: Fri Dec 04 2026 - 06:10:56 EST


On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> When truncating a file or punching a hole, hugetlb_vmdelete_list() uses
> vma_offset_end() to translate the end of the range in the file to an
> address in the VMA, limited to the end of the VMA.
>
> However, the end of the range can lie far beyond the end of the VMA, and
> on 32-bit, calculating the address can overflow before we limit it.
>
> Consequently, we might unmap only part of the VMA, or nothing at all. For
> example, when punching a hole covering the first 4.5 GiB of a file that
> is mapped by a 1 GiB VMA, we only unmap the first 512 MiB of that VMA.
> hugetlb_unmap_file_folio() later unmaps the page cache folios, but
> anonymous folios in private mappings, and for example poison markers,
> stay in the hole.
>
> Let's fix it by checking whether the range ends beyond the VMA before
> calculating the address, which also simplifies the code.
>
> This has low urgency, as it requires 32-bit and punching a hole that
> extends 4 GiB or more past the start of a mapping. No need to CC stable.
>
> Fixes: 1bfad99ab425 ("hugetlbfs: hugetlb_vmtruncate_list() needs to take a range to delete")
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

LGTM:

Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>

--
cheers,
jose a. p-a