Re: [PATCH v2 17/35] hugetlbfs: don't overflow the pseudo VMA address in fallocate()

From: Muchun Song

Date: Fri Dec 04 2026 - 01:20:35 EST




> On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) <david@xxxxxxxxxx> 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>

Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>

Thanks.