Skip to contentSkip to conversation

ipv4: use WARN_ON_ONCE() in ip_rt_bug()

PATCH Applied Eric Dumazet 4 participants 4 messages May 19 – May 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: use WARN_ON_ONCE() in ip_rt_bug()

It turns out ip_rt_bug() can be called more than expected.

syzbot will still panic (because of panic_on_warn=1), but non debug kernels will no longer die while repeating stack traces on the console.

Fixes c378a9c019cf ("ipv4: Give backtrace in ip_rt_bug().")
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
index bc1296f0ea69b0705e00e547a0d550129e03326a..3d62d45d84bda986db8b3592c0c7f5c81da3fb7e 100644
@@ -1272,7 +1272,7 @@ static int ip_rt_bug(struct net *net, struct sock *sk, struct sk_buff *skb)
 		 __func__, &ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
 		 skb->dev ? skb->dev->name : "?");
 	kfree_skb(skb);
-	WARN_ON(1);
+	WARN_ON_ONCE(1);
 	return 0;
 }
 
Signature · 1 line
2.54.0.631.ge1b05301d1-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Eric Dumazet

It turns out ip_rt_bug() can be called more than expected.

syzbot will still panic (because of panic_on_warn=1), but non debug kernels will no longer die while repeating stack traces on the console.

Fixes c378a9c019cf ("ipv4: Give backtrace in ip_rt_bug().")
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 16 lines · Eric Dumazet

It turns out ip_rt_bug() can be called more than expected.

syzbot will still panic (because of panic_on_warn=1), but non debug kernels will no longer die while repeating stack traces on the console.

Fixes c378a9c019cf ("ipv4: Give backtrace in ip_rt_bug().")
---
  net/ipv4/route.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +0 -0
index bc1296f0ea69b0705e00e547a0d550129e03326a..3d62d45d84bda986db8b3592c0c7f5c81da3fb7e 100644

net/ipv4/route.c static int ip_rt_bug(struct net *net, struct sock *sk, struct sk_buff *skb) · line 1278

Quoted 8 lines
net/ipv4/route.c +1 -1
@@ -1272,7 +1272,7 @@ static int ip_rt_bug(struct net *net, struct sock *sk, struct sk_buff *skb)
  		 __func__, &ip_hdr(skb)->saddr, &ip_hdr(skb)->daddr,
  		 skb->dev ? skb->dev->name : "?");
  	kfree_skb(skb);
-	WARN_ON(1);
+	WARN_ON_ONCE(1);
  	return 0;
  }
 

Recently I backported one missing patch to stable because of excessive ip_rt_bug() prints. So I think it is reasonable to carry a Fixes tag for backporting.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-6.6.y&id=da54b3039d436227deebbc202cefea63bd318a38

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 19 May 2026 19:32:48 +0000 you wrote:

It turns out ip_rt_bug() can be called more than expected.

syzbot will still panic (because of panic_on_warn=1), but non debug kernels will no longer die while repeating stack traces on the console.

Fixes c378a9c019cf ("ipv4: Give backtrace in ip_rt_bug().")

[...]

Here is the summary with links:
- [net] ipv4: use WARN_ON_ONCE() in ip_rt_bug()

    https://git.kernel.org/netdev/net/c/e4bdef4d320b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html