Re: [PATCH net 2/4] net: skbuff: limit folio refcount when rearranging skb frags
From: netdev-bot+sashiko
Date: Sun Nov 22 2026 - 04:20:05 EST
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