Re: [PATCH v2 5/5] mm/gup: limit pagecache folio refcount when grabbing references
From: Jose A. Perez de Azpillaga
Date: Mon Nov 09 2026 - 04:15:32 EST
On 11/7/26 11:23 PM, David Hildenbrand (Arm) wrote:
> Let's add a folio_ref_count_over_limit() check in fast and slow GUP
> before acquiring additional references or pins.
>
> Keep it simple and use the check for all folio types.
>
> Don't check capabilities with IRQs disabled, as even unaudited capability
> checks can take locks. Refuse access to the admin reserve, so GUP-fast will
> fail and fall back to GUP-slow if possible.
>
> Also propagate try_grab_folio() errors when grabbing additional
> references in __get_user_pages() and in memfd_pin_folios(), so hitting
> the limit returns -ENOMEM instead of -EFAULT and -EINVAL, respectively.
nice!
> Keep the existing invalid-refcount warnings.
>
> Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a