net: core: use WARN_ON_ONCE in datagram iterators
Subsystems (2)
PATCH 1/1 net: core: use WARN_ON_ONCE in datagram iterators
Datagram fragment iteration helpers check for invalid buffer offsets using WARN_ON(). In fast-path packet processing routines, a malformed skb or lower-level driver bug triggering this check can result in unbounded dmesg logging.
Excessive console logging in data-path contexts introduces severe I/O latency overhead and risks triggering a DoS or system instability via log flooding.
Replace WARN_ON() with WARN_ON_ONCE() in __skb_datagram_iter() and skb_copy_datagram_from_iter(). This ensures anomalous conditions remain reportable for debugging without spamming the kernel log on repeated occurrences.
--- net/core/datagram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/datagram.c +4 -4
@@ -416,7 +416,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,int end;const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start +skb_frag_size (frag);if ((copy = end - offset) >0 ) {
@@ -449,7 +449,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, skb_walk_frags(skb, frag_iter) {int end; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start + frag_iter->len;if ((copy = end - offset) >0 ) {
@@ -570,7 +570,7 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,int end;const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start +skb_frag_size (frag);if ((copy = end - offset) >0 ) {
@@ -594,7 +594,7 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset, skb_walk_frags(skb, frag_iter) {int end; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start + frag_iter->len;if ((copy = end - offset) >0 ) {
Signature · 1 line
2.47.3
Quoted 6 lines · Igor Putko
Datagram fragment iteration helpers check for invalid buffer offsets using
WARN_ON(). In fast-path packet processing routines, a malformed skb or lower-level driver bug triggering this check can result in unbounded dmesg logging.
IMO the things that you mention as the root cause are the ones need fixing. I don't see a reason why the log should be changed here..
Quoted 58 lines
Excessive console logging in data-path contexts introduces severe I/O latency overhead and risks triggering a DoS or system instability via log flooding.
Replace
WARN_ON()withWARN_ON_ONCE()in__skb_datagram_iter()andskb_copy_datagram_from_iter(). This ensures anomalous conditions remain reportable for debugging without spamming the kernel log on repeated occurrences.Signed-off-by Igor Putko <[email protected]>--- net/core/datagram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)net/core/datagram.c +4
-5@@ -416,7 +416,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,int end;const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start +skb_frag_size (frag);if ((copy = end - offset) >0 ) {@@ -449,7 +449,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, skb_walk_frags(skb, frag_iter) {int end; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start + frag_iter->len;if ((copy = end - offset) >0 ) {@@ -570,7 +570,7 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,int end;const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start +skb_frag_size (frag);if ((copy = end - offset) >0 ) {@@ -594,7 +594,7 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset, skb_walk_frags(skb, frag_iter) {int end; -WARN_ON (start > offset + len); +WARN_ON_ONCE (start > offset + len); end = start + frag_iter->len;if ((copy = end - offset) >0 ) { --2.47.3