bpf: sockmap add missing rcu_read_(un)lock in smap_data_ready
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 28 Aug 2017 14:10:45 +0000 (07:10 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Aug 2017 18:13:21 +0000 (11:13 -0700)
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>
kernel/bpf/sockmap.c

index a6882e54930b2891efd17192112f98d0c5497c69..266011c822ec5cc58b635016c5c2022bf94e3fa1 100644 (file)
@@ -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)