Fixes for Exceptions
Subsystems (5)
Kumar Kartikeya Dwivedi
maintainercover Fixes for Exceptions
Set of fixes for bugs reported for the exceptions series.
Kumar Kartikeya Dwivedi (3):
selftests/bpf: Print log buffer for exceptions test only on failure
bpf: Fix bpf_throw warning on 32-bit arch
bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y
arch/x86/net/bpf_jit_comp.c | 9 ++++----- kernel/bpf/helpers.c | 2 +- tools/testing/selftests/bpf/prog_tests/exceptions.c | 5 +++-- 3 files changed, 8 insertions(+), 8 deletions(-)
base-commit: ec6f1b4db95b7eedb3fe85f4f14e08fa0e9281c3
Signature · 1 line
2.41.0
Kumar Kartikeya Dwivedi
maintainerPATCH 1/3 selftests/bpf: Print log buffer for exceptions test only on failure
Alexei reported seeing log messages for some test cases even though we just wanted to match the error string from the verifier. Move the printing of the log buffer to a guarded condition so that we only print it when we fail to match on the expected string in the log buffer, preventing unneeded output when running the test.
--- tools/testing/selftests/bpf/prog_tests/exceptions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/exceptions.c +3 -2
@@ -103,9 +103,10 @@ static void test_exceptions_success(void) goto done; \ } \if (load_ret !=0 ) { \ -printf ("%s\n" , log_buf); \ -if (!ASSERT_OK_PTR (strstr (log_buf, msg),"strstr" )) \ +if (!ASSERT_OK_PTR (strstr (log_buf, msg),"strstr" )) { \ +printf ("%s\n" , log_buf); \ goto done; \ + } \ } \if (!load_ret && attach_err) { \if (!ASSERT_ERR_PTR (link =bpf_program__attach (prog),"attach err" )) \
Signature · 1 line
2.41.0
Kumar Kartikeya Dwivedi
maintainerPATCH 2/3 bpf: Fix bpf_throw warning on 32-bit arch
In reply to Kumar Kartikeya DwivediOn 32-bit architectures, the pointer width is 32-bit, while we try to cast from a u64 down to it, the compiler complains on mismatch in integer size. Fix this by first casting to long which should match the pointer width on targets supported by Linux.
--- kernel/bpf/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/helpers.c +1 -1
@@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie)* deeper stack depths than ctx.sp as we do not return from bpf_throw, * which skips compiler generated instrumentation to do the same. */ -kasan_unpoison_task_stack_below ((void *)ctx.sp); +kasan_unpoison_task_stack_below ((void *)(long )ctx.sp); ctx.aux->bpf_exception_cb (cookie, ctx.sp, ctx.bp);WARN (1 ,"A call to BPF exception callback should never return\n" ); }
Signature · 1 line
2.41.0
Kumar Kartikeya Dwivedi
maintainerPATCH 3/3 bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y
In reply to Kumar Kartikeya DwivediThe build with CONFIG_UNWINDER_FRAME_POINTER=y is broken for current exceptions feature as it assumes ORC unwinder specific fields in the unwind_state. Disable exceptions when frame_pointer unwinder is enabled for now.
--- arch/x86/net/bpf_jit_comp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/net/bpf_jit_comp.c +4 -5
@@ -3003,16 +3003,15 @@ void bpf_jit_free(struct bpf_prog *prog)bool bpf_jit_supports_exceptions (void ) {/* We unwind through both kernel frames (starting from within bpf_throw -* call) and BPF frames. Therefore we require one of ORC or FP unwinder -* to be enabled to walk kernel frames and reach BPF frames in the stack -* trace. +* call) and BPF frames. Therefore we require ORC unwinder to be enabled +* to walk kernel frames and reach BPF frames in the stack trace. */ -return IS_ENABLED (CONFIG_UNWINDER_ORC ) ||IS_ENABLED (CONFIG_UNWINDER_FRAME_POINTER ); +return IS_ENABLED (CONFIG_UNWINDER_ORC ); }void arch_bpf_stack_walk (bool (*consume_fn)(void *cookie,u64 ip,u64 sp,u64 bp),void *cookie) { -#if defined(CONFIG_UNWINDER_ORC ) || defined(CONFIG_UNWINDER_FRAME_POINTER ) +#if defined(CONFIG_UNWINDER_ORC )struct unwind_state state;unsigned long addr;
Signature · 1 line
2.41.0
Re: [PATCH bpf-next v1 3/3] bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y
Quoted 9 lines · Kumar Kartikeya Dwivedi
The build with
CONFIG_UNWINDER_FRAME_POINTER=yis broken for current exceptions feature as it assumes ORC unwinder specific fields in theunwind_state. Disable exceptions whenframe_pointerunwinder is enabled for now.Fixes fd5d27b70188 ("arch/x86: Implement arch_bpf_stack_walk")Reported-by Eric Dumazet <[email protected]>Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>
Very weird that only this patch reached patchwork. Could you resend and trim cc list significantly?
Kumar Kartikeya Dwivedi
maintainerRe: [PATCH bpf-next v1 3/3] bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y
Quoted 9 lines · Alexei Starovoitov
Quoted 6 lines · Kumar Kartikeya Dwivedi
The build with
CONFIG_UNWINDER_FRAME_POINTER=yis broken for current exceptions feature as it assumes ORC unwinder specific fields in theunwind_state. Disable exceptions whenframe_pointerunwinder is enabled for now.
Quoted 6 lines
Quoted 3 lines
Fixes fd5d27b70188 ("arch/x86: Implement arch_bpf_stack_walk")Reported-by Eric Dumazet <[email protected]>Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>Very weird that only this patch reached patchwork. Could you resend and trim cc list significantly?
I have resent it with just BPF and you in To:.
But I think it's not with this patch, a lot of emails are not appearing on the list.