From: Eric Dumazet <eric.dumazet@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
kernel-team@fb.com
Subject: Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()
Date: Fri, 27 Sep 2019 10:24:49 -0700 [thread overview]
Message-ID: <04f683c6-ac49-05fb-6ec9-9f0d698657a2@gmail.com> (raw)
In-Reply-To: <20190927165221.2391541-1-kafai@fb.com>
On 9/27/19 9:52 AM, Martin KaFai Lau wrote:
> In reuseport_array_free(), the rcu_read_lock() cannot ensure sk is still
> valid. It is because bpf_sk_reuseport_detach() can be called from
> __sk_destruct() which is invoked through call_rcu(..., __sk_destruct).
We could question why reuseport_detach_sock(sk) is called from __sk_destruct()
(after the rcu grace period) instead of sk_destruct() ?
>
> This patch takes the reuseport_lock in reuseport_array_free() which
> is not the fast path. The lock is taken inside the loop in case
> that the bpf map is big.
>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Fixes: 5dc4c4b7d4e8 ("bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY")
next prev parent reply other threads:[~2019-09-27 17:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 16:52 [PATCH bpf] bpf: Fix a race in reuseport_array_free() Martin KaFai Lau
2019-09-27 17:24 ` Eric Dumazet [this message]
2019-09-27 18:17 ` Martin Lau
2019-09-27 20:47 ` Eric Dumazet
2019-09-27 21:22 ` Martin Lau
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=04f683c6-ac49-05fb-6ec9-9f0d698657a2@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kafai@fb.com \
--cc=kernel-team@fb.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