fixes for seg6 and rpl lwtunnels on input
Subsystems (3)
v3 cover fixes for seg6 and rpl lwtunnels on input
v3:
- split patch #1 from -v2 into two separate patches
- drop patches #2 and #3 from -v2: they will be addressed later with another series, so that we don't block this one
v2:
- https://lore.kernel.org/netdev/[email protected]/
v1:
- https://lore.kernel.org/netdev/[email protected]/
As a follow up to commit 92191dd10730 ("net: ipv6: fix dst ref loops in rpl, seg6 and ioam6 lwtunnels"), we also need a conditional dst cache on input for seg6_iptunnel and rpl_iptunnel to prevent dst ref loops (i.e., if the packet destination did not change, we may end up recording a reference to the lwtunnel in its own cache, and the lwtunnel state will never be freed). This series provides a fix to respectively prevent a dst ref loop on input in seg6_iptunnel and rpl_iptunnel.
Justin Iurman (2):
net: ipv6: fix dst ref loop on input in seg6 lwt
net: ipv6: fix dst ref loop on input in rpl lwt
net/ipv6/rpl_iptunnel.c | 14 ++++++++++++-- net/ipv6/seg6_iptunnel.c | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 net: ipv6: fix dst ref loop on input in seg6 lwt
Prevent a dst ref loop on input in seg6_iptunnel.
--- net/ipv6/seg6_iptunnel.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv6/seg6_iptunnel.c +12 -2
@@ -472,10 +472,18 @@ static int seg6_input_core(struct net *net, struct sock *sk, {struct dst_entry *orig_dst =skb_dst (skb);struct dst_entry *dst =NULL ; +struct lwtunnel_state *lwtst;struct seg6_lwt *slwt;int err; - slwt =seg6_lwt_lwtunnel (orig_dst->lwtstate); +/* We cannot dereference "orig_dst" once ip6_route_input() or +* skb_dst_drop() is called. However, in order to detect a dst loop, we +* need the address of its lwtstate. So, save the address of lwtstate +* now and use it later as a comparison. +*/ + lwtst = orig_dst->lwtstate; + + slwt =seg6_lwt_lwtunnel (lwtst);local_bh_disable (); dst =dst_cache_get (&slwt->cache);
@@ -490,7 +498,9 @@ static int seg6_input_core(struct net *net, struct sock *sk,if (!dst) {ip6_route_input (skb); dst =skb_dst (skb); -if (!dst->error) { + +/* cache only if we don't create a dst reference loop */ +if (!dst->error && lwtst != dst->lwtstate) {local_bh_disable ();dst_cache_set_ip6 (&slwt->cache, dst, &ipv6_hdr (skb)->saddr);
Signature · 1 line
2.34.1
PATCH v3 2/2 net: ipv6: fix dst ref loop on input in rpl lwt
In reply to Justin IurmanPrevent a dst ref loop on input in rpl_iptunnel.
--- net/ipv6/rpl_iptunnel.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv6/rpl_iptunnel.c +12 -2
@@ -262,10 +262,18 @@ static int rpl_input(struct sk_buff *skb) {struct dst_entry *orig_dst =skb_dst (skb);struct dst_entry *dst =NULL ; +struct lwtunnel_state *lwtst;struct rpl_lwt *rlwt;int err; - rlwt =rpl_lwt_lwtunnel (orig_dst->lwtstate); +/* We cannot dereference "orig_dst" once ip6_route_input() or +* skb_dst_drop() is called. However, in order to detect a dst loop, we +* need the address of its lwtstate. So, save the address of lwtstate +* now and use it later as a comparison. +*/ + lwtst = orig_dst->lwtstate; + + rlwt =rpl_lwt_lwtunnel (lwtst);local_bh_disable (); dst =dst_cache_get (&rlwt->cache);
@@ -280,7 +288,9 @@ static int rpl_input(struct sk_buff *skb)if (!dst) {ip6_route_input (skb); dst =skb_dst (skb); -if (!dst->error) { + +/* cache only if we don't create a dst reference loop */ +if (!dst->error && lwtst != dst->lwtstate) {local_bh_disable ();dst_cache_set_ip6 (&rlwt->cache, dst, &ipv6_hdr (skb)->saddr);
Signature · 1 line
2.34.1
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 25 Feb 2025 18:51:37 +0100 you wrote:
v3:
- split patch #1 from -v2 into two separate patches
- drop patches #2 and #3 from -v2: they will be addressed later with another series, so that we don't block this one
v2:
- https://lore.kernel.org/netdev/[email protected]/
v1:
- https://lore.kernel.org/netdev/[email protected]/[...]
Here is the summary with links:
- [net,v3,1/2] net: ipv6: fix dst ref loop on input in seg6 lwt
https://git.kernel.org/netdev/net/c/c64a0727f9b1 - [net,v3,2/2] net: ipv6: fix dst ref loop on input in rpl lwt https://git.kernel.org/netdev/net/c/13e55fbaec17
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html