Skip to content

Commit 87b7b53

Browse files
yonghong-songborkmann
authored andcommitted
bpf: Add missing bpf_read_[un]lock_trace() for syscall program
Commit 79a7f8b ("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: 79a7f8b ("bpf: Introduce bpf_sys_bpf() helper and program type.") Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 51e1bb9 commit 87b7b53

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/bpf/test_run.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/vmalloc.h>
88
#include <linux/etherdevice.h>
99
#include <linux/filter.h>
10+
#include <linux/rcupdate_trace.h>
1011
#include <linux/sched/signal.h>
1112
#include <net/bpf_sk_storage.h>
1213
#include <net/sock.h>
@@ -951,7 +952,10 @@ int bpf_prog_test_run_syscall(struct bpf_prog *prog,
951952
goto out;
952953
}
953954
}
955+
956+
rcu_read_lock_trace();
954957
retval = bpf_prog_run_pin_on_cpu(prog, ctx);
958+
rcu_read_unlock_trace();
955959

956960
if (copy_to_user(&uattr->test.retval, &retval, sizeof(u32))) {
957961
err = -EFAULT;

0 commit comments

Comments
 (0)