Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: david@kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, sdf.kernel@gmail.com, willemb@google.com,
	horms@kernel.org, akpm@linux-foundation.org, kas@kernel.org,
	songliubraving@fb.com, hannes@cmpxchg.org, riel@surriel.com,
	willy@infradead.org, ncardwell@google.com, kuniyu@google.com,
	pfalcato@suse.de, cel@kernel.org, jlayton@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, stable@vger.kernel.org
Subject: Re: [PATCH net v2 3/4] net: skbuff: limit folio refcount when splicing pages into skbs
Date: Fri, 27 Nov 2026 21:21:50 +0000	[thread overview]
Message-ID: <179581451032.3135.17667643003292457918@kernel.org> (raw)
In-Reply-To: <20261126-skb_refcount_overflow-v2-3-a6f600a5634a@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The refcount-limit fix does not cover kernel TLS, so the case
  the commit message uses as its example (sunrpc/nfsd sending pagecache…

--

net: skbuff: limit folio refcount when splicing pages into skbs

This commit changes skb_append_pagefrags() to use try_get_page() instead
of get_page(). In-kernel MSG_SPLICE_PAGES senders that pass pagecache
pages directly, such as sunrpc, can then no longer push a folio's
refcount past the limit. On failure it returns -EFAULT rather than
-EMSGSIZE, so TCP does not just retry with a new skb.

> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 6da51ad8fd440..957335bcc5961 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4714,8 +4714,13 @@ int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
>  	if (skb_can_coalesce(skb, i, page, offset)) {
>  		skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], size);
>  	} else if (i < max_frags) {
> +		/*
> +		 * Don't use -EMSGSIZE, as callers would just retry with a new
> +		 * skb.
> +		 */
> +		if (!try_get_page(page))
> +			return -EFAULT;
>  		skb_zcopy_downgrade_managed(skb);
> -		get_page(page);
>  		skb_fill_page_desc_noacc(skb, i, page, offset, size);
>  	} else {
>  		return -EMSGSIZE;

[Severity: High]
Does this cover sockets that have kTLS installed? The commit message uses
sunrpc/nfsd as its example. With kTLS, though, MSG_SPLICE_PAGES never
reaches skb_append_pagefrags().

With software kTLS the call chain is:

tls_sw_sendmsg()
  tls_sw_sendmsg_splice()
    sk_msg_page_add()

sk_msg_page_add() in include/linux/skmsg.h still takes the reference
without a check, and it has no way to return an error:

static inline void sk_msg_page_add(struct sk_msg *msg, struct page *page,
				   u32 len, u32 offset)
{
	struct scatterlist *sge;

	get_page(page);
	...
}

With TLS device offload, the MSG_SPLICE_PAGES branch in tls_push_data()
passes the extracted page to tls_append_frag(). That function also uses
plain get_page(), and the reference is held until the record is ACKed:

net/tls/tls_device.c:tls_append_frag() {
	...
	} else {
		++frag;
		skb_frag_fill_page_desc(frag, pfrag->page, pfrag->offset,
					size);
		++record->num_frags;
		get_page(pfrag->page);
	}
	...
}

nfsd reaches these paths with xprtsec=tls:

- nfsd_read_splice_ok() only turns off splice reads for krb5i and krb5p.
- So nfsd_splice_read() still puts pagecache pages into rq_res.
- svc_tcp_sendmsg() then sends them with MSG_SPLICE_PAGES through
  sock_sendmsg(), which goes to tls_sw_sendmsg() or tls_device_sendmsg().

nvme-tcp over TLS also sends pages with MSG_SPLICE_PAGES and goes through
the same paths.

The sunrpc client does not seem to use MSG_SPLICE_PAGES, since
XS_SENDMSG_FLAGS is MSG_DONTWAIT | MSG_NOSIGNAL. The server side is the
case that matters here.

Should sk_msg_page_add() (or tls_sw_sendmsg_splice()) and the zero-copy
tls_append_frag() path also use try_get_page() and fail with -EFAULT in
the same way? No other patch in the series appears to touch net/tls or
include/linux/skmsg.h.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-skb_refcount_overflow-v2-0-a6f600a5634a%40kernel.org

  reply	other threads:[~2026-11-27 21:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:18 [PATCH net v2 0/4] net: skbuff: limit pagecache folio refcount David Hildenbrand (Arm)
2026-11-26 21:18 ` [PATCH net v2 1/4] net: skbuff: limit folio refcount when copying skb frag references David Hildenbrand (Arm)
2026-11-27 21:21   ` netdev-bot+sashiko
2026-11-26 21:18 ` [PATCH net v2 2/4] net: skbuff: limit folio refcount when rearranging skb frags David Hildenbrand (Arm)
2026-11-26 21:18 ` [PATCH net v2 3/4] net: skbuff: limit folio refcount when splicing pages into skbs David Hildenbrand (Arm)
2026-11-27 21:21   ` netdev-bot+sashiko [this message]
2026-11-26 21:18 ` [PATCH net v2 4/4] net: skbuff: limit folio refcount when splicing from sockets David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179581451032.3135.17667643003292457918@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cel@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=horms@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=kas@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=riel@surriel.com \
    --cc=sdf.kernel@gmail.com \
    --cc=songliubraving@fb.com \
    --cc=stable@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox