]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Use recursion prevention helpers in hashtab code
authorThomas Gleixner <tglx@linutronix.de>
Mon, 24 Feb 2020 14:01:48 +0000 (15:01 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Feb 2020 00:20:10 +0000 (16:20 -0800)
commit36ece1844b0cfd0ede8ae42d12b318f42c006f1e
treee215f625f6ca1185cd82d9fd65a2585c109f6b5d
parent1be10e012c65a83e770fde1485a8f5a1ec35741d
bpf: Use recursion prevention helpers in hashtab code

The required protection is that the caller cannot be migrated to a
different CPU as these places take either a hash bucket lock or might
trigger a kprobe inside the memory allocator. Both scenarios can lead to
deadlocks. The deadlock prevention is per CPU by incrementing a per CPU
variable which temporarily blocks the invocation of BPF programs from perf
and kprobes.

Replace the open coded preempt_disable/enable() and this_cpu_inc/dec()
pairs with the new recursion prevention helpers to prepare BPF to work on
PREEMPT_RT enabled kernels. On a non-RT kernel the migrate disable/enable
in the helpers map to preempt_disable/enable(), i.e. no functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200224145644.211208533@linutronix.de
kernel/bpf/hashtab.c