From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: mptcp@lists.linux.dev, Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
Date: Mon, 27 Jun 2022 15:46:12 -0700 (PDT) [thread overview]
Message-ID: <d8ed8625-2761-b74-793f-268f14a04727@linux.intel.com> (raw)
In-Reply-To: <886e059dc9096dcc9e1daa1eb1a07ec34d72aa74.1656323519.git.pabeni@redhat.com>
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
next prev parent reply other threads:[~2022-06-27 22:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Mat Martineau [this message]
2022-06-28 16:06 ` [PATCH mptcp-net] mptcp: fix locking in mptcp_nl_cmd_sf_destroy() Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8ed8625-2761-b74-793f-268f14a04727@linux.intel.com \
--to=mathew.j.martineau@linux.intel.com \
--cc=fw@strlen.de \
--cc=mptcp@lists.linux.dev \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).