]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: decouple BPF link/attach hook and BPF program sleepable semantics
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 1 Nov 2024 18:17:53 +0000 (11:17 -0700)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 1 Nov 2024 18:39:07 +0000 (14:39 -0400)
commit61c6fefa92bb4ed7a34163b94f6ffac628237a29
treed20e5bad53b23de4c653b9f9865f37bb25460fdc
parentf44ec8733a8469143fde1984b5e6931b2e2f6f3f
bpf: decouple BPF link/attach hook and BPF program sleepable semantics

BPF link's lifecycle protection scheme depends on both BPF hook and BPF
program. If *either* of those require RCU Tasks Trace GP, then we need
to go through a chain of GPs before putting BPF program refcount and
deallocating BPF link memory.

This patch adds bpf_link-specific sleepable flag, which can be set to
true even if underlying BPF program is not sleepable itself. If either
link->sleepable or link->prog->sleepable is true, we'll go through
a chain of RCU Tasks Trace GP and RCU GP before putting BPF program and
freeing memory.

This will be used to protect BPF link for sleepable (faultable) raw
tracepoints in the next patch.

Link: https://lore.kernel.org/20241101181754.782341-2-andrii@kernel.org
Tested-by: Jordan Rife <jrife@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/linux/bpf.h
kernel/bpf/syscall.c