Skip to contentSkip to conversation

mptcp: fix tracking issue in mptcp_subflow_create_socket()

PATCH Applied Eric Dumazet 4 participants 4 messages Oct 25, 2022 – Oct 27, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mptcp: fix tracking issue in mptcp_subflow_create_socket()

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")
Cc Mat Martineau <[email protected]>
Cc Matthieu Baerts <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>
---
 net/mptcp/subflow.c | 2 ++
 1 file changed, 2 insertions(+)
net/mptcp/subflow.c +2 -0
index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
@@ -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);
Signature · 1 line
2.38.0.135.g90850a2211-goog
Reviewed-by on v1 1/1
#1 lore raw
From:   Eric Dumazet <[email protected]>
Date:   Tue, 25 Oct 2022 18:05:46 +0000
Quoted 6 lines

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")

I missed that, thanks for the fix!

Quoted 23 lines
Cc Mat Martineau <[email protected]>
Cc Matthieu Baerts <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>
---
 net/mptcp/subflow.c | 2 ++
 1 file changed, 2 insertions(+)
net/mptcp/subflow.c +2 -0
index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
@@ -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);
Signature · 1 line
2.38.0.135.g90850a2211-goog
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 10 lines · Eric Dumazet

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")
Cc Mat Martineau <[email protected]>
Cc Matthieu Baerts <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>

---

Hi Eric -

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

Quoted 21 lines

net/mptcp/subflow.c | 2 ++

1 file changed, 2 insertions(+)
net/mptcp/subflow.c +2 -0
index 07dd23d0fe04ac37f4cc66c0c21d4d41f50fb3f4..120f792fda9764271f020771b36d27c6e44d8618 100644
@@ -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);
Signature · 1 line
2.38.0.135.g90850a2211-goog

--
Mat Martineau
Intel

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 11 lines · 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")
Cc Mat Martineau <[email protected]>
Cc Matthieu Baerts <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>

[...]

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!

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