* [PATCH net] bpf, perf: delay release of BPF prog after grace period
@ 2016-06-27 19:38 Daniel Borkmann
2016-06-29 9:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2016-06-27 19:38 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-kernel, alexei.starovoitov, Daniel Borkmann,
Jann Horn
Commit dead9f29ddcc ("perf: Fix race in BPF program unregister") moved
destruction of BPF program from free_event_rcu() callback to __free_event(),
which is problematic if used with tail calls: if prog A is attached as
trace event directly, but at the same time present in a tail call map used
by another trace event program elsewhere, then we need to delay destruction
via RCU grace period since it can still be in use by the program doing the
tail call (the prog first needs to be dropped from the tail call map, then
trace event with prog A attached destroyed, so we get immediate destruction).
Fixes: dead9f29ddcc ("perf: Fix race in BPF program unregister")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Jann Horn <jann@thejh.net>
---
include/linux/bpf.h | 4 ++++
kernel/events/core.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8269caf..0de4de6 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -264,6 +264,10 @@ static inline struct bpf_prog *bpf_prog_get(u32 ufd)
static inline void bpf_prog_put(struct bpf_prog *prog)
{
}
+
+static inline void bpf_prog_put_rcu(struct bpf_prog *prog)
+{
+}
#endif /* CONFIG_BPF_SYSCALL */
/* verifier prototypes for helper functions called from eBPF programs */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 274450e..d00c47b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7531,7 +7531,7 @@ static void perf_event_free_bpf_prog(struct perf_event *event)
prog = event->tp_event->prog;
if (prog) {
event->tp_event->prog = NULL;
- bpf_prog_put(prog);
+ bpf_prog_put_rcu(prog);
}
}
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] bpf, perf: delay release of BPF prog after grace period
2016-06-27 19:38 [PATCH net] bpf, perf: delay release of BPF prog after grace period Daniel Borkmann
@ 2016-06-29 9:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-06-29 9:43 UTC (permalink / raw)
To: daniel; +Cc: netdev, linux-kernel, alexei.starovoitov, jann
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Mon, 27 Jun 2016 21:38:11 +0200
> Commit dead9f29ddcc ("perf: Fix race in BPF program unregister") moved
> destruction of BPF program from free_event_rcu() callback to __free_event(),
> which is problematic if used with tail calls: if prog A is attached as
> trace event directly, but at the same time present in a tail call map used
> by another trace event program elsewhere, then we need to delay destruction
> via RCU grace period since it can still be in use by the program doing the
> tail call (the prog first needs to be dropped from the tail call map, then
> trace event with prog A attached destroyed, so we get immediate destruction).
>
> Fixes: dead9f29ddcc ("perf: Fix race in BPF program unregister")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> Cc: Jann Horn <jann@thejh.net>
Applied and queued up for -stable, thanks Daniel.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-29 9:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-27 19:38 [PATCH net] bpf, perf: delay release of BPF prog after grace period Daniel Borkmann
2016-06-29 9:43 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).