Re: mm/hugetlb: a min_size-only hugetlbfs subpool is kfree()d before its last pinned page is released, so free_huge_folio() takes a spinlock on freed memory (UAF)

From: Ackerley Tng

Date: Thu Nov 26 2026 - 00:52:08 EST


"David Hildenbrand (Arm)" <david@xxxxxxxxxx> writes:

> Hi Ackerley,
>
> does your series [1] actually fix this? What's the status of that?
>
> [1]
> https://lore.kernel.org/linux-mm/20260916-hugetlb-subpool-always-track-used-v3-0-38aae9b5ccdd@xxxxxxxxxx/
>

Hi!

Yes, "mm/hugetlb: Track used_hpages when getting/putting pages from
subpool" fixes this bug.

I've been tied up with other work since [1] was posted.

I have a set of reproducers locally for the various combinations of
min_size, max_size, and both defined, while taking various paths
(reservations vs actual allocations).

The plan was to always track used_hpages, which simplifies the
accounting and it does fix all the reproducers I have.

I thought in addition to simplifying and fixing all those paths, it
would always fix races, but AI showed me a repro with races that broke
the model.

Because of the repro, I planned to re-evaluate to see if there's a
better model/clean fix but haven't got around to that.

I'll try to get to it in the next few weeks?

Ackerley

> On 11/22/26 08:37, 徐晗翔 wrote:
>>
>> [...snip...]
>>
>
>
> --
> Cheers,
>
> David