mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
@ 2022-06-27  9:58 Paolo Abeni
  2022-06-27 10:06 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure MPTCP CI
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Paolo Abeni @ 2022-06-27  9:58 UTC (permalink / raw)
  To: mptcp; +Cc: Florian Westphal

The user-space PM subflow removal path uses a couple of helpers
that must be called under the msk socket lock and the current
code lacks such requirement.

Change the existing lock scope so that the relevant code is under
its protection.

Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
It should close issues/287, let's see what the CI says
---
 net/mptcp/pm_userspace.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 3d1d365e9c6f..33be79f0e9c2 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -307,15 +307,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
 				      const struct mptcp_addr_info *local,
 				      const struct mptcp_addr_info *remote)
 {
-	struct sock *sk = &msk->sk.icsk_inet.sk;
 	struct mptcp_subflow_context *subflow;
-	struct sock *found = NULL;
 
 	if (local->family != remote->family)
 		return NULL;
 
-	lock_sock(sk);
-
 	mptcp_for_each_subflow(msk, subflow) {
 		const struct inet_sock *issk;
 		struct sock *ssk;
@@ -348,16 +344,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
 		}
 
 		if (issk->inet_sport == local->port &&
-		    issk->inet_dport == remote->port) {
-			found = ssk;
-			goto found;
-		}
+		    issk->inet_dport == remote->port)
+			return ssk;
 	}
 
-found:
-	release_sock(sk);
-
-	return found;
+	return NULL;
 }
 
 int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
@@ -413,6 +404,7 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	sk = &msk->sk.icsk_inet.sk;
+	lock_sock(sk);
 	ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
 	if (ssk) {
 		struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
@@ -424,8 +416,9 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 	} else {
 		err = -ESRCH;
 	}
+	release_sock(sk);
 
- destroy_err:
+destroy_err:
 	sock_put((struct sock *)msk);
 	return err;
 }
-- 
2.35.3


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

