Skip to contentSkip to conversation

netdevsim: zero initialize struct iphdr in dummy sk_buff

PATCH Applied Nikola Z. Ivanov 3 participants 3 messages Apr 26 – Apr 28

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

PATCH v2 1/1 netdevsim: zero initialize struct iphdr in dummy sk_buff

Syzbot reports a KMSAN uninit-value originating from nsim_dev_trap_skb_build, with the allocation also being performed in the same function.

Fix this by calling skb_put_zero instead of skb_put to guarantee zero initialization of the whole IP header.

Fixes da58f90f11f5 ("netdevsim: Add devlink-trap support")

---
Changes since v1:
- avoid unnecessary shuffling of struct member initialization.
https://lore.kernel.org/netdev/[email protected]/

 drivers/net/netdevsim/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netdevsim/dev.c +1 -1
index 1e06e781c835..f00fc2f9ebde 100644
@@ -829,7 +829,7 @@ static struct sk_buff *nsim_dev_trap_skb_build(void)
 	skb->protocol = htons(ETH_P_IP);
 
 	skb_set_network_header(skb, skb->len);
-	iph = skb_put(skb, sizeof(struct iphdr));
+	iph = skb_put_zero(skb, sizeof(struct iphdr));
 	iph->protocol = IPPROTO_UDP;
 	iph->saddr = in_aton("192.0.2.1");
 	iph->daddr = in_aton("198.51.100.1");
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Nikola Z. Ivanov

Syzbot reports a KMSAN uninit-value originating from nsim_dev_trap_skb_build, with the allocation also being performed in the same function.

Fix this by calling skb_put_zero instead of skb_put to guarantee zero initialization of the whole IP header.

Fixes da58f90f11f5 ("netdevsim: Add devlink-trap support")
#2 lore raw
In reply to Nikola Z. Ivanov
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 8 lines · On Sun, 26 Apr 2026 23:14:34 +0300 you wrote:

Syzbot reports a KMSAN uninit-value originating from nsim_dev_trap_skb_build, with the allocation also being performed in the same function.

Fix this by calling skb_put_zero instead of skb_put to guarantee zero initialization of the whole IP header.

[...]

Here is the summary with links:
- [net,v2] netdevsim: zero initialize struct iphdr in dummy sk_buff

    https://git.kernel.org/netdev/net/c/35eaa6d8d6c2

You are awesome, thank you!

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