Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Browse files Browse the repository at this point in the history
Alexei Starovoitov says:

====================
bpf-next 2023-09-19

The following pull-request contains BPF updates for your *net-next* tree.

We've added 4 non-merge commits during the last 1 day(s) which contain
a total of 4 files changed, 9 insertions(+), 13 deletions(-).

The main changes are:

1) A set of fixes for bpf exceptions, from Kumar and Alexei.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 20, 2023
2 parents 6c0da84 + aec42f3 commit b3af9c0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
9 changes: 4 additions & 5 deletions arch/x86/net/bpf_jit_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion kernel/bpf/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 1 addition & 5 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -15339,14 +15339,12 @@ static int check_btf_func(struct bpf_verifier_env *env,
bpfptr_t uattr)
{
const struct btf_type *type, *func_proto, *ret_type;
u32 i, nfuncs, urec_size, min_size;
u32 krec_size = sizeof(struct bpf_func_info);
u32 i, nfuncs, urec_size;
struct bpf_func_info *krecord;
struct bpf_func_info_aux *info_aux = NULL;
struct bpf_prog *prog;
const struct btf *btf;
bpfptr_t urecord;
u32 prev_offset = 0;
bool scalar_return;
int ret = -ENOMEM;

Expand All @@ -15367,7 +15365,6 @@ static int check_btf_func(struct bpf_verifier_env *env,
btf = prog->aux->btf;

urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
min_size = min_t(u32, krec_size, urec_size);

krecord = prog->aux->func_info;
info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
Expand Down Expand Up @@ -15401,7 +15398,6 @@ static int check_btf_func(struct bpf_verifier_env *env,
goto err_free;
}

prev_offset = krecord[i].insn_off;
bpfptr_add(&urecord, urec_size);
}

Expand Down
5 changes: 3 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) \
Expand Down

0 comments on commit b3af9c0

Please sign in to comment.