diff mbox series

[net,5/7] net: ipv6: ila: fix lwtunnel_output() loop

Message ID 20250311141238.19862-6-justin.iurman@uliege.be (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: fix lwtunnel reentry loops | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Justin Iurman March 11, 2025, 2:12 p.m. UTC
Fix the lwtunnel_output() reentry loop in ila_lwt when the destination
is the same after transformation. Some configurations leading to this
may be considered pathological, but we don't want the kernel to crash
even for these ones.

Fixes: 79ff2fc31e0f ("ila: Cache a route to translated address")
Cc: Tom Herbert <tom@herbertland.com>
Cc: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
 net/ipv6/ila/ila_lwt.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Paolo Abeni March 13, 2025, 12:46 p.m. UTC | #1
On 3/11/25 3:12 PM, Justin Iurman wrote:
> diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c
> index 7d574f5132e2..67f7c7015693 100644
> --- a/net/ipv6/ila/ila_lwt.c
> +++ b/net/ipv6/ila/ila_lwt.c
> @@ -96,6 +96,14 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>  		}
>  	}
>  
> +	/* avoid lwtunnel_output() reentry loop when destination is the same
> +	 * after transformation
> +	 */
> +	if (orig_dst->lwtstate == dst->lwtstate) {
> +		dst_release(dst);
> +		return orig_dst->lwtstate->orig_output(net, sk, skb);
> +	}
> +
>  	skb_dst_drop(skb);
>  	skb_dst_set(skb, dst);
>  	return dst_output(net, sk, skb);

Even this pattern is repeated verbatim in patch 3, and I think it should
deserve a shared helper. Also a bit of a pity there are a few variations
that do not fit cleanly a common helper, but I guess there is little to
do about that for 'net'.

Thanks,

Paolo
Justin Iurman March 13, 2025, 2:48 p.m. UTC | #2
On 3/13/25 13:46, Paolo Abeni wrote:
> On 3/11/25 3:12 PM, Justin Iurman wrote:
>> diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c
>> index 7d574f5132e2..67f7c7015693 100644
>> --- a/net/ipv6/ila/ila_lwt.c
>> +++ b/net/ipv6/ila/ila_lwt.c
>> @@ -96,6 +96,14 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
>>   		}
>>   	}
>>   
>> +	/* avoid lwtunnel_output() reentry loop when destination is the same
>> +	 * after transformation
>> +	 */
>> +	if (orig_dst->lwtstate == dst->lwtstate) {
>> +		dst_release(dst);
>> +		return orig_dst->lwtstate->orig_output(net, sk, skb);
>> +	}
>> +
>>   	skb_dst_drop(skb);
>>   	skb_dst_set(skb, dst);
>>   	return dst_output(net, sk, skb);
> 
> Even this pattern is repeated verbatim in patch 3, and I think it should
> deserve a shared helper. Also a bit of a pity there are a few variations

+1 as well. However, same remark applies here: this patch (and some 
others) will be removed from this series in -v2.

> that do not fit cleanly a common helper, but I guess there is little to
> do about that for 'net'.

Indeed...

> Thanks,
> 
> Paolo
>
diff mbox series

Patch

diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c
index 7d574f5132e2..67f7c7015693 100644
--- a/net/ipv6/ila/ila_lwt.c
+++ b/net/ipv6/ila/ila_lwt.c
@@ -96,6 +96,14 @@  static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 		}
 	}
 
+	/* avoid lwtunnel_output() reentry loop when destination is the same
+	 * after transformation
+	 */
+	if (orig_dst->lwtstate == dst->lwtstate) {
+		dst_release(dst);
+		return orig_dst->lwtstate->orig_output(net, sk, skb);
+	}
+
 	skb_dst_drop(skb);
 	skb_dst_set(skb, dst);
 	return dst_output(net, sk, skb);