Message ID | 20210809060320.1176782-1-yhs@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: fix a couple of issues with syscall program | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | fail | 1 blamed authors not CCed: john.fastabend@gmail.com; 7 maintainers not CCed: netdev@vger.kernel.org john.fastabend@gmail.com davem@davemloft.net kuba@kernel.org songliubraving@fb.com kpsingh@kernel.org kafai@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 13 this patch: 13 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 17 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 13 this patch: 13 |
netdev/header_inline | success | Link |
On Sun, Aug 8, 2021 at 11:03 PM Yonghong Song <yhs@fb.com> wrote: > > 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 added bpf_read_[un]lock_trace() properly. > > Fixes: 79a7f8bdb159d ("bpf: Introduce bpf_sys_bpf() helper and program type.") > Signed-off-by: Yonghong Song <yhs@fb.com> > --- LGTM. Acked-by: Andrii Nakryiko <andrii@kernel.org> > net/bpf/test_run.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c > index 1cc75c811e24..caa16bf30fb5 100644 > --- a/net/bpf/test_run.c > +++ b/net/bpf/test_run.c > @@ -7,6 +7,7 @@ > #include <linux/vmalloc.h> > #include <linux/etherdevice.h> > #include <linux/filter.h> > +#include <linux/rcupdate_trace.h> > #include <linux/sched/signal.h> > #include <net/bpf_sk_storage.h> > #include <net/sock.h> > @@ -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; > -- > 2.30.2 >
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 1cc75c811e24..caa16bf30fb5 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -7,6 +7,7 @@ #include <linux/vmalloc.h> #include <linux/etherdevice.h> #include <linux/filter.h> +#include <linux/rcupdate_trace.h> #include <linux/sched/signal.h> #include <net/bpf_sk_storage.h> #include <net/sock.h> @@ -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;
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 added bpf_read_[un]lock_trace() properly. Fixes: 79a7f8bdb159d ("bpf: Introduce bpf_sys_bpf() helper and program type.") Signed-off-by: Yonghong Song <yhs@fb.com> --- net/bpf/test_run.c | 4 ++++ 1 file changed, 4 insertions(+)