All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket()
@ 2022-10-25 18:05 Eric Dumazet
  2022-10-25 18:15 ` Kuniyuki Iwashima
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2022-10-25 18:05 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet, syzbot, Mat Martineau,
	Matthieu Baerts, Kuniyuki Iwashima

My recent patch missed that mptcp_subflow_create_socket()
was creating a 'kernel' socket, then converted it to 'user' socket.

Fixes: 0cafd77dcd03 ("net: add a refcount tracker for kernel sockets")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mat Martineau <mathew.j.martineau@linux.intel.com>
Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/mptcp/subflow.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1595,7 +1595,9 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
 
 	/* kernel sockets do not by default acquire net ref, but TCP timer
 	 * needs it.
+	 * Update ns_tracker to current stack trace and refcounted tracker.
 	 */
+	__netns_tracker_free(net, &sf->sk->ns_tracker, false);
 	sf->sk->sk_net_refcnt = 1;
 	get_net_track(net, &sf->sk->ns_tracker, GFP_KERNEL);
 	sock_inuse_add(net, 1);
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket()
  2022-10-25 18:05 [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket() Eric Dumazet
@ 2022-10-25 18:15 ` Kuniyuki Iwashima
  2022-10-25 22:53 ` Mat Martineau
  2022-10-27  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2022-10-25 18:15 UTC (permalink / raw)
  To: edumazet
  Cc: davem, eric.dumazet, kuba, kuniyu, mathew.j.martineau,
	matthieu.baerts, netdev, pabeni, syzkaller

From:   Eric Dumazet <edumazet@google.com>
Date:   Tue, 25 Oct 2022 18:05:46 +0000
> My recent patch missed that mptcp_subflow_create_socket()
> was creating a 'kernel' socket, then converted it to 'user' socket.
> 
> Fixes: 0cafd77dcd03 ("net: add a refcount tracker for kernel sockets")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>

I missed that, thanks for the fix!


> Cc: Mat Martineau <mathew.j.martineau@linux.intel.com>
> Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
> Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
>  net/mptcp/subflow.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1595,7 +1595,9 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
>  
>  	/* kernel sockets do not by default acquire net ref, but TCP timer
>  	 * needs it.
> +	 * Update ns_tracker to current stack trace and refcounted tracker.
>  	 */
> +	__netns_tracker_free(net, &sf->sk->ns_tracker, false);
>  	sf->sk->sk_net_refcnt = 1;
>  	get_net_track(net, &sf->sk->ns_tracker, GFP_KERNEL);
>  	sock_inuse_add(net, 1);
> -- 
> 2.38.0.135.g90850a2211-goog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket()
  2022-10-25 18:05 [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket() Eric Dumazet
  2022-10-25 18:15 ` Kuniyuki Iwashima
@ 2022-10-25 22:53 ` Mat Martineau
  2022-10-27  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Mat Martineau @ 2022-10-25 22:53 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
	eric.dumazet, syzbot, Matthieu Baerts, Kuniyuki Iwashima

On Tue, 25 Oct 2022, Eric Dumazet wrote:

> My recent patch missed that mptcp_subflow_create_socket()
> was creating a 'kernel' socket, then converted it to 'user' socket.
>
> Fixes: 0cafd77dcd03 ("net: add a refcount tracker for kernel sockets")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Mat Martineau <mathew.j.martineau@linux.intel.com>
> Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
> Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---

Hi Eric -

I also missed this quirk in MPTCP subflow handling, thanks for the fix:

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>



> net/mptcp/subflow.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1595,7 +1595,9 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
>
> 	/* kernel sockets do not by default acquire net ref, but TCP timer
> 	 * needs it.
> +	 * Update ns_tracker to current stack trace and refcounted tracker.
> 	 */
> +	__netns_tracker_free(net, &sf->sk->ns_tracker, false);
> 	sf->sk->sk_net_refcnt = 1;
> 	get_net_track(net, &sf->sk->ns_tracker, GFP_KERNEL);
> 	sock_inuse_add(net, 1);
> -- 
> 2.38.0.135.g90850a2211-goog
>
>

--
Mat Martineau
Intel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket()
  2022-10-25 18:05 [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket() Eric Dumazet
  2022-10-25 18:15 ` Kuniyuki Iwashima
  2022-10-25 22:53 ` Mat Martineau
@ 2022-10-27  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-27  3:20 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, netdev, eric.dumazet, syzkaller,
	mathew.j.martineau, matthieu.baerts, kuniyu

Hello:

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

On Tue, 25 Oct 2022 18:05:46 +0000 you wrote:
> My recent patch missed that mptcp_subflow_create_socket()
> was creating a 'kernel' socket, then converted it to 'user' socket.
> 
> Fixes: 0cafd77dcd03 ("net: add a refcount tracker for kernel sockets")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Mat Martineau <mathew.j.martineau@linux.intel.com>
> Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
> Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
> 
> [...]

Here is the summary with links:
  - [net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket()
    https://git.kernel.org/netdev/net-next/c/d1e96cc4fbe0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-27  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 18:05 [PATCH net-next] mptcp: fix tracking issue in mptcp_subflow_create_socket() Eric Dumazet
2022-10-25 18:15 ` Kuniyuki Iwashima
2022-10-25 22:53 ` Mat Martineau
2022-10-27  3:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.