Re: [PATCH v2 14/35] hugetlbfs: fix integer overflow when punching holes
From: Muchun Song
Date: Fri Dec 04 2026 - 01:18:01 EST
> On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> hugetlbfs_punch_hole() rounds up the offset to find the first full huge
> page in the hole, and zeroes the partial huge page before it, starting at
> the offset.
>
> However, if the offset falls into the last possible huge page below
> LLONG_MAX, but not at its start, rounding up overflows and hole_start
> becomes LLONG_MIN.
>
> Consequently, we will zero from the start of that huge page, not from the
> offset.
>
> Reproduced by allocating that huge page with fallocate(), placing data in
> it through udmabuf, and punching a hole starting inside it: the data
> before the hole gets zeroed.
>
> Let's fix it by clamping hole_start to offset + len on overflow, as
> there are no full huge pages in the hole in that case.
>
> This has low urgency: hugetlbfs supports neither write() nor mmap() of
> that last huge page, so only something like udmabuf could place data
> there, which no reasonable use case does. No need to CC stable.
>
> Fixes: 68d32527d340 ("hugetlbfs: zero partial pages during fallocate hole punch")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
Thanks.