* [PATCH] bpf: test_bpf: turn of preemption in function __run_once
@ 2019-02-21 8:44 Anders Roxell
2019-02-21 15:37 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Anders Roxell @ 2019-02-21 8:44 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-kernel, Anders Roxell
When running test seccomp_bpf the following splat occurs:
[ RUN ] global.secseccomp_bpf.c:2136:global.detect_seccomp_filter_flags:Expected 22 (22) == (*__errno_location ()) (14)
seccomp_bpf.c:2138:global.detect_seccomp_filter_flags:Failed to detect that an unknown
filter flag (0x8) is unsupported! Does a new flag need to be added to this test?
[ 2155.677841] BUG: assuming atomic context at kernel/seccomp.c:271
[ 2155.689351] in_atomic(): 0, irqs_disabled(): 0, pid: 28540, name: seccomp_bpf
[ 2155.696597] INFO: lockdep is turned off.
[ 2155.700605] CPU: 5 PID: 28540 Comm: seccomp_bpf Tainted: G W 5.0.0-rc7-next-20190220 #1
[ 2155.709972] Hardware name: HiKey Development Board (DT)
[ 2155.715232] Call trace:
[ 2155.717710] dump_backtrace+0x0/0x160
[ 2155.721399] show_stack+0x24/0x30
[ 2155.724742] dump_stack+0xc8/0x114
[ 2155.728172] __cant_sleep+0xf0/0x108
[ 2155.731777] __seccomp_filter+0x8c/0x5c8
[ 2155.735727] __secure_computing+0x4c/0xe8
[ 2155.739767] syscall_trace_enter+0xf8/0x2b8
[ 2155.743982] el0_svc_common+0xf0/0x130
[ 2155.747758] el0_svc_handler+0x38/0x78
[ 2155.751534] el0_svc+0x8/0xc
Rework so that preemption is disabled when we loop over function
'BPF_PROG_RUN(...)'.
Commit 568f196756ad ("bpf: check that BPF programs run with preemption disabled")
highlighted the issue.
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
lib/test_bpf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index f3e570722a7e..0845f635f404 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -6668,12 +6668,14 @@ static int __run_one(const struct bpf_prog *fp, const void *data,
u64 start, finish;
int ret = 0, i;
+ preempt_disable();
start = ktime_get_ns();
for (i = 0; i < runs; i++)
ret = BPF_PROG_RUN(fp, data);
finish = ktime_get_ns();
+ preempt_enable();
*duration = finish - start;
do_div(*duration, runs);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: test_bpf: turn of preemption in function __run_once
2019-02-21 8:44 [PATCH] bpf: test_bpf: turn of preemption in function __run_once Anders Roxell
@ 2019-02-21 15:37 ` Daniel Borkmann
2019-02-22 8:25 ` Anders Roxell
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2019-02-21 15:37 UTC (permalink / raw)
To: Anders Roxell, ast; +Cc: netdev, linux-kernel
On 02/21/2019 09:44 AM, Anders Roxell wrote:
> When running test seccomp_bpf the following splat occurs:
>
> [ RUN ] global.secseccomp_bpf.c:2136:global.detect_seccomp_filter_flags:Expected 22 (22) == (*__errno_location ()) (14)
> seccomp_bpf.c:2138:global.detect_seccomp_filter_flags:Failed to detect that an unknown
> filter flag (0x8) is unsupported! Does a new flag need to be added to this test?
> [ 2155.677841] BUG: assuming atomic context at kernel/seccomp.c:271
> [ 2155.689351] in_atomic(): 0, irqs_disabled(): 0, pid: 28540, name: seccomp_bpf
> [ 2155.696597] INFO: lockdep is turned off.
> [ 2155.700605] CPU: 5 PID: 28540 Comm: seccomp_bpf Tainted: G W 5.0.0-rc7-next-20190220 #1
> [ 2155.709972] Hardware name: HiKey Development Board (DT)
> [ 2155.715232] Call trace:
> [ 2155.717710] dump_backtrace+0x0/0x160
> [ 2155.721399] show_stack+0x24/0x30
> [ 2155.724742] dump_stack+0xc8/0x114
> [ 2155.728172] __cant_sleep+0xf0/0x108
> [ 2155.731777] __seccomp_filter+0x8c/0x5c8
> [ 2155.735727] __secure_computing+0x4c/0xe8
> [ 2155.739767] syscall_trace_enter+0xf8/0x2b8
> [ 2155.743982] el0_svc_common+0xf0/0x130
> [ 2155.747758] el0_svc_handler+0x38/0x78
> [ 2155.751534] el0_svc+0x8/0xc
>
> Rework so that preemption is disabled when we loop over function
> 'BPF_PROG_RUN(...)'.
> Commit 568f196756ad ("bpf: check that BPF programs run with preemption disabled")
> highlighted the issue.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Hmm, wrong commit description? Below code is not related to seccomp
but rather BPF test suite. Could you fix it up and resubmit? Rest
looks okay to me.
> ---
> lib/test_bpf.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index f3e570722a7e..0845f635f404 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -6668,12 +6668,14 @@ static int __run_one(const struct bpf_prog *fp, const void *data,
> u64 start, finish;
> int ret = 0, i;
>
> + preempt_disable();
> start = ktime_get_ns();
>
> for (i = 0; i < runs; i++)
> ret = BPF_PROG_RUN(fp, data);
>
> finish = ktime_get_ns();
> + preempt_enable();
>
> *duration = finish - start;
> do_div(*duration, runs);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: test_bpf: turn of preemption in function __run_once
2019-02-21 15:37 ` Daniel Borkmann
@ 2019-02-22 8:25 ` Anders Roxell
0 siblings, 0 replies; 3+ messages in thread
From: Anders Roxell @ 2019-02-22 8:25 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: Alexei Starovoitov, Networking, Linux Kernel Mailing List
On Thu, 21 Feb 2019 at 16:38, Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 02/21/2019 09:44 AM, Anders Roxell wrote:
> > When running test seccomp_bpf the following splat occurs:
> >
> > [ RUN ] global.secseccomp_bpf.c:2136:global.detect_seccomp_filter_flags:Expected 22 (22) == (*__errno_location ()) (14)
> > seccomp_bpf.c:2138:global.detect_seccomp_filter_flags:Failed to detect that an unknown
> > filter flag (0x8) is unsupported! Does a new flag need to be added to this test?
> > [ 2155.677841] BUG: assuming atomic context at kernel/seccomp.c:271
> > [ 2155.689351] in_atomic(): 0, irqs_disabled(): 0, pid: 28540, name: seccomp_bpf
> > [ 2155.696597] INFO: lockdep is turned off.
> > [ 2155.700605] CPU: 5 PID: 28540 Comm: seccomp_bpf Tainted: G W 5.0.0-rc7-next-20190220 #1
> > [ 2155.709972] Hardware name: HiKey Development Board (DT)
> > [ 2155.715232] Call trace:
> > [ 2155.717710] dump_backtrace+0x0/0x160
> > [ 2155.721399] show_stack+0x24/0x30
> > [ 2155.724742] dump_stack+0xc8/0x114
> > [ 2155.728172] __cant_sleep+0xf0/0x108
> > [ 2155.731777] __seccomp_filter+0x8c/0x5c8
> > [ 2155.735727] __secure_computing+0x4c/0xe8
> > [ 2155.739767] syscall_trace_enter+0xf8/0x2b8
> > [ 2155.743982] el0_svc_common+0xf0/0x130
> > [ 2155.747758] el0_svc_handler+0x38/0x78
> > [ 2155.751534] el0_svc+0x8/0xc
> >
> > Rework so that preemption is disabled when we loop over function
> > 'BPF_PROG_RUN(...)'.
> > Commit 568f196756ad ("bpf: check that BPF programs run with preemption disabled")
> > highlighted the issue.
> >
> > Suggested-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
>
> Hmm, wrong commit description?
urgh, you are correct. I'm sorry.
Sending a v2 shortly.
> Below code is not related to seccomp
> but rather BPF test suite. Could you fix it up and resubmit? Rest
> looks okay to me.
>
> > ---
> > lib/test_bpf.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> > index f3e570722a7e..0845f635f404 100644
> > --- a/lib/test_bpf.c
> > +++ b/lib/test_bpf.c
> > @@ -6668,12 +6668,14 @@ static int __run_one(const struct bpf_prog *fp, const void *data,
> > u64 start, finish;
> > int ret = 0, i;
> >
> > + preempt_disable();
> > start = ktime_get_ns();
> >
> > for (i = 0; i < runs; i++)
> > ret = BPF_PROG_RUN(fp, data);
> >
> > finish = ktime_get_ns();
> > + preempt_enable();
> >
> > *duration = finish - start;
> > do_div(*duration, runs);
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-22 8:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 8:44 [PATCH] bpf: test_bpf: turn of preemption in function __run_once Anders Roxell
2019-02-21 15:37 ` Daniel Borkmann
2019-02-22 8:25 ` Anders Roxell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).