Commit 1461f5a3 authored by Cong Wang's avatar Cong Wang Committed by Jakub Kicinski

l2tp: avoid overriding sk->sk_user_data

Although commit 4a4cd703 ("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: 4a4cd703 ("l2tp: don't set sk_user_data in tunnel socket")
Reported-by: syzbot+8dbe3133b840c470da0e@syzkaller.appspotmail.com
Cc: Tom Parkin <tparkin@katalix.com>
Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
Tested-by: default avatarJames Chapman <jchapman@katalix.com>
Reviewed-by: default avatarJames Chapman <jchapman@katalix.com>
Link: https://patch.msgid.link/20240822182544.378169-1-xiyou.wangcong@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7888173e
...@@ -1620,6 +1620,9 @@ static int l2tp_validate_socket(const struct sock *sk, const struct net *net, ...@@ -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)) (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP))
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
if (encap == L2TP_ENCAPTYPE_UDP && sk->sk_user_data)
return -EBUSY;
tunnel = l2tp_sk_to_tunnel(sk); tunnel = l2tp_sk_to_tunnel(sk);
if (tunnel) { if (tunnel) {
l2tp_tunnel_put(tunnel); l2tp_tunnel_put(tunnel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment