netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries
@ 2025-04-21 17:07 Matthieu Baerts (NGI0)
  2025-04-21 17:07 ` [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries Matthieu Baerts (NGI0)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-04-21 17:07 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, Gang Yan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable, Geliang Tang

Here are two unrelated fixes for MPTCP:

- Patch 1: free userspace PM entry with RCU helpers. A fix for v6.14.

- Patch 2: avoid a warning when running diag.sh selftest. A fix for
  v6.15-rc1.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Geliang Tang (1):
      selftests: mptcp: diag: use mptcp_lib_get_info_value

Mat Martineau (1):
      mptcp: pm: Defer freeing of MPTCP userspace path manager entries

 net/mptcp/pm_userspace.c                  | 6 +++++-
 tools/testing/selftests/net/mptcp/diag.sh | 5 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)
---
base-commit: 750d0ac001e85b754404178ee8ce01cbc76a03be
change-id: 20250421-net-mptcp-pm-defer-freeing-f9cd01b70043

Best regards,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>


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

* [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries
  2025-04-21 17:07 [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries Matthieu Baerts (NGI0)
@ 2025-04-21 17:07 ` Matthieu Baerts (NGI0)
  2025-04-21 17:07 ` [PATCH net 2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value Matthieu Baerts (NGI0)
  2025-04-24  0:10 ` [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-04-21 17:07 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, Gang Yan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable

From: Mat Martineau <martineau@kernel.org>

When path manager entries are deleted from the local address list, they
are first unlinked from the address list using list_del_rcu(). The
entries must not be freed until after the RCU grace period, but the
existing code immediately frees the entry.

Use kfree_rcu_mightsleep() and adjust sk_omem_alloc in open code instead
of using the sock_kfree_s() helper. This code path is only called in a
netlink handler, so the "might sleep" function is preferable to adding
a rarely-used rcu_head member to struct mptcp_pm_addr_entry.

Fixes: 88d097316371 ("mptcp: drop free_list for deleting entries")
Cc: stable@vger.kernel.org
Signed-off-by: Mat Martineau <martineau@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_userspace.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 2cb62f026b1f4420c549ab8ee6f54ffe3880d453..a715dcbe0146ed0c055d071c63257047a90a9afd 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -337,7 +337,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
 
 	release_sock(sk);
 
-	sock_kfree_s(sk, match, sizeof(*match));
+	kfree_rcu_mightsleep(match);
+	/* Adjust sk_omem_alloc like sock_kfree_s() does, to match
+	 * with allocation of this memory by sock_kmemdup()
+	 */
+	atomic_sub(sizeof(*match), &sk->sk_omem_alloc);
 
 	err = 0;
 out:

-- 
2.48.1


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

* [PATCH net 2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value
  2025-04-21 17:07 [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries Matthieu Baerts (NGI0)
  2025-04-21 17:07 ` [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries Matthieu Baerts (NGI0)
@ 2025-04-21 17:07 ` Matthieu Baerts (NGI0)
  2025-04-24  0:10 ` [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-04-21 17:07 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, Gang Yan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	Geliang Tang

From: Geliang Tang <tanggeliang@kylinos.cn>

When running diag.sh in a loop, chk_dump_one will report the following
"grep: write error":

 13 ....chk 2 cestab                                  [ OK ]
 grep: write error
 14 ....chk dump_one                                  [ OK ]
 15 ....chk 2->0 msk in use after flush               [ OK ]
 16 ....chk 2->0 cestab after flush                   [ OK ]

This error is caused by a broken pipe. When the output of 'ss' is processed
by grep, 'head -n 1' will exit immediately after getting the first line,
causing the subsequent pipe to close. At this time, if 'grep' is still
trying to write data to the closed pipe, it will trigger a SIGPIPE signal,
causing a write error.

One solution is not to use this problematic "head -n 1" command, but to use
mptcp_lib_get_info_value() helper defined in mptcp_lib.sh to get the value
of 'token'.

Fixes: ba2400166570 ("selftests: mptcp: add a test for mptcp_diag_dump_one")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Tested-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/diag.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 4f55477ffe087721ad13774e82a5e2b1e6cec7c4..e7a75341f0f32304ff4e58c9b2500d405124dc74 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -206,9 +206,8 @@ chk_dump_one()
 	local token
 	local msg
 
-	ss_token="$(ss -inmHMN $ns | grep 'token:' |\
-		    head -n 1 |\
-		    sed 's/.*token:\([0-9a-f]*\).*/\1/')"
+	ss_token="$(ss -inmHMN $ns |
+		    mptcp_lib_get_info_value "token" "token")"
 
 	token="$(ip netns exec $ns ./mptcp_diag -t $ss_token |\
 		 awk -F':[ \t]+' '/^token/ {print $2}')"

-- 
2.48.1


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

* Re: [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries
  2025-04-21 17:07 [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries Matthieu Baerts (NGI0)
  2025-04-21 17:07 ` [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries Matthieu Baerts (NGI0)
  2025-04-21 17:07 ` [PATCH net 2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value Matthieu Baerts (NGI0)
@ 2025-04-24  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-24  0:10 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: mptcp, martineau, geliang, davem, edumazet, kuba, pabeni, horms,
	shuah, yangang, netdev, linux-kernel, linux-kselftest, stable

Hello:

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

On Mon, 21 Apr 2025 19:07:12 +0200 you wrote:
> Here are two unrelated fixes for MPTCP:
> 
> - Patch 1: free userspace PM entry with RCU helpers. A fix for v6.14.
> 
> - Patch 2: avoid a warning when running diag.sh selftest. A fix for
>   v6.15-rc1.
> 
> [...]

Here is the summary with links:
  - [net,1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries
    https://git.kernel.org/netdev/net/c/13b4ece33cf9
  - [net,2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value
    https://git.kernel.org/netdev/net/c/ce72fea219c1

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:[~2025-04-24  0:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 17:07 [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries Matthieu Baerts (NGI0)
2025-04-21 17:07 ` [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries Matthieu Baerts (NGI0)
2025-04-21 17:07 ` [PATCH net 2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value Matthieu Baerts (NGI0)
2025-04-24  0:10 ` [PATCH net 0/2] mptcp: pm: Defer freeing userspace pm entries patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).