bpf: prevent kprobe+bpf deadlocks
authorAlexei Starovoitov <ast@fb.com>
Tue, 8 Mar 2016 05:57:13 +0000 (21:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Mar 2016 20:28:30 +0000 (15:28 -0500)
commitb121d1e74d1f24654bdc3165d3db1ca149501356
treeaa0326edc95e2152a2277386b5363beb7768f7dc
parent8aba8b83128a04197991518e241aafd3323b705d
bpf: prevent kprobe+bpf deadlocks

if kprobe is placed within update or delete hash map helpers
that hold bucket spin lock and triggered bpf program is trying to
grab the spinlock for the same bucket on the same cpu, it will
deadlock.
Fix it by extending existing recursion prevention mechanism.

Note, map_lookup and other tracing helpers don't have this problem,
since they don't hold any locks and don't modify global data.
bpf_trace_printk has its own recursive check and ok as well.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
kernel/bpf/syscall.c
kernel/trace/bpf_trace.c