Linux kernel -stable discussions
 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, 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, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net 2/4] net: skbuff: limit folio refcount when rearranging skb frags
Date: Sun, 22 Nov 2026 09:19:37 +0000	[thread overview]
Message-ID: <179533917726.3135.13005025144396516237@kernel.org> (raw)
In-Reply-To: <20261118-skb_refcount_overflow-v1-2-5551b4954c3f@kernel.org>

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 commit message explains why skb_split() keeps its
  unconditional skb_frag_ref() by saying that "each split also allocates…

--

net: skbuff: limit folio refcount when rearranging skb frags

This patch replaces unconditional skb_frag_ref() calls with
skb_frag_try_ref() and skb_frags_try_ref() in skb_segment(),
skb_try_coalesce(), skb_shift() and tcp_clone_payload(). The goal is to
stop skbs from multiplying folio references until the folio refcount limit
is exceeded. skb_split() is deliberately left alone.

> skb_split() can still add one reference when splitting a frag. But each
> split also allocates a new skb that is charged to the socket, reaching
> the refcount limit that way would require a lot of socket memory, and the
> references go away once the data was acked, so it's not that relevant in
> practice. Making skb_split() fail is more involved, so let's leave it alone
> for now.

[Severity: Low]
Is this reasoning true for all skb_split() callers?

Socket charging and dropping the references on ACK both describe the TCP
callers, tcp_fragment() and tso_fragment() in net/ipv4/tcp_output.c.

skb_split() also has a non-TCP caller in batadv_frag_create() in
net/batman-adv/fragmentation.c:

net/batman-adv/fragmentation.c:batadv_frag_create() {
    ...
	skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom);
    ...
	skb_split(skb, skb_fragment, skb->len - fragment_size);
    ...
}

The fragment skb there comes from dev_alloc_skb(), so it is not charged to
any socket. The data is not acked either.

The path is batadv_frag_send_packet()->batadv_frag_create()->skb_split()->
skb_split_no_header(). skb_split_no_header() still calls
skb_frag_ref(skb1, k) unconditionally whenever the split point falls inside
a frag.

The KUnit tests in net/core/net_test.c also call skb_split() on skbs that
have no socket.

The conclusion probably still holds for batman-adv. A packet is limited to
BATADV_FRAG_MAX_FRAGMENTS fragments, and the fragments are transmitted and
freed. Only the stated reason is TCP-specific.

Could the commit message say that the socket memory argument covers only
the TCP callers, and mention why the batman-adv path is also bounded?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-skb_refcount_overflow-v1-0-5551b4954c3f%40kernel.org

  reply	other threads:[~2026-11-22  9:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  8:32 [PATCH net 0/4] net: skbuff: limit pagecache folio refcount David Hildenbrand (Arm)
2026-11-18  8:32 ` [PATCH net 1/4] net: skbuff: limit folio refcount when copying skb frag references David Hildenbrand (Arm)
2026-11-19 13:53   ` David Hildenbrand (Arm)
2026-11-20 16:21   ` Stanislav Fomichev
2026-11-20 21:01     ` David Hildenbrand (Arm)
2026-11-22  9:19   ` netdev-bot+sashiko
2026-11-22 12:58     ` David Hildenbrand (Arm)
2026-11-18  8:32 ` [PATCH net 2/4] net: skbuff: limit folio refcount when rearranging skb frags David Hildenbrand (Arm)
2026-11-22  9:19   ` netdev-bot+sashiko [this message]
2026-11-22 12:48     ` David Hildenbrand (Arm)
2026-11-18  8:32 ` [PATCH net 3/4] net: skbuff: limit folio refcount when splicing pages into skbs David Hildenbrand (Arm)
2026-11-22  9:19   ` netdev-bot+sashiko
2026-11-22 13:05     ` David Hildenbrand (Arm)
2026-11-18  8:32 ` [PATCH net 4/4] net: skbuff: limit folio refcount when splicing from sockets David Hildenbrand (Arm)
2026-11-22  9:19   ` netdev-bot+sashiko
2026-11-22 13:09     ` 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=179533917726.3135.13005025144396516237@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=horms@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=songliubraving@fb.com \
    --cc=stable@vger.kernel.org \
    --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