ipv6: exthdrs: refresh nh after handling HAO option
Subsystems (3)
PATCH 1/1 ipv6: exthdrs: refresh nh after handling HAO option
In reply to a message not in the archiveFrom: Zhengchuan Liang <[email protected]>
ip6_parse_tlv() caches skb_network_header(skb) in nh while walking IPv6 TLVs.
ipv6_dest_hao() may call pskb_expand_head() for a cloned skb, which can move the skb head and invalidate the cached network header pointer. Refresh nh after ipv6_dest_hao() returns so any trailing padding or TLVs are parsed from the current skb head.
This matches the existing pattern used in ip6_parse_tlv() after helpers that can modify skb header storage.
--- net/ipv6/exthdrs.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/exthdrs.c +2 -0
@@ -201,6 +201,8 @@ static bool ip6_parse_tlv(bool hopbyhop,case IPV6_TLV_HAO :if (!ipv6_dest_hao (skb, off))return false; + + nh =skb_network_header (skb);break ;#endif default :
Signature · 1 line
2.47.3
Quoted 31 lines · Ren Wei
From: Zhengchuan Liang <[email protected]>
ip6_parse_tlv()cachesskb_network_header(skb)in nh while walking IPv6 TLVs.
ipv6_dest_hao()may callpskb_expand_head()for a cloned skb, which can move the skb head and invalidate the cached network header pointer. Refresh nh afteripv6_dest_hao()returns so any trailing padding or TLVs are parsed from the current skb head.This matches the existing pattern used in
ip6_parse_tlv()after helpers that can modify skb header storage.Fixes a831f5bbc89a ("[IPV6] MIP6: Add inbound interface of home address option.")Reported-by Yuan Tan <[email protected]>Reported-by Xin Liu <[email protected]>Co-developed-by Luxing Yin <[email protected]>Signed-off-by Luxing Yin <[email protected]>Signed-off-by Zhengchuan Liang <[email protected]>Signed-off-by Ren Wei <[email protected]>Assisted-by Codex:gpt-5.4--- net/ipv6/exthdrs.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv6/exthdrs.c +0
-0
net/ipv6/exthdrs.c static bool ip6_parse_tlv(bool hopbyhop, · line 208
Quoted 8 lines
net/ipv6/exthdrs.c +2
-0@@ -201,6 +201,8 @@ static bool ip6_parse_tlv(bool hopbyhop,case IPV6_TLV_HAO :if (!ipv6_dest_hao (skb, off))return false; + + nh =skb_network_header (skb);break ;#endif default :
Note that the same issue applies to IPV6_TLV_JUMBO (hopopts), I've sent a patch to fix it as well (see [1]). Which makes me wonder... at some point, we may refresh the nh pointer once by default, regardless of the option. The impact wouldn't be that huge, and it would avoid missing the above for similar (new) cases.
Quoted 14 lines · Justin Iurman
Quoted 13 lines · Ren Wei
From: Zhengchuan Liang <[email protected]>
ip6_parse_tlv()cachesskb_network_header(skb)in nh while walking IPv6 TLVs.
ipv6_dest_hao()may callpskb_expand_head()for a cloned skb, which can move the skb head and invalidate the cached network header pointer. Refresh nh afteripv6_dest_hao()returns so any trailing padding or TLVs are parsed from the current skb head.This matches the existing pattern used in
ip6_parse_tlv()after helpers that can modify skb header storage.
Quoted 9 lines
Quoted 9 lines
Fixes a831f5bbc89a ("[IPV6] MIP6: Add inbound interface of home address option.")Reported-by Yuan Tan <[email protected]>Reported-by Xin Liu <[email protected]>Co-developed-by Luxing Yin <[email protected]>Signed-off-by Luxing Yin <[email protected]>Signed-off-by Zhengchuan Liang <[email protected]>Signed-off-by Ren Wei <[email protected]>Assisted-by Codex:gpt-5.4
Quoted 20 lines
Quoted 9 lines
--- net/ipv6/exthdrs.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv6/exthdrs.c +0
-0net/ipv6/exthdrs.c static bool ip6_parse_tlv(bool hopbyhop, · line 208
Quoted 8 lines
net/ipv6/exthdrs.c +2
-0@@ -201,6 +201,8 @@ static bool ip6_parse_tlv(bool hopbyhop,case IPV6_TLV_HAO :if (!ipv6_dest_hao (skb, off))return false; + + nh =skb_network_header (skb);break ;#endif default :Reviewed-by Justin Iurman <[email protected]>
Quoted 5 lines
Note that the same issue applies to
IPV6_TLV_JUMBO(hopopts), I've sent a patch to fix it as well (see [1]). Which makes me wonder... at some point, we may refresh the nh pointer once by default, regardless of the option. The impact wouldn't be that huge, and it would avoid missing the above for similar (new) cases.
+1
Do you want to send such a patch to net-next once both patches are present there?
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 11 lines · On Fri, 22 May 2026 17:42:26 +0800 you wrote:
From: Zhengchuan Liang <[email protected]>
ip6_parse_tlv()cachesskb_network_header(skb)in nh while walking IPv6 TLVs.
ipv6_dest_hao()may callpskb_expand_head()for a cloned skb, which can move the skb head and invalidate the cached network header pointer. Refresh nh afteripv6_dest_hao()returns so any trailing padding or TLVs are parsed from the current skb head.[...]
Here is the summary with links:
- [net,1/1] ipv6: exthdrs: refresh nh after handling HAO option
https://git.kernel.org/netdev/net/c/f7b52afe3592
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 53 lines · Ido Schimmel
Quoted 14 lines · Justin Iurman
Quoted 13 lines · Ren Wei
From: Zhengchuan Liang <[email protected]>
ip6_parse_tlv()cachesskb_network_header(skb)in nh while walking IPv6 TLVs.
ipv6_dest_hao()may callpskb_expand_head()for a cloned skb, which can move the skb head and invalidate the cached network header pointer. Refresh nh afteripv6_dest_hao()returns so any trailing padding or TLVs are parsed from the current skb head.This matches the existing pattern used in
ip6_parse_tlv()after helpers that can modify skb header storage.Quoted 9 lines
Quoted 9 lines
Fixes a831f5bbc89a ("[IPV6] MIP6: Add inbound interface of home address option.")Reported-by Yuan Tan <[email protected]>Reported-by Xin Liu <[email protected]>Co-developed-by Luxing Yin <[email protected]>Signed-off-by Luxing Yin <[email protected]>Signed-off-by Zhengchuan Liang <[email protected]>Signed-off-by Ren Wei <[email protected]>Assisted-by Codex:gpt-5.4Reviewed-by Ido Schimmel <[email protected]>Quoted 20 lines
Quoted 9 lines
--- net/ipv6/exthdrs.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv6/exthdrs.c +0
-0net/ipv6/exthdrs.c static bool ip6_parse_tlv(bool hopbyhop, · line 208
Quoted 8 lines
net/ipv6/exthdrs.c +2
-0@@ -201,6 +201,8 @@ static bool ip6_parse_tlv(bool hopbyhop,case IPV6_TLV_HAO :if (!ipv6_dest_hao (skb, off))return false; + + nh =skb_network_header (skb);break ;#endif default :Reviewed-by Justin Iurman <[email protected]>Quoted 5 lines
Note that the same issue applies to
IPV6_TLV_JUMBO(hopopts), I've sent a patch to fix it as well (see [1]). Which makes me wonder... at some point, we may refresh the nh pointer once by default, regardless of the option. The impact wouldn't be that huge, and it would avoid missing the above for similar (new) cases.
Quoted 4 lines
+1
Do you want to send such a patch to net-next once both patches are present there?
Sure, will do. In case I forget, don't hesitate to remind me offline.