Re: [PATCH net-next] bpf: add missing rcu protection when releasing programs from prog_array
From: David Miller <davem@davemloft.net>
Date: 2015-05-31 07:28:03
From: David Miller <davem@davemloft.net>
Date: 2015-05-31 07:28:03
From: Alexei Starovoitov <redacted> Date: Thu, 28 May 2015 19:26:02 -0700
Normally the program attachment place (like sockets, qdiscs) takes
care of rcu protection and calls bpf_prog_put() after a grace period.
The programs stored inside prog_array may not be attached anywhere,
so prog_array needs to take care of preserving rcu protection.
Otherwise bpf_tail_call() will race with bpf_prog_put().
To solve that introduce bpf_prog_put_rcu() helper function and use
it in 3 places where unattached program can decrement refcnt:
closing program fd, deleting/replacing program in prog_array.
Fixes: 04fd61ab36ec ("bpf: allow bpf programs to tail-call other bpf programs")
Reported-by: Martin Schwidefsky <redacted>
Signed-off-by: Alexei Starovoitov <redacted>Applied, thank you.