From: Mat Martineau <mathew.j.martineau at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [MPTCP][PATCH net-next] mptcp: free resources when the port number is mismatched
Date: Tue, 16 Feb 2021 17:29:18 -0800 [thread overview]
Message-ID: <edb21055-e9a5-3a4-c43e-708ade17bc77@linux.intel.com> (raw)
In-Reply-To: c79259641c0fda0a0df41c25f58ae0a1da1e3839.1613112149.git.geliangtang@gmail.com
[-- Attachment #1: Type: text/plain, Size: 2672 bytes --]
On Fri, 12 Feb 2021, Geliang Tang wrote:
> When the port number is mismatched with the announced ones, use
> 'goto dispose_child' to free the resources instead of using 'goto out'.
>
> This patch also moves the port number checking code in
> subflow_syn_recv_sock before the setting of ctx->conn, otherwise
> subflow_drop_ctx will fail in dispose_child.
>
> Fixes: 5bc56388c74f ("mptcp: add port number check for MP_JOIN")
> Reported-by: Paolo Abeni <pabeni(a)redhat.com>
> Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
> ---
> net/mptcp/subflow.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 280da418d60b..a9c8daf72768 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -692,25 +692,25 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
> if (!owner)
> goto dispose_child;
>
> - /* move the msk reference ownership to the subflow */
> - subflow_req->msk = NULL;
> - ctx->conn = (struct sock *)owner;
What kind of failure did you see in subflow_drop_ctx() if ctx->conn is set
before the port number check? If it's the sock_put(ctx->conn), that makes
me wonder if there's an existing sock_hold/sock_put imbalance somewhere.
Just trying to make sure we aren't hiding an existing bug here, since it
looks like the above three lines shouldn't need to be moved, while these
lines:
> - if (!mptcp_finish_join(child))
> - goto dispose_child;
> -
> - SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX);
> - tcp_rsk(req)->drop_req = true;
> -
...do look like they belong after the port check.
Mat
> if (subflow_use_different_sport(owner, sk)) {
> pr_debug("ack inet_sport=%d %d",
> ntohs(inet_sk(sk)->inet_sport),
> ntohs(inet_sk((struct sock *)owner)->inet_sport));
> if (!mptcp_pm_sport_in_anno_list(owner, sk)) {
> SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MISMATCHPORTACKRX);
> - goto out;
> + goto dispose_child;
> }
> SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINPORTACKRX);
> }
> +
> + /* move the msk reference ownership to the subflow */
> + subflow_req->msk = NULL;
> + ctx->conn = (struct sock *)owner;
> + if (!mptcp_finish_join(child))
> + goto dispose_child;
> +
> + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX);
> + tcp_rsk(req)->drop_req = true;
> }
> }
>
> --
> 2.29.2
> _______________________________________________
> mptcp mailing list -- mptcp(a)lists.01.org
> To unsubscribe send an email to mptcp-leave(a)lists.01.org
>
--
Mat Martineau
Intel
reply other threads:[~2021-02-17 1:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=edb21055-e9a5-3a4-c43e-708ade17bc77@linux.intel.com \
--to=mptcp@lists.linux.dev \
/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