diff options
author | John Fastabend <john.fastabend@gmail.com> | 2017-08-28 07:10:45 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-28 11:13:21 -0700 |
commit | d26e597d87635d90128fafb3f6bb0a14d972d952 (patch) | |
tree | c3da1ee7debd158cbd33beaea31330c807a7c2fd /kernel/bpf/sockmap.c | |
parent | 2f857d04601a1bb56958b95a9f180bce0e91e5e6 (diff) | |
download | linux-d26e597d87635d90128fafb3f6bb0a14d972d952.tar.gz linux-d26e597d87635d90128fafb3f6bb0a14d972d952.tar.bz2 linux-d26e597d87635d90128fafb3f6bb0a14d972d952.zip |
bpf: sockmap add missing rcu_read_(un)lock in smap_data_ready
References to psock must be done inside RCU critical section.
Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/sockmap.c')
-rw-r--r-- | kernel/bpf/sockmap.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index a6882e54930b..266011c822ec 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -227,11 +227,14 @@ static void smap_data_ready(struct sock *sk) { struct smap_psock *psock; - write_lock_bh(&sk->sk_callback_lock); + rcu_read_lock(); psock = smap_psock_sk(sk); - if (likely(psock)) + if (likely(psock)) { + write_lock_bh(&sk->sk_callback_lock); strp_data_ready(&psock->strp); - write_unlock_bh(&sk->sk_callback_lock); + write_unlock_bh(&sk->sk_callback_lock); + } + rcu_read_unlock(); } static void smap_tx_work(struct work_struct *w) |