* Re: mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure
  2022-06-27  9:58 [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Paolo Abeni
@ 2022-06-27 10:06 ` MPTCP CI
  2022-06-27 11:05   ` Matthieu Baerts
  2022-06-27 11:35 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Tests Results MPTCP CI
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: MPTCP CI @ 2022-06-27 10:06 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: mptcp

Hi Paolo,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

  https://patchwork.kernel.org/project/mptcp/patch/886e059dc9096dcc9e1daa1eb1a07ec34d72aa74.1656323519.git.pabeni@redhat.com/
  https://github.com/multipath-tcp/mptcp_net-next/actions/runs/2568360433

Status: 
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/31a3bb3c20ba

Feel free to reply to this email if you cannot access logs, if you need
some support to fix the error, if this doesn't seem to be caused by your
modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

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

* Re: mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure
  2022-06-27 10:06 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure MPTCP CI
@ 2022-06-27 11:05   ` Matthieu Baerts
  0 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts @ 2022-06-27 11:05 UTC (permalink / raw)
  To: mptcp, Paolo Abeni

Hello,

On 27/06/2022 12:06, MPTCP CI wrote:
> Hi Paolo,
> 
> Thank you for your modifications, that's great!
> 
> But sadly, our CI spotted some issues with it when trying to build it.
> 
> You can find more details there:
> 
>   https://patchwork.kernel.org/project/mptcp/patch/886e059dc9096dcc9e1daa1eb1a07ec34d72aa74.1656323519.git.pabeni@redhat.com/
>   https://github.com/multipath-tcp/mptcp_net-next/actions/runs/2568360433

Mmh, there was no error :-/

I will monitor that.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

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

* Re: mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Tests Results
  2022-06-27  9:58 [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Paolo Abeni
  2022-06-27 10:06 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure MPTCP CI
@ 2022-06-27 11:35 ` MPTCP CI
  2022-06-27 22:46 ` [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Mat Martineau
  2022-06-28 16:06 ` Matthieu Baerts
  3 siblings, 0 replies; 6+ messages in thread
From: MPTCP CI @ 2022-06-27 11:35 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: mptcp

Hi Paolo,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/6101836691144704
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6101836691144704/summary/summary.txt

- KVM Validation: debug:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5538886737723392
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5538886737723392/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/31a3bb3c20ba


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

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

* Re: [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
  2022-06-27  9:58 [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Paolo Abeni
  2022-06-27 10:06 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure MPTCP CI
  2022-06-27 11:35 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Tests Results MPTCP CI
@ 2022-06-27 22:46 ` Mat Martineau
  2022-06-28 16:06 ` Matthieu Baerts
  3 siblings, 0 replies; 6+ messages in thread
From: Mat Martineau @ 2022-06-27 22:46 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: mptcp, Florian Westphal

On Mon, 27 Jun 2022, Paolo Abeni wrote:

> The user-space PM subflow removal path uses a couple of helpers
> that must be called under the msk socket lock and the current
> code lacks such requirement.
>
> Change the existing lock scope so that the relevant code is under
> its protection.
>
> Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> It should close issues/287, let's see what the CI says

Thanks for tracking this down, Paolo. Patch looks good, tests are passing 
for me.

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

> ---
> net/mptcp/pm_userspace.c | 19 ++++++-------------
> 1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 3d1d365e9c6f..33be79f0e9c2 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -307,15 +307,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
> 				      const struct mptcp_addr_info *local,
> 				      const struct mptcp_addr_info *remote)
> {
> -	struct sock *sk = &msk->sk.icsk_inet.sk;
> 	struct mptcp_subflow_context *subflow;
> -	struct sock *found = NULL;
>
> 	if (local->family != remote->family)
> 		return NULL;
>
> -	lock_sock(sk);
> -
> 	mptcp_for_each_subflow(msk, subflow) {
> 		const struct inet_sock *issk;
> 		struct sock *ssk;
> @@ -348,16 +344,11 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
> 		}
>
> 		if (issk->inet_sport == local->port &&
> -		    issk->inet_dport == remote->port) {
> -			found = ssk;
> -			goto found;
> -		}
> +		    issk->inet_dport == remote->port)
> +			return ssk;
> 	}
>
> -found:
> -	release_sock(sk);
> -
> -	return found;
> +	return NULL;
> }
>
> int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
> @@ -413,6 +404,7 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
> 	}
>
> 	sk = &msk->sk.icsk_inet.sk;
> +	lock_sock(sk);
> 	ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
> 	if (ssk) {
> 		struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
> @@ -424,8 +416,9 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
> 	} else {
> 		err = -ESRCH;
> 	}
> +	release_sock(sk);
>
> - destroy_err:
> +destroy_err:
> 	sock_put((struct sock *)msk);
> 	return err;
> }
> -- 
> 2.35.3
>
>
>

--
Mat Martineau
Intel

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

* Re: [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
  2022-06-27  9:58 [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Paolo Abeni
                   ` (2 preceding siblings ...)
  2022-06-27 22:46 ` [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Mat Martineau
@ 2022-06-28 16:06 ` Matthieu Baerts
  3 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts @ 2022-06-28 16:06 UTC (permalink / raw)
  To: Paolo Abeni, mptcp; +Cc: Florian Westphal

Hi Paolo, Mat,

On 27/06/2022 11:58, Paolo Abeni wrote:
> The user-space PM subflow removal path uses a couple of helpers
> that must be called under the msk socket lock and the current
> code lacks such requirement.
> 
> Change the existing lock scope so that the relevant code is under
> its protection.
> 
> Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Thank you for the patch and the review!

Now in our tree (fixes for -net) with Mat's RvB tag:

New patches for t/upstream-net:
- 106e35505557: mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
- 52865f3cc71f: tg:msg: add Closes tag
- Results: 93f7e050cd84..d964bfb845c8 (export)

New patches for t/upstream:
- 106e35505557: mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
- 52865f3cc71f: tg:msg: add Closes tag
- Results: 9756359748a6..a972bdf0fdec (export)

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20220628T160121

https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export-net
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220628T160121
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export


> ---
> It should close issues/287, let's see what the CI says


I added the "Closes" tag in the commit message to link the patch with
the issue and automatically close the ticket ;-)

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

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

end of thread, other threads:[~2022-06-28 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27  9:58 [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Paolo Abeni
2022-06-27 10:06 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Build Failure MPTCP CI
2022-06-27 11:05   ` Matthieu Baerts
2022-06-27 11:35 ` mptcp: fix locking in mptcp_nl_cmd_sf_destroy(): Tests Results MPTCP CI
2022-06-27 22:46 ` [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Mat Martineau
2022-06-28 16:06 ` Matthieu Baerts

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