diff options
author | Eric Dumazet <edumazet@google.com> | 2023-09-13 13:48:41 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-09-16 10:10:27 +0100 |
commit | c123e0d30bdb54a0f91ec348827eef76877165d8 (patch) | |
tree | ef95571b1f5538b29fe0adbf557bdfdb3239d96f | |
parent | 41862d12e77f78b4ecb59b028bf44de92991bda2 (diff) | |
download | linux-stable-c123e0d30bdb54a0f91ec348827eef76877165d8.tar.gz linux-stable-c123e0d30bdb54a0f91ec348827eef76877165d8.tar.bz2 linux-stable-c123e0d30bdb54a0f91ec348827eef76877165d8.zip |
net: add truesize debug checks in skb_{add|coalesce}_rx_frag()
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>
-rw-r--r-- | net/core/skbuff.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 4eaf7ed0d1f4..2198979470ec 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -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; @@ -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; |