Skip to contentSkip to conversation

l2tp: avoid overriding sk->sk_user_data

PATCH Applied Cong Wang 3 participants 3 messages Aug 22, 2024 – Aug 26, 2024

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 l2tp: avoid overriding sk->sk_user_data

From: Cong Wang <[email protected]>

Although commit 4a4cd70369f1 ("l2tp: don't set sk_user_data in tunnel socket") removed sk->sk_user_data usage, setup_udp_tunnel_sock() still touches sk->sk_user_data, this conflicts with sockmap which also leverages sk->sk_user_data to save psock.

Restore this sk->sk_user_data check to avoid such conflicts.

Fixes 4a4cd70369f1 ("l2tp: don't set sk_user_data in tunnel socket")
Reported-by [email protected]
Cc James Chapman <[email protected]>
Cc Tom Parkin <[email protected]>
---
 net/l2tp/l2tp_core.c | 3 +++
 1 file changed, 3 insertions(+)
net/l2tp/l2tp_core.c +3 -0
index af87c781d6a6..df73c35363cb 100644
@@ -1620,6 +1620,9 @@ static int l2tp_validate_socket(const struct sock *sk, const struct net *net,
 	    (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP))
 		return -EPROTONOSUPPORT;
 
+	if (encap == L2TP_ENCAPTYPE_UDP && sk->sk_user_data)
+		return -EBUSY;
+
 	tunnel = l2tp_sk_to_tunnel(sk);
 	if (tunnel) {
 		l2tp_tunnel_put(tunnel);
Signature · 1 line
2.34.1
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Cong Wang

From: Cong Wang <[email protected]>

Although commit 4a4cd70369f1 ("l2tp: don't set sk_user_data in tunnel socket") removed sk->sk_user_data usage, setup_udp_tunnel_sock() still touches sk->sk_user_data, this conflicts with sockmap which also leverages sk->sk_user_data to save psock.

Restore this sk->sk_user_data check to avoid such conflicts.

Fixes 4a4cd70369f1 ("l2tp: don't set sk_user_data in tunnel socket")
Reported-by [email protected]
Cc James Chapman <[email protected]>
Cc Tom Parkin <[email protected]>
---
  net/l2tp/l2tp_core.c | 3 +++
  1 file changed, 3 insertions(+)
net/l2tp/l2tp_core.c +0 -0
index af87c781d6a6..df73c35363cb 100644

net/l2tp/l2tp_core.c static int l2tp_validate_socket(const struct sock *sk, const struct net *net, · line 1628

Quoted 9 lines
net/l2tp/l2tp_core.c +3 -0
@@ -1620,6 +1620,9 @@ static int l2tp_validate_socket(const struct sock *sk, const struct net *net,
  	    (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP))
  		return -EPROTONOSUPPORT;
 
+	if (encap == L2TP_ENCAPTYPE_UDP && sk->sk_user_data)
+		return -EBUSY;
+
  	tunnel = l2tp_sk_to_tunnel(sk);
  	if (tunnel) {
  		l2tp_tunnel_put(tunnel);

Thanks Cong

#2 lore raw
In reply to Cong Wang
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 22 Aug 2024 11:25:44 -0700 you wrote:

From: Cong Wang <[email protected]>

Although commit 4a4cd70369f1 ("l2tp: don't set sk_user_data in tunnel socket") removed sk->sk_user_data usage, setup_udp_tunnel_sock() still touches sk->sk_user_data, this conflicts with sockmap which also leverages sk->sk_user_data to save psock.

[...]

Here is the summary with links:
- [net-next] l2tp: avoid overriding sk->sk_user_data

    https://git.kernel.org/netdev/net-next/c/1461f5a3d810

You are awesome, thank you!

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