Skip to content

Commit

Permalink
net: add truesize debug checks in skb_{add|coalesce}_rx_frag()
Browse files Browse the repository at this point in the history
It can be time consuming to track driver bugs, that might be detected
too late from this confusing warning in skb_try_coalesce()

	WARN_ON_ONCE(delta < len);

Add sanity check in skb_add_rx_frag() and skb_coalesce_rx_frag()
to better track bug origin for CONFIG_DEBUG_NET=y builds.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 16, 2023
1 parent 41862d1 commit c123e0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,8 @@ EXPORT_SYMBOL(__napi_alloc_skb);
void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
int size, unsigned int truesize)
{
DEBUG_NET_WARN_ON_ONCE(size > truesize);

skb_fill_page_desc(skb, i, page, off, size);
skb->len += size;
skb->data_len += size;
Expand All @@ -859,6 +861,8 @@ void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
{
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];

DEBUG_NET_WARN_ON_ONCE(size > truesize);

skb_frag_size_add(frag, size);
skb->len += size;
skb->data_len += size;
Expand Down

0 comments on commit c123e0d

Please sign in to comment.