Subject: Re: [PATCH net-next] l2tp: fix ICMP error handling for UDP-encap sockets

From: Tom Parkin <[email-masked]>
Date: Tue, 7 May 2024 15:10:12 +0100

Thanks Jakub,

On  Fri, May 03, 2024 at 15:32:14 -0700, Jakub Kicinski wrote:
> Seems like we should target it at net? Description indicates it's 
> a clear regression.

Ack, I'll respin for net.

> not: the !tunnel can't happen, right?

Your question makes me realise that l2tp_udp_encap_err_recv is being
called in the same context as l2tp_udp_encap_recv, and so should be
using rcu_dereference_sk_user_data to access the tunnel handle rather
than l2tp_sk_to_tunnel.

I'll fix that in the respin.

However I note that l2tp_udp_encap_recv also checks for the tunnel
handle being NULL :-|

> nit: mismatch on the braces here, this would be more usual:
> 
> +	if (ip_hdr(skb)->version == IPVERSION) {
> +		if (inet_test_bit(RECVERR, sk))
> +			return ip_icmp_error(sk, skb, err, port, info, payload);
> +#if IS_ENABLED(CONFIG_IPV6)
> +	} else {
> +		if (inet6_test_bit(RECVERR6, sk))
> +			return ipv6_icmp_error(sk, skb, err, port, info, payload);
> +#endif
> +	}
> 
> +}

Thanks, I will fix this.