Re: [PATCH v3 8/9] RFC: net: limit folio refcount when splicing pages into skbs

From: Pedro Falcato

Date: Thu Nov 12 2026 - 11:17:30 EST


On Tue, Nov 10, 2026 at 09:35:48PM +0100, David Hildenbrand (Arm) wrote:
> Various networking features use MSG_SPLICE_PAGES to add pages to skbs,
> whereby skb_append_pagefrags() takes a page reference for each fragment it
> adds. Pages spliced from pipes were already checked when entering the
> pipe, but in-kernel users like sunrpc pass pagecache pages directly. This
> allows for exceeding folio refcount limits.
>
> This is not specific to large pagecache folios, but with them it is a
> lot easier to reach the refcount limit, as page table mappings can cheaply
> create many references.
>
> Let's use try_get_page() in skb_append_pagefrags() and fail with -EFAULT.
> Don't use -EMSGSIZE, as TCP would just retry with a new skb. The only
> caller, skb_splice_from_iter(), handles that.
>
> 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>

Acked-by: Pedro Falcato <pfalcato@xxxxxxx>

--
Pedro