summaryrefslogtreecommitdiff
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2022-06-02 09:18:58 -0700
committerJakub Kicinski <kuba@kernel.org>2022-06-02 10:15:05 -0700
commit22296a5c0cd35aaf62e1af3266f82cdf6b0b9b78 (patch)
tree0f328bfb3dc7bcc9234d882d320c15603ca94107 /include/linux/skbuff.h
parenteb0b39efb7d908e3950f6f76ee6e3cecb86ec489 (diff)
downloadlwn-22296a5c0cd35aaf62e1af3266f82cdf6b0b9b78.tar.gz
lwn-22296a5c0cd35aaf62e1af3266f82cdf6b0b9b78.zip
net: add debug info to __skb_pull()
While analyzing yet another syzbot report, I found the following patch very useful. It allows to better understand what went wrong. This debug info is only enabled if CONFIG_DEBUG_NET=y, which is the case for syzbot builds. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index da96f0d3e753..d3d10556f0fa 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2696,7 +2696,14 @@ void *skb_pull(struct sk_buff *skb, unsigned int len);
static inline void *__skb_pull(struct sk_buff *skb, unsigned int len)
{
skb->len -= len;
- BUG_ON(skb->len < skb->data_len);
+ if (unlikely(skb->len < skb->data_len)) {
+#if defined(CONFIG_DEBUG_NET)
+ skb->len += len;
+ pr_err("__skb_pull(len=%u)\n", len);
+ skb_dump(KERN_ERR, skb, false);
+#endif
+ BUG();
+ }
return skb->data += len;
}