public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: edumazet@google.com, ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org
Subject: Re: [bpf PATCH v2 2/3] bpf: sockmap, fix transition through disconnect without close
Date: Mon, 17 Sep 2018 12:52:01 -0700	[thread overview]
Message-ID: <7a85593b-7589-758e-2e5a-21c2ab1c6a5a@gmail.com> (raw)
In-Reply-To: <20180917175922.3870.69188.stgit@john-Precision-Tower-5810>

On 09/17/2018 10:59 AM, John Fastabend wrote:
> It is possible (via shutdown()) for TCP socks to go trough TCP_CLOSE
> state via tcp_disconnect() without actually calling tcp_close which
> would then call our bpf_tcp_close() callback. Because of this a user
> could disconnect a socket then put it in a LISTEN state which would
> break our assumptions about sockets always being ESTABLISHED state.
> 
> To resolve this rely on the unhash hook, which is called in the
> disconnect case, to remove the sock from the sockmap.
> 

Sorry for the noise will need a v3 actually.

> Reported-by: Eric Dumazet <edumazet@google.com>
> Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks")
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> ---
>  kernel/bpf/sockmap.c |   71 +++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 52 insertions(+), 19 deletions(-)

[...]


> +}
> +
> +static void bpf_tcp_unhash(struct sock *sk)
> +{
> +	void (*unhash_fun)(struct sock *sk);
> +	struct smap_psock *psock;
> +
> +	rcu_read_lock();
> +	psock = smap_psock_sk(sk);
> +	if (unlikely(!psock)) {
> +		rcu_read_unlock();
> +		release_sock(sk);
                 ^^^^^^^^^^^^^^^^^
> +		return sk->sk_prot->unhash(sk);

		if (sk->sk_prot->unhash) ...
		else return;

Thanks,
John

  reply	other threads:[~2018-09-18  1:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17 17:59 [bpf PATCH v2 0/3] bpf, sockmap ESTABLISHED state only John Fastabend
2018-09-17 17:59 ` [bpf PATCH v2 1/3] bpf: sockmap only allow ESTABLISHED sock state John Fastabend
2018-09-17 17:59 ` [bpf PATCH v2 2/3] bpf: sockmap, fix transition through disconnect without close John Fastabend
2018-09-17 19:52   ` John Fastabend [this message]
2018-09-17 17:59 ` [bpf PATCH v2 3/3] bpf: test_maps, only support ESTABLISHED socks John Fastabend

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=7a85593b-7589-758e-2e5a-21c2ab1c6a5a@gmail.com \
    --to=john.fastabend@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    /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