From: Florian Westphal <fw at strlen.de>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [PATCH] mptcp: only orphan partially subflow at close time
Date: Thu, 12 Dec 2019 17:16:39 +0100 [thread overview]
Message-ID: <20191212161639.GN795@breakpoint.cc> (raw)
In-Reply-To: a4d28a295c187d20e3b6a9d345597eac474b6e59.1576164482.git.pabeni@redhat.com
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
Paolo Abeni <pabeni(a)redhat.com> wrote:
> This close the following race
>
> CPU 0 CPU 1
> sock_orphan()
> // SOCK_DEAD
> tcp_done()
> inet_csk_destroy_sock()
> sock_put()
>
> tcp_close()
> // UAF
>
> Note that we can't simply acquire an additional ref to the
> sock before sock_orphan() and releasing it after close,
> such ref will be consumed by inet_csk_destroy_sock when
> the race is triggered.
>
> Squash-to: "mptcp: Handle MP_CAPABLE options for outgoing connections"
> Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
> ---
> net/mptcp/protocol.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 9506e04a2010..24d68e504e9c 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -178,8 +178,16 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
> /* outgoing subflow */
> sock_release(sock);
> } else {
> - /* incoming subflow */
> - sock_orphan(ssk);
> + /* This is an incoming subflow. We almost orphan it,
> + * but do not mark has death, otherwise inet_csk_destroy_sock
> + * may kick-in via tcp_done() and steal one reference
> + * before tcp_close below.
> + */
> + write_lock_bh(&sk->sk_callback_lock);
> + sk_set_socket(sk, NULL);
> + sk->sk_wq = NULL;
> + write_unlock_bh(&sk->sk_callback_lock);
> +
Hmm, I wonder if we can't just remove sock_orphan()?
next reply other threads:[~2019-12-12 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 16:16 Florian Westphal [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-12-12 17:03 [MPTCP] Re: [PATCH] mptcp: only orphan partially subflow at close time Paolo Abeni
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=20191212161639.GN795@breakpoint.cc \
--to=unknown@example.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.