Skip to contentSkip to conversation

ipv6: fix possible UAF in icmpv6_rcv()

PATCH Applied Eric Dumazet 5 participants 5 messages Apr 16 – Apr 18

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

PATCH 1/1 ipv6: fix possible UAF in icmpv6_rcv()

Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.

Remove these temporary variables:

- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.

- Avoid potential future misuse after pskb_pull() call.

Fixes 4b3418fba0fe ("ipv6: icmp: include addresses in debug messages")
---
 net/ipv6/icmp.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
net/ipv6/icmp.c +4 -6
index 799d9e9ac45d11f7b460da7d8a7aeeaf0eb50f2f..efb23807a0262e8d68aa1afc8d96ee94eab89d50 100644
@@ -1104,7 +1104,6 @@ static int icmpv6_rcv(struct sk_buff *skb)
 	struct net *net = dev_net_rcu(skb->dev);
 	struct net_device *dev = icmp6_dev(skb);
 	struct inet6_dev *idev = __in6_dev_get(dev);
-	const struct in6_addr *saddr, *daddr;
 	struct icmp6hdr *hdr;
 	u8 type;
 
@@ -1135,12 +1134,10 @@ static int icmpv6_rcv(struct sk_buff *skb)
 
 	__ICMP6_INC_STATS(dev_net_rcu(dev), idev, ICMP6_MIB_INMSGS);
 
-	saddr = &ipv6_hdr(skb)->saddr;
-	daddr = &ipv6_hdr(skb)->daddr;
-
 	if (skb_checksum_validate(skb, IPPROTO_ICMPV6, ip6_compute_pseudo)) {
 		net_dbg_ratelimited("ICMPv6 checksum failed [%pI6c > %pI6c]\n",
-				    saddr, daddr);
+				    &ipv6_hdr(skb)->saddr,
+				    &ipv6_hdr(skb)->daddr);
 		goto csum_error;
 	}
 
@@ -1220,7 +1217,8 @@ static int icmpv6_rcv(struct sk_buff *skb)
 			break;
 
 		net_dbg_ratelimited("icmpv6: msg of unknown type [%pI6c > %pI6c]\n",
-				    saddr, daddr);
+				    &ipv6_hdr(skb)->saddr,
+				    &ipv6_hdr(skb)->daddr);
 
 		/*
 		 * error of unknown type.
Signature · 1 line
2.54.0.rc1.513.gad8abe7a5a-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eric Dumazet

Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.

Remove these temporary variables:

Quoted 7 lines

- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.

- Avoid potential future misuse after pskb_pull() call.

Fixes 4b3418fba0fe ("ipv6: icmp: include addresses in debug messages")

Thanks!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 8 lines · Eric Dumazet

Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.

Remove these temporary variables:

- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.

Quoted 7 lines

- Avoid potential future misuse after pskb_pull() call.

Fixes 4b3418fba0fe ("ipv6: icmp: include addresses in debug messages")
---
 net/ipv6/icmp.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Eric Dumazet
Quoted 5 lines · Eric Dumazet

Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.

Remove these temporary variables:

Quoted 7 lines

- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.

- Avoid potential future misuse after pskb_pull() call.

Fixes 4b3418fba0fe ("ipv6: icmp: include addresses in debug messages")
#4 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 Thu, 16 Apr 2026 10:35:05 +0000 you wrote:

Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.

Remove these temporary variables:

- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.

[...]

Here is the summary with links:
- [net] ipv6: fix possible UAF in icmpv6_rcv()

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

You are awesome, thank you!

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