提交 691b767a 编写于 作者: T Thomas Gleixner 提交者: Yang Yingliang

bpf: Remove recursion prevention from rcu free callback

[ Upstream commit 8a37963c ]

If an element is freed via RCU then recursion into BPF instrumentation
functions is not a concern. The element is already detached from the map
and the RCU callback does not hold any locks on which a kprobe, perf event
or tracepoint attached BPF program could deadlock.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200224145643.259118710@linutronix.deSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f119be5e
...@@ -667,15 +667,7 @@ static void htab_elem_free_rcu(struct rcu_head *head) ...@@ -667,15 +667,7 @@ static void htab_elem_free_rcu(struct rcu_head *head)
struct htab_elem *l = container_of(head, struct htab_elem, rcu); struct htab_elem *l = container_of(head, struct htab_elem, rcu);
struct bpf_htab *htab = l->htab; struct bpf_htab *htab = l->htab;
/* must increment bpf_prog_active to avoid kprobe+bpf triggering while
* we're calling kfree, otherwise deadlock is possible if kprobes
* are placed somewhere inside of slub
*/
preempt_disable();
__this_cpu_inc(bpf_prog_active);
htab_elem_free(htab, l); htab_elem_free(htab, l);
__this_cpu_dec(bpf_prog_active);
preempt_enable();
} }
static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l) static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册