From nobody Sun Dec 14 02:01:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A42C1E5B82; Mon, 21 Apr 2025 17:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745255293; cv=none; b=Ijc7dufRsIc+07QTkMSdmrZruhayxJ35Lqdj+NhQJ5KRTbYDzx24mVy1K6d48kJ5m5BoCwfDijng71xiORFO9Xkv/CQTjvhJUrHYwYky/xSZuGT5OY9mTGcSVhchB35D9x5Bn2GHmAiQcTwYm/CzghqCMLLI4tZVuPa/9DBS3ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745255293; c=relaxed/simple; bh=aFqGH0paYxGxHUjSJw30+gqhavTKRlHfTAmSY/feUhI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TM1/5YahSv0lwSchwI/aiQCLRptCtH/syjE3DyXGuXw+Xs7M0BuMOdP2+NiE/93JCBDr8x0zBPQi95mtxkSVS0Mf7H7J1/UXyMgVSyfKxRo4ckqomYwTyIVnh+omuQNzTVA8m7RPlTuPH6jMJLw4CUiZbZFYIhzT+vD4NWBdNHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IB3E96zN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IB3E96zN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307C1C4CEEA; Mon, 21 Apr 2025 17:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745255292; bh=aFqGH0paYxGxHUjSJw30+gqhavTKRlHfTAmSY/feUhI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IB3E96zNGsPSIrWWQpwDyy6vjnLhVLxsO3ylLubuDB3vAfi73esoOvLAzwIvCSpdn XywG8B1E4jYgFcyqw7vA4YR14ymyKyXLny7VTN8J1qtR5iQaQ4zY6llrBmQCuZ48b5 BgJb2/w8w62/QRGTIP7FgTDn4HG9/Eu/nDdUIKY3axPtc9yBchEXA0bIj26Pi11H61 FJiwp009mu3/aAu5erFE2TYdhp8Lz1W6yIC9JdbOJKTzWQAwP2GJ/Og3SVoCAg+VhS oZhMgS+v7H9VS47kBA3x8ydL6UPuuzBmCWqpCnzILKpXl05CeX8lALR0pcL3//PanJ MGzxgWbSta6hg== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Apr 2025 19:07:13 +0200 Subject: [PATCH net 1/2] mptcp: pm: Defer freeing of MPTCP userspace path manager entries Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250421-net-mptcp-pm-defer-freeing-v1-1-e731dc6e86b9@kernel.org> References: <20250421-net-mptcp-pm-defer-freeing-v1-0-e731dc6e86b9@kernel.org> In-Reply-To: <20250421-net-mptcp-pm-defer-freeing-v1-0-e731dc6e86b9@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Gang Yan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1536; i=matttbe@kernel.org; h=from:subject:message-id; bh=hG631LGYz4PCLJEqqRwKqfnXdY9WVYg4k+smAbalb/g=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDLYqksPtKrL5IhaNZ269ibFkFvcd+bfwCkvdy9Y8/DMn 8XZ7d80O0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACYS+5HhrxjLg/PbJhpk/Tps +HqXzk//ez3Lr/a4Fb7YH9dm2LlNUozhr8Q7Td0l21s0mg4s2PJS7qmyarIJQ8ELHQHxtFM50r3 HmAE= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Mat Martineau 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 Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- 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..a715dcbe0146ed0c055d071c632= 57047a90a9afd 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, struc= t genl_info *info) =20 release_sock(sk); =20 - 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); =20 err =3D 0; out: --=20 2.48.1 From nobody Sun Dec 14 02:01:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F42F1E8358; Mon, 21 Apr 2025 17:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745255296; cv=none; b=g2jLDxNyaIHl7Vnn7kUAmkB1cBjsoj4K9kiXzCEzIUQrXeBlv1nfoJJGEQ/FCw3o/Bv1pwAee73Cia0OR0U7+7KzS9T7ZFbVrKFmZtQ1Y3sz60Jq1Sd2no/9DukbFi8uv7J2Y1EyxXUAbjFd6pUEKRMfuUYiXa0+KHEQKUnOfdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745255296; c=relaxed/simple; bh=7M9VEbNw/wxshPV8CHZ1wPPNOjwcbLcxoHMPDHW572c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EKlLUBUtDxYEZRUafRzhBQRhdBQyfSnbNn1/4ItlUsPPyROQ7mOidBypU5scqJyMNnxUSo5zAlJyOxquakMx0VabbvMoGklui+b5LU87iH5oL+DJ08HGAxpMLO0IhANgj/o7qbmYpOKJJtF7y1M6DLZmkZn3w0jCKNXvb5G73GQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pw+kYY86; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pw+kYY86" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 219F8C4CEEC; Mon, 21 Apr 2025 17:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745255295; bh=7M9VEbNw/wxshPV8CHZ1wPPNOjwcbLcxoHMPDHW572c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pw+kYY86U/fEJhD1CJycV+A1ZxHSyEYx2Z7m9Z+F2BO2KnJ65R+knO8VAk5df248g V111OQbe0+bTwBxxsoEaSW1LUP7cLcn60TNzHgaNOL+oN1qpfdlWFVqYG/OO1v/9QH z4JY2hvqfp2riUkpL7XbEaRAJir5LODbX2Mw5jnnkZeAyjTfJc6UszGVeMbtxe15+C dvrvY1pL5Q6qcbi4Fsy0UC7CdeSNneR1cuurpqJzshcWwywmYBmDdG/N60zLjZZ6Wz LpUXsEjCOXfv8UXkV6HEDeojsyACrWAEhEjHzVd70ElSxag5OrYq8Bz5df+hbxxIdN 3Eem0+G2GHWZQ== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Apr 2025 19:07:14 +0200 Subject: [PATCH net 2/2] selftests: mptcp: diag: use mptcp_lib_get_info_value Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250421-net-mptcp-pm-defer-freeing-v1-2-e731dc6e86b9@kernel.org> References: <20250421-net-mptcp-pm-defer-freeing-v1-0-e731dc6e86b9@kernel.org> In-Reply-To: <20250421-net-mptcp-pm-defer-freeing-v1-0-e731dc6e86b9@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Gang Yan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1945; i=matttbe@kernel.org; h=from:subject:message-id; bh=5uqavJtPDjFSLzxOBtTDk/jrKu7HjOYDEmUMS8zpsNA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDLYqsv+SbQJ5EoX8b19GpCwXKd91ZHuB7EHfs1WENfh2 fpcoMW4o5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKtRxkZ3ul3Tek8ah2/NDbI watk8Y7qGU/3Mz6xYjHdXTv3wvdDTgy/WS89eu/3+u5Ts8k2ZxTP1KzT2HU/znb/xAU+Z2uaovk 4eQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang 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 Reviewed-by: Matthieu Baerts (NGI0) Tested-by: Gang Yan Signed-off-by: Matthieu Baerts (NGI0) --- 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/self= tests/net/mptcp/diag.sh index 4f55477ffe087721ad13774e82a5e2b1e6cec7c4..e7a75341f0f32304ff4e58c9b25= 00d405124dc74 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 =20 - ss_token=3D"$(ss -inmHMN $ns | grep 'token:' |\ - head -n 1 |\ - sed 's/.*token:\([0-9a-f]*\).*/\1/')" + ss_token=3D"$(ss -inmHMN $ns | + mptcp_lib_get_info_value "token" "token")" =20 token=3D"$(ip netns exec $ns ./mptcp_diag -t $ss_token |\ awk -F':[ \t]+' '/^token/ {print $2}')" --=20 2.48.1