Re: [PATCH v2 17/35] hugetlbfs: don't overflow the pseudo VMA address in fallocate()
From: Jose A. Perez de Azpillaga
Date: Fri Dec 04 2026 - 06:09:13 EST
On 12/3/26 12:37 PM, David Hildenbrand (Arm) wrote:
> hugetlbfs_fallocate() allocates folios through a pseudo VMA that starts
> at address 0 and file offset 0. It passes the file offset of the folio
> as the address. The reservation code then derives the reserve map index
> of the folio from that address. Confusing.
>
> However, on 32-bit, that address overflows for file offsets at or above
> 4 GiB, while we still add the folio to the page cache at the real index.
>
> Consequently, fallocate() of a single hugetlb folio at offset 4 GiB
> consumes or restores the reservation at index 0, messing up the reservation
> accounting on truncation and eviction.
>
> Let's fix it by setting the file offset of the folio in the pseudo VMA
> instead, and passing address 0.
>
> This has low urgency, as it only affects 32-bit kernels with hugetlb.
> No need to CC stable.
>
> Fixes: 70c3547e36f5 ("hugetlbfs: add hugetlbfs_fallocate()")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a