Commit b3af9c0e authored by David S. Miller's avatar David S. Miller

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 6c0da840 aec42f36
...@@ -3003,16 +3003,15 @@ void bpf_jit_free(struct bpf_prog *prog) ...@@ -3003,16 +3003,15 @@ void bpf_jit_free(struct bpf_prog *prog)
bool bpf_jit_supports_exceptions(void) bool bpf_jit_supports_exceptions(void)
{ {
/* We unwind through both kernel frames (starting from within bpf_throw /* We unwind through both kernel frames (starting from within bpf_throw
* call) and BPF frames. Therefore we require one of ORC or FP unwinder * call) and BPF frames. Therefore we require ORC unwinder to be enabled
* to be enabled to walk kernel frames and reach BPF frames in the stack * to walk kernel frames and reach BPF frames in the stack trace.
* 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) 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; struct unwind_state state;
unsigned long addr; unsigned long addr;
......
...@@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie) ...@@ -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, * deeper stack depths than ctx.sp as we do not return from bpf_throw,
* which skips compiler generated instrumentation to do the same. * 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); ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp);
WARN(1, "A call to BPF exception callback should never return\n"); WARN(1, "A call to BPF exception callback should never return\n");
} }
......
...@@ -15339,14 +15339,12 @@ static int check_btf_func(struct bpf_verifier_env *env, ...@@ -15339,14 +15339,12 @@ static int check_btf_func(struct bpf_verifier_env *env,
bpfptr_t uattr) bpfptr_t uattr)
{ {
const struct btf_type *type, *func_proto, *ret_type; const struct btf_type *type, *func_proto, *ret_type;
u32 i, nfuncs, urec_size, min_size; u32 i, nfuncs, urec_size;
u32 krec_size = sizeof(struct bpf_func_info);
struct bpf_func_info *krecord; struct bpf_func_info *krecord;
struct bpf_func_info_aux *info_aux = NULL; struct bpf_func_info_aux *info_aux = NULL;
struct bpf_prog *prog; struct bpf_prog *prog;
const struct btf *btf; const struct btf *btf;
bpfptr_t urecord; bpfptr_t urecord;
u32 prev_offset = 0;
bool scalar_return; bool scalar_return;
int ret = -ENOMEM; int ret = -ENOMEM;
...@@ -15367,7 +15365,6 @@ static int check_btf_func(struct bpf_verifier_env *env, ...@@ -15367,7 +15365,6 @@ static int check_btf_func(struct bpf_verifier_env *env,
btf = prog->aux->btf; btf = prog->aux->btf;
urecord = make_bpfptr(attr->func_info, uattr.is_kernel); urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
min_size = min_t(u32, krec_size, urec_size);
krecord = prog->aux->func_info; krecord = prog->aux->func_info;
info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN); info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
...@@ -15401,7 +15398,6 @@ static int check_btf_func(struct bpf_verifier_env *env, ...@@ -15401,7 +15398,6 @@ static int check_btf_func(struct bpf_verifier_env *env,
goto err_free; goto err_free;
} }
prev_offset = krecord[i].insn_off;
bpfptr_add(&urecord, urec_size); bpfptr_add(&urecord, urec_size);
} }
......
...@@ -103,10 +103,11 @@ static void test_exceptions_success(void) ...@@ -103,10 +103,11 @@ static void test_exceptions_success(void)
goto done; \ goto done; \
} \ } \
if (load_ret != 0) { \ if (load_ret != 0) { \
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \
printf("%s\n", log_buf); \ printf("%s\n", log_buf); \
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) \
goto done; \ goto done; \
} \ } \
} \
if (!load_ret && attach_err) { \ if (!load_ret && attach_err) { \
if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \ if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \
goto done; \ goto done; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment