* [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends
@ 2022-05-10 3:57 Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 1/5] net: add include/net/net_debug.h Eric Dumazet
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
This patch series is inspired by some syzbot reports
hinting that skb transport_header might be not set
in places we expect it being set.
Add a new CONFIG_DEBUG_NET option
and DEBUG_NET_WARN_ON_ONCE() helper, so that we can start
adding more sanity checks in the future.
Replace two BUG() in skb_checksum_help()
with less risky code.
v2: make first patch compile on more arches/compilers
add the 5th patch to add more debugging in skb_checksum_help()
Eric Dumazet (5):
net: add include/net/net_debug.h
net: add CONFIG_DEBUG_NET
net: warn if transport header was not set
net: remove two BUG() from skb_checksum_help()
net: add more debug info in skb_checksum_help()
include/linux/netdevice.h | 141 +---------------------------------
include/linux/skbuff.h | 2 +
include/net/net_debug.h | 157 ++++++++++++++++++++++++++++++++++++++
net/Kconfig.debug | 7 ++
net/core/dev.c | 12 ++-
5 files changed, 176 insertions(+), 143 deletions(-)
create mode 100644 include/net/net_debug.h
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 net-next 1/5] net: add include/net/net_debug.h
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
@ 2022-05-10 3:57 ` Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 2/5] net: add CONFIG_DEBUG_NET Eric Dumazet
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Remove from include/linux/netdevice.h helpers
that send debug/info/warnings to syslog.
We plan adding more helpers in following patches.
v2: added two includes, and 'struct net_device' forward declaration
to avoid compile errors (kernel bots)
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/netdevice.h | 141 +----------------------------------
include/net/net_debug.h | 151 ++++++++++++++++++++++++++++++++++++++
2 files changed, 152 insertions(+), 140 deletions(-)
create mode 100644 include/net/net_debug.h
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 74c97a34921d48c593c08e2bed72e099f42520a3..5fb1de931bcb9d0caaa5449169012b192d69d892 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -50,6 +50,7 @@
#include <linux/hashtable.h>
#include <linux/rbtree.h>
#include <net/net_trackers.h>
+#include <net/net_debug.h>
struct netpoll_info;
struct device;
@@ -5050,81 +5051,9 @@ static inline const char *netdev_reg_state(const struct net_device *dev)
return " (unknown)";
}
-__printf(3, 4) __cold
-void netdev_printk(const char *level, const struct net_device *dev,
- const char *format, ...);
-__printf(2, 3) __cold
-void netdev_emerg(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_alert(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_crit(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_err(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_warn(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_notice(const struct net_device *dev, const char *format, ...);
-__printf(2, 3) __cold
-void netdev_info(const struct net_device *dev, const char *format, ...);
-
-#define netdev_level_once(level, dev, fmt, ...) \
-do { \
- static bool __section(".data.once") __print_once; \
- \
- if (!__print_once) { \
- __print_once = true; \
- netdev_printk(level, dev, fmt, ##__VA_ARGS__); \
- } \
-} while (0)
-
-#define netdev_emerg_once(dev, fmt, ...) \
- netdev_level_once(KERN_EMERG, dev, fmt, ##__VA_ARGS__)
-#define netdev_alert_once(dev, fmt, ...) \
- netdev_level_once(KERN_ALERT, dev, fmt, ##__VA_ARGS__)
-#define netdev_crit_once(dev, fmt, ...) \
- netdev_level_once(KERN_CRIT, dev, fmt, ##__VA_ARGS__)
-#define netdev_err_once(dev, fmt, ...) \
- netdev_level_once(KERN_ERR, dev, fmt, ##__VA_ARGS__)
-#define netdev_warn_once(dev, fmt, ...) \
- netdev_level_once(KERN_WARNING, dev, fmt, ##__VA_ARGS__)
-#define netdev_notice_once(dev, fmt, ...) \
- netdev_level_once(KERN_NOTICE, dev, fmt, ##__VA_ARGS__)
-#define netdev_info_once(dev, fmt, ...) \
- netdev_level_once(KERN_INFO, dev, fmt, ##__VA_ARGS__)
-
#define MODULE_ALIAS_NETDEV(device) \
MODULE_ALIAS("netdev-" device)
-#if defined(CONFIG_DYNAMIC_DEBUG) || \
- (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
-#define netdev_dbg(__dev, format, args...) \
-do { \
- dynamic_netdev_dbg(__dev, format, ##args); \
-} while (0)
-#elif defined(DEBUG)
-#define netdev_dbg(__dev, format, args...) \
- netdev_printk(KERN_DEBUG, __dev, format, ##args)
-#else
-#define netdev_dbg(__dev, format, args...) \
-({ \
- if (0) \
- netdev_printk(KERN_DEBUG, __dev, format, ##args); \
-})
-#endif
-
-#if defined(VERBOSE_DEBUG)
-#define netdev_vdbg netdev_dbg
-#else
-
-#define netdev_vdbg(dev, format, args...) \
-({ \
- if (0) \
- netdev_printk(KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-
/*
* netdev_WARN() acts like dev_printk(), but with the key difference
* of using a WARN/WARN_ON to get the message out, including the
@@ -5138,74 +5067,6 @@ do { \
WARN_ONCE(1, "netdevice: %s%s: " format, netdev_name(dev), \
netdev_reg_state(dev), ##args)
-/* netif printk helpers, similar to netdev_printk */
-
-#define netif_printk(priv, type, level, dev, fmt, args...) \
-do { \
- if (netif_msg_##type(priv)) \
- netdev_printk(level, (dev), fmt, ##args); \
-} while (0)
-
-#define netif_level(level, priv, type, dev, fmt, args...) \
-do { \
- if (netif_msg_##type(priv)) \
- netdev_##level(dev, fmt, ##args); \
-} while (0)
-
-#define netif_emerg(priv, type, dev, fmt, args...) \
- netif_level(emerg, priv, type, dev, fmt, ##args)
-#define netif_alert(priv, type, dev, fmt, args...) \
- netif_level(alert, priv, type, dev, fmt, ##args)
-#define netif_crit(priv, type, dev, fmt, args...) \
- netif_level(crit, priv, type, dev, fmt, ##args)
-#define netif_err(priv, type, dev, fmt, args...) \
- netif_level(err, priv, type, dev, fmt, ##args)
-#define netif_warn(priv, type, dev, fmt, args...) \
- netif_level(warn, priv, type, dev, fmt, ##args)
-#define netif_notice(priv, type, dev, fmt, args...) \
- netif_level(notice, priv, type, dev, fmt, ##args)
-#define netif_info(priv, type, dev, fmt, args...) \
- netif_level(info, priv, type, dev, fmt, ##args)
-
-#if defined(CONFIG_DYNAMIC_DEBUG) || \
- (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
-#define netif_dbg(priv, type, netdev, format, args...) \
-do { \
- if (netif_msg_##type(priv)) \
- dynamic_netdev_dbg(netdev, format, ##args); \
-} while (0)
-#elif defined(DEBUG)
-#define netif_dbg(priv, type, dev, format, args...) \
- netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
-#else
-#define netif_dbg(priv, type, dev, format, args...) \
-({ \
- if (0) \
- netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-
-/* if @cond then downgrade to debug, else print at @level */
-#define netif_cond_dbg(priv, type, netdev, cond, level, fmt, args...) \
- do { \
- if (cond) \
- netif_dbg(priv, type, netdev, fmt, ##args); \
- else \
- netif_ ## level(priv, type, netdev, fmt, ##args); \
- } while (0)
-
-#if defined(VERBOSE_DEBUG)
-#define netif_vdbg netif_dbg
-#else
-#define netif_vdbg(priv, type, dev, format, args...) \
-({ \
- if (0) \
- netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
- 0; \
-})
-#endif
-
/*
* The list of packet types we will receive (as opposed to discard)
* and the routines to invoke.
diff --git a/include/net/net_debug.h b/include/net/net_debug.h
new file mode 100644
index 0000000000000000000000000000000000000000..19cd2700c20ea9945ae7662bacfa50f5d2bed398
--- /dev/null
+++ b/include/net/net_debug.h
@@ -0,0 +1,151 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_NET_DEBUG_H
+#define _LINUX_NET_DEBUG_H
+
+#include <linux/bug.h>
+#include <linux/kern_levels.h>
+
+struct net_device;
+
+__printf(3, 4) __cold
+void netdev_printk(const char *level, const struct net_device *dev,
+ const char *format, ...);
+__printf(2, 3) __cold
+void netdev_emerg(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_alert(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_crit(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_err(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_warn(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_notice(const struct net_device *dev, const char *format, ...);
+__printf(2, 3) __cold
+void netdev_info(const struct net_device *dev, const char *format, ...);
+
+#define netdev_level_once(level, dev, fmt, ...) \
+do { \
+ static bool __section(".data.once") __print_once; \
+ \
+ if (!__print_once) { \
+ __print_once = true; \
+ netdev_printk(level, dev, fmt, ##__VA_ARGS__); \
+ } \
+} while (0)
+
+#define netdev_emerg_once(dev, fmt, ...) \
+ netdev_level_once(KERN_EMERG, dev, fmt, ##__VA_ARGS__)
+#define netdev_alert_once(dev, fmt, ...) \
+ netdev_level_once(KERN_ALERT, dev, fmt, ##__VA_ARGS__)
+#define netdev_crit_once(dev, fmt, ...) \
+ netdev_level_once(KERN_CRIT, dev, fmt, ##__VA_ARGS__)
+#define netdev_err_once(dev, fmt, ...) \
+ netdev_level_once(KERN_ERR, dev, fmt, ##__VA_ARGS__)
+#define netdev_warn_once(dev, fmt, ...) \
+ netdev_level_once(KERN_WARNING, dev, fmt, ##__VA_ARGS__)
+#define netdev_notice_once(dev, fmt, ...) \
+ netdev_level_once(KERN_NOTICE, dev, fmt, ##__VA_ARGS__)
+#define netdev_info_once(dev, fmt, ...) \
+ netdev_level_once(KERN_INFO, dev, fmt, ##__VA_ARGS__)
+
+#if defined(CONFIG_DYNAMIC_DEBUG) || \
+ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
+#define netdev_dbg(__dev, format, args...) \
+do { \
+ dynamic_netdev_dbg(__dev, format, ##args); \
+} while (0)
+#elif defined(DEBUG)
+#define netdev_dbg(__dev, format, args...) \
+ netdev_printk(KERN_DEBUG, __dev, format, ##args)
+#else
+#define netdev_dbg(__dev, format, args...) \
+({ \
+ if (0) \
+ netdev_printk(KERN_DEBUG, __dev, format, ##args); \
+})
+#endif
+
+#if defined(VERBOSE_DEBUG)
+#define netdev_vdbg netdev_dbg
+#else
+
+#define netdev_vdbg(dev, format, args...) \
+({ \
+ if (0) \
+ netdev_printk(KERN_DEBUG, dev, format, ##args); \
+ 0; \
+})
+#endif
+
+/* netif printk helpers, similar to netdev_printk */
+
+#define netif_printk(priv, type, level, dev, fmt, args...) \
+do { \
+ if (netif_msg_##type(priv)) \
+ netdev_printk(level, (dev), fmt, ##args); \
+} while (0)
+
+#define netif_level(level, priv, type, dev, fmt, args...) \
+do { \
+ if (netif_msg_##type(priv)) \
+ netdev_##level(dev, fmt, ##args); \
+} while (0)
+
+#define netif_emerg(priv, type, dev, fmt, args...) \
+ netif_level(emerg, priv, type, dev, fmt, ##args)
+#define netif_alert(priv, type, dev, fmt, args...) \
+ netif_level(alert, priv, type, dev, fmt, ##args)
+#define netif_crit(priv, type, dev, fmt, args...) \
+ netif_level(crit, priv, type, dev, fmt, ##args)
+#define netif_err(priv, type, dev, fmt, args...) \
+ netif_level(err, priv, type, dev, fmt, ##args)
+#define netif_warn(priv, type, dev, fmt, args...) \
+ netif_level(warn, priv, type, dev, fmt, ##args)
+#define netif_notice(priv, type, dev, fmt, args...) \
+ netif_level(notice, priv, type, dev, fmt, ##args)
+#define netif_info(priv, type, dev, fmt, args...) \
+ netif_level(info, priv, type, dev, fmt, ##args)
+
+#if defined(CONFIG_DYNAMIC_DEBUG) || \
+ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
+#define netif_dbg(priv, type, netdev, format, args...) \
+do { \
+ if (netif_msg_##type(priv)) \
+ dynamic_netdev_dbg(netdev, format, ##args); \
+} while (0)
+#elif defined(DEBUG)
+#define netif_dbg(priv, type, dev, format, args...) \
+ netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
+#else
+#define netif_dbg(priv, type, dev, format, args...) \
+({ \
+ if (0) \
+ netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
+ 0; \
+})
+#endif
+
+/* if @cond then downgrade to debug, else print at @level */
+#define netif_cond_dbg(priv, type, netdev, cond, level, fmt, args...) \
+ do { \
+ if (cond) \
+ netif_dbg(priv, type, netdev, fmt, ##args); \
+ else \
+ netif_ ## level(priv, type, netdev, fmt, ##args); \
+ } while (0)
+
+#if defined(VERBOSE_DEBUG)
+#define netif_vdbg netif_dbg
+#else
+#define netif_vdbg(priv, type, dev, format, args...) \
+({ \
+ if (0) \
+ netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
+ 0; \
+})
+#endif
+
+
+#endif /* _LINUX_NET_DEBUG_H */
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 net-next 2/5] net: add CONFIG_DEBUG_NET
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 1/5] net: add include/net/net_debug.h Eric Dumazet
@ 2022-05-10 3:57 ` Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 3/5] net: warn if transport header was not set Eric Dumazet
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
This config option enables network debugging checks.
This patch adds DEBUG_NET_WARN_ON_ONCE(cond)
Note that this is not a replacement for WARN_ON_ONCE(cond)
as (cond) is not evaluated if CONFIG_DEBUG_NET is not set.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/net_debug.h | 6 ++++++
net/Kconfig.debug | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/include/net/net_debug.h b/include/net/net_debug.h
index 19cd2700c20ea9945ae7662bacfa50f5d2bed398..1e74684cbbdbcd5ba304b935e76376a72d6ba3f2 100644
--- a/include/net/net_debug.h
+++ b/include/net/net_debug.h
@@ -148,4 +148,10 @@ do { \
#endif
+#if defined(CONFIG_DEBUG_NET)
+#define DEBUG_NET_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond)
+#else
+#define DEBUG_NET_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
+#endif
+
#endif /* _LINUX_NET_DEBUG_H */
diff --git a/net/Kconfig.debug b/net/Kconfig.debug
index 2f50611df858911cf5190a361e4e9316e543ed3a..a5781cf63b16b32e5360df1ca26a753b6505d81f 100644
--- a/net/Kconfig.debug
+++ b/net/Kconfig.debug
@@ -17,3 +17,10 @@ config NET_NS_REFCNT_TRACKER
help
Enable debugging feature to track netns references.
This adds memory and cpu costs.
+
+config DEBUG_NET
+ bool "Add generic networking debug"
+ depends on DEBUG_KERNEL
+ help
+ Enable extra sanity checks in networking.
+ This is mostly used by fuzzers, but is safe to select.
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 net-next 3/5] net: warn if transport header was not set
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 1/5] net: add include/net/net_debug.h Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 2/5] net: add CONFIG_DEBUG_NET Eric Dumazet
@ 2022-05-10 3:57 ` Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 4/5] net: remove two BUG() from skb_checksum_help() Eric Dumazet
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
Make sure skb_transport_header() and skb_transport_offset() uses
are not fooled if the transport header has not been set.
This change will likely expose existing bugs in linux networking stacks.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/linux/skbuff.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..a1c73fccccc68641fe46066e6d1195b31483ca4c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -42,6 +42,7 @@
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <linux/netfilter/nf_conntrack_common.h>
#endif
+#include <net/net_debug.h>
/* The interface for checksum offload between the stack and networking drivers
* is as follows...
@@ -2804,6 +2805,7 @@ static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
{
+ DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
return skb->head + skb->transport_header;
}
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 net-next 4/5] net: remove two BUG() from skb_checksum_help()
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
` (2 preceding siblings ...)
2022-05-10 3:57 ` [PATCH v2 net-next 3/5] net: warn if transport header was not set Eric Dumazet
@ 2022-05-10 3:57 ` Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 5/5] net: add more debug info in skb_checksum_help() Eric Dumazet
2022-05-11 12:00 ` [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
I have a syzbot report that managed to get a crash in skb_checksum_help()
If syzbot can trigger these BUG(), it makes sense to replace
them with more friendly WARN_ON_ONCE() since skb_checksum_help()
can instead return an error code.
Note that syzbot will still crash there, until real bug is fixed.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/dev.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index f036ccb61da4da3ffc52c4f2402427054b831e8a..e12f8310dd86b312092c5d8fd50fa2ab60fce310 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3265,11 +3265,15 @@ int skb_checksum_help(struct sk_buff *skb)
}
offset = skb_checksum_start_offset(skb);
- BUG_ON(offset >= skb_headlen(skb));
+ ret = -EINVAL;
+ if (WARN_ON_ONCE(offset >= skb_headlen(skb)))
+ goto out;
+
csum = skb_checksum(skb, offset, skb->len - offset, 0);
offset += skb->csum_offset;
- BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
+ if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb)))
+ goto out;
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
if (ret)
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 net-next 5/5] net: add more debug info in skb_checksum_help()
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
` (3 preceding siblings ...)
2022-05-10 3:57 ` [PATCH v2 net-next 4/5] net: remove two BUG() from skb_checksum_help() Eric Dumazet
@ 2022-05-10 3:57 ` Eric Dumazet
2022-05-11 12:00 ` [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2022-05-10 3:57 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Eric Dumazet, Eric Dumazet
From: Eric Dumazet <edumazet@google.com>
This is a followup of previous patch.
Dumping the stack trace is a good start, but printing
basic skb information is probably better.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/dev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index e12f8310dd86b312092c5d8fd50fa2ab60fce310..d3221ea4aab3bfded1d3d9e2b0d861afc1c2eed6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3266,15 +3266,17 @@ int skb_checksum_help(struct sk_buff *skb)
offset = skb_checksum_start_offset(skb);
ret = -EINVAL;
- if (WARN_ON_ONCE(offset >= skb_headlen(skb)))
+ if (WARN_ON_ONCE(offset >= skb_headlen(skb))) {
+ DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
goto out;
-
+ }
csum = skb_checksum(skb, offset, skb->len - offset, 0);
offset += skb->csum_offset;
- if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb)))
+ if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb))) {
+ DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
goto out;
-
+ }
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
if (ret)
goto out;
--
2.36.0.512.ge40c2bad7a-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
` (4 preceding siblings ...)
2022-05-10 3:57 ` [PATCH v2 net-next 5/5] net: add more debug info in skb_checksum_help() Eric Dumazet
@ 2022-05-11 12:00 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-11 12:00 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, edumazet
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Mon, 9 May 2022 20:57:36 -0700 you wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> This patch series is inspired by some syzbot reports
> hinting that skb transport_header might be not set
> in places we expect it being set.
>
> Add a new CONFIG_DEBUG_NET option
> and DEBUG_NET_WARN_ON_ONCE() helper, so that we can start
> adding more sanity checks in the future.
>
> [...]
Here is the summary with links:
- [v2,net-next,1/5] net: add include/net/net_debug.h
https://git.kernel.org/netdev/net-next/c/5b87be9e4978
- [v2,net-next,2/5] net: add CONFIG_DEBUG_NET
https://git.kernel.org/netdev/net-next/c/d268c1f5cfc9
- [v2,net-next,3/5] net: warn if transport header was not set
(no matching commit)
- [v2,net-next,4/5] net: remove two BUG() from skb_checksum_help()
https://git.kernel.org/netdev/net-next/c/d7ea0d9df2a6
- [v2,net-next,5/5] net: add more debug info in skb_checksum_help()
https://git.kernel.org/netdev/net-next/c/eeee4b77dc52
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-05-11 12:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 3:57 [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 1/5] net: add include/net/net_debug.h Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 2/5] net: add CONFIG_DEBUG_NET Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 3/5] net: warn if transport header was not set Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 4/5] net: remove two BUG() from skb_checksum_help() Eric Dumazet
2022-05-10 3:57 ` [PATCH v2 net-next 5/5] net: add more debug info in skb_checksum_help() Eric Dumazet
2022-05-11 12:00 ` [PATCH v2 net-next 0/5] net: CONFIG_DEBUG_NET and friends patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).