diff options
| author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2025-07-03 13:48:10 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-07-03 19:30:06 -0700 |
| commit | d090326860096df9dac6f27cff76d3f8df44d4f1 (patch) | |
| tree | 2f3958edbb8eb87e8eb46971e81306a923cd487a /kernel/bpf/core.c | |
| parent | 0e521efaf36350b8f783984541efa56f560c90b0 (diff) | |
bpf: Ensure RCU lock is held around bpf_prog_ksym_find
Add a warning to ensure RCU lock is held around tree lookup, and then
fix one of the invocations in bpf_stack_walker. The program has an
active stack frame and won't disappear. Use the opportunity to remove
unneeded invocation of is_bpf_text_address.
Fixes: f18b03fabaa9 ("bpf: Implement BPF exceptions")
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20250703204818.925464-5-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/core.c')
| -rw-r--r-- | kernel/bpf/core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 2dc5b846ae50..833442661742 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -782,7 +782,10 @@ bool is_bpf_text_address(unsigned long addr) struct bpf_prog *bpf_prog_ksym_find(unsigned long addr) { - struct bpf_ksym *ksym = bpf_ksym_find(addr); + struct bpf_ksym *ksym; + + WARN_ON_ONCE(!rcu_read_lock_held()); + ksym = bpf_ksym_find(addr); return ksym && ksym->prog ? container_of(ksym, struct bpf_prog_aux, ksym)->prog : |