diff mbox series

[net-next] l2tp: avoid overriding sk->sk_user_data

Message ID 20240822182544.378169-1-xiyou.wangcong@gmail.com (mailing list archive)
State Accepted
Commit 1461f5a3d810869e182f1d11caaac7dee0458ff7
Delegated to: Netdev Maintainers
Headers show
Series [net-next] l2tp: avoid overriding sk->sk_user_data | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: pabeni@redhat.com kuba@kernel.org edumazet@google.com
netdev/build_clang success Errors and warnings before: 16 this patch: 16
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: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 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
netdev/contest success net-next-2024-08-25--21-00 (tests: 714)

Commit Message

Cong Wang Aug. 22, 2024, 6:25 p.m. UTC
From: Cong Wang <cong.wang@bytedance.com>

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: syzbot+8dbe3133b840c470da0e@syzkaller.appspotmail.com
Cc: James Chapman <jchapman@katalix.com>
Cc: Tom Parkin <tparkin@katalix.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
 net/l2tp/l2tp_core.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

James Chapman Aug. 23, 2024, 7:13 a.m. UTC | #1
On 22/08/2024 19:25, Cong Wang wrote:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> 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: syzbot+8dbe3133b840c470da0e@syzkaller.appspotmail.com
> Cc: James Chapman <jchapman@katalix.com>
> Cc: Tom Parkin <tparkin@katalix.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
>   net/l2tp/l2tp_core.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> index af87c781d6a6..df73c35363cb 100644
> --- a/net/l2tp/l2tp_core.c
> +++ b/net/l2tp/l2tp_core.c
> @@ -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

Tested-by: James Chapman <jchapman@katalix.com>
Reviewed-by: James Chapman <jchapman@katalix.com>
patchwork-bot+netdevbpf@kernel.org Aug. 26, 2024, 5:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 22 Aug 2024 11:25:44 -0700 you wrote:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> 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!
diff mbox series

Patch

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index af87c781d6a6..df73c35363cb 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -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);