Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

John Fastabend and committed by
David S. Miller
d26e597d 2f857d04

+6 -3
+6 -3
kernel/bpf/sockmap.c
··· 227 227 { 228 228 struct smap_psock *psock; 229 229 230 - write_lock_bh(&sk->sk_callback_lock); 230 + rcu_read_lock(); 231 231 psock = smap_psock_sk(sk); 232 - if (likely(psock)) 232 + if (likely(psock)) { 233 + write_lock_bh(&sk->sk_callback_lock); 233 234 strp_data_ready(&psock->strp); 234 - write_unlock_bh(&sk->sk_callback_lock); 235 + write_unlock_bh(&sk->sk_callback_lock); 236 + } 237 + rcu_read_unlock(); 235 238 } 236 239 237 240 static void smap_tx_work(struct work_struct *w)