Re: [PATCH net 4/4] net: skbuff: limit folio refcount when splicing from sockets
From: David Hildenbrand (Arm)
Date: Sun Nov 22 2026 - 08:09:32 EST
On 11/22/26 10:19, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
>
> Low priority / nit picks for your consideration:
>
> - [Low] The new comment above skb_splice_bits()
> (net/core/skbuff.c:3295-3300) says the function "Returns the number of…
>
> Pre-existing issues:
> - [Medium] skb_splice_bits() still returns 0, which callers report as
> EOF, when nothing was spliced because linear_to_page() failed to…
>
> --
>
> net: skbuff: limit folio refcount when splicing from sockets
>
> This patch uses try_get_page() in spd_fill_page() so that splicing from
> sockets into pipes cannot push a folio refcount past its limit. On
> failure it returns -EFAULT, and the error is propagated as an int
> through __splice_segment() and __skb_splice_bits(). skb_splice_bits()
> returns the error when nothing was spliced, so the callers don't report
> EOF.
>
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index c937d74eed6ac..b73fef7a1b460 100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>
> [ ... ]
>
>> @@ -3284,7 +3294,9 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
>>
>> /*
>> * Map data from the skb to a pipe. Should handle both the linear part,
>> - * the fragments, and the frag list.
>> + * the fragments, and the frag list. Returns the number of bytes spliced,
>> + * or an error if we could not splice anything because we could not take
>> + * a page reference.
>> */
>
> [Severity: Low]
> This isn't a bug, but is this return description complete?
>
> When spd.nr_pages is non-zero, skb_splice_bits() returns whatever
> splice_to_pipe() returns. splice_to_pipe() in fs/splice.c can fail for
> reasons that have nothing to do with page references:
>
> if (unlikely(!pipe->readers)) {
> send_sig(SIGPIPE, current, 0);
> ret = -EPIPE;
> goto out;
> }
> ...
> if (!ret)
> ret = -EAGAIN;
>
> The reverse case also exists. If linear_to_page() fails in
> spd_fill_page(), nothing gets spliced, yet skb_splice_bits() returns 0
> and not an error.
>
> Could the comment also mention the -EPIPE and -EAGAIN cases that come
> from splice_to_pipe()?
I guess we can just make it simpler by saying
"... or an error if splicing failed."
I assume that could be fixed up when applying.
>
>> int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
>> struct pipe_inode_info *pipe, unsigned int tlen,
>> @@ -3299,14 +3311,14 @@ int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
>> .ops = &default_pipe_buf_ops,
>> .spd_release = sock_spd_release,
>> };
>> - int ret = 0;
>> + int ret;
>>
>> - __skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk);
>> + ret = __skb_splice_bits(skb, pipe, &offset, &tlen, &spd, sk);
>>
>> if (spd.nr_pages)
>> - ret = splice_to_pipe(pipe, &spd);
>> -
>> - return ret;
>> + return splice_to_pipe(pipe, &spd);
>> + /* Returning 0 would make callers report EOF. */
>> + return ret < 0 ? ret : 0;
>
> [Severity: Medium]
> This is a pre-existing issue, not one introduced by this patch. Can the
> spurious EOF that this new comment describes still happen when
> linear_to_page() fails?
Sounds like something for net people to investigate.
--
Cheers,
David