From: Yonghong Song Date: Mon, 9 Aug 2021 23:51:51 +0000 (-0700) Subject: bpf: Add missing bpf_read_[un]lock_trace() for syscall program X-Git-Tag: v5.14-rc6~21^2~14^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87b7b5335e6995a6d64fca98fc67b92b29caac9c;p=thirdparty%2Fkernel%2Flinux.git bpf: Add missing bpf_read_[un]lock_trace() for syscall program Commit 79a7f8bdb159d ("bpf: Introduce bpf_sys_bpf() helper and program type.") added support for syscall program, which is a sleepable program. But the program run missed bpf_read_lock_trace()/bpf_read_unlock_trace(), which is needed to ensure proper rcu callback invocations. This patch adds bpf_read_[un]lock_trace() properly. Fixes: 79a7f8bdb159d ("bpf: Introduce bpf_sys_bpf() helper and program type.") Signed-off-by: Yonghong Song Signed-off-by: Daniel Borkmann Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210809235151.1663680-1-yhs@fb.com --- diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 1cc75c811e247..caa16bf30fb55 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -951,7 +952,10 @@ int bpf_prog_test_run_syscall(struct bpf_prog *prog, goto out; } } + + rcu_read_lock_trace(); retval = bpf_prog_run_pin_on_cpu(prog, ctx); + rcu_read_unlock_trace(); if (copy_to_user(&uattr->test.retval, &retval, sizeof(u32))) { err = -EFAULT;