Re: [PATCH 1/2] mm/memfd_luo: reject memfds whose page count exceeds UINT_MAX

Pasha Tatashin
2026-05-01T19:38:39Z

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.

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>