Re: [PATCH 1/2] mm/memfd_luo: reject memfds whose page count exceeds UINT_MAX
From: Pratyush Yadav
Date: Mon May 04 2026 - 04:10:13 EST
On Fri, May 01 2026, Pasha Tatashin wrote:
> On 05-01 20:26, David CARLIER wrote:
>> On 2026-05-01 18:59, Pasha Tatashin wrote:
>> > I think, the fix should be first done at memfd_pin_folios() to
>> change
>> > max_folios to 'long' or 'unsigned long', and then just updated
>> > memfd_luo.c to match.
>>
>> Even with memfd_pin_folios() widened, memfd_luo_preserve_folios()
>> still
>> kvmalloc_objs()s the folios array up front -- at UINT_MAX entries
>> that's
>> already ~32 GiB of pointer array, which won't realistically succeed.
>> So
>> the guard here still makes sense, just on allocation grounds rather than
>> interface truncation.
>>
>> Happy to widen memfd_pin_folios() as a separate patch, but I'd keep
>> the
>> -EFBIG check regardless. Or did you have a different shape in mind?
>
> Ah, Good point about kvmalloc_objs(), I am not against this, even though
> it is a very theoretical issue.
Yeah. I plan to get rid of the pinning anyway and do this via the page
cache directly (might be easier said than done though), so this should
be fine for now I think. I suspect we might run into a lot more problems
if we get a memfd like this anyway.
Reviewed-by: Pratyush Yadav <pratyush@xxxxxxxxxx>
>
> Reviewed-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
--
Regards,
Pratyush Yadav