Skip to content

Commit b3af9c0

Browse files
committed
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: David S. Miller <[email protected]>
2 parents 6c0da84 + aec42f3 commit b3af9c0

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,16 +3003,15 @@ void bpf_jit_free(struct bpf_prog *prog)
30033003
bool bpf_jit_supports_exceptions(void)
30043004
{
30053005
/* We unwind through both kernel frames (starting from within bpf_throw
3006-
* call) and BPF frames. Therefore we require one of ORC or FP unwinder
3007-
* to be enabled to walk kernel frames and reach BPF frames in the stack
3008-
* trace.
3006+
* call) and BPF frames. Therefore we require ORC unwinder to be enabled
3007+
* to walk kernel frames and reach BPF frames in the stack trace.
30093008
*/
3010-
return IS_ENABLED(CONFIG_UNWINDER_ORC) || IS_ENABLED(CONFIG_UNWINDER_FRAME_POINTER);
3009+
return IS_ENABLED(CONFIG_UNWINDER_ORC);
30113010
}
30123011

30133012
void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie)
30143013
{
3015-
#if defined(CONFIG_UNWINDER_ORC) || defined(CONFIG_UNWINDER_FRAME_POINTER)
3014+
#if defined(CONFIG_UNWINDER_ORC)
30163015
struct unwind_state state;
30173016
unsigned long addr;
30183017

kernel/bpf/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie)
24882488
* deeper stack depths than ctx.sp as we do not return from bpf_throw,
24892489
* which skips compiler generated instrumentation to do the same.
24902490
*/
2491-
kasan_unpoison_task_stack_below((void *)ctx.sp);
2491+
kasan_unpoison_task_stack_below((void *)(long)ctx.sp);
24922492
ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp);
24932493
WARN(1, "A call to BPF exception callback should never return\n");
24942494
}

kernel/bpf/verifier.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15339,14 +15339,12 @@ static int check_btf_func(struct bpf_verifier_env *env,
1533915339
bpfptr_t uattr)
1534015340
{
1534115341
const struct btf_type *type, *func_proto, *ret_type;
15342-
u32 i, nfuncs, urec_size, min_size;
15343-
u32 krec_size = sizeof(struct bpf_func_info);
15342+
u32 i, nfuncs, urec_size;
1534415343
struct bpf_func_info *krecord;
1534515344
struct bpf_func_info_aux *info_aux = NULL;
1534615345
struct bpf_prog *prog;
1534715346
const struct btf *btf;
1534815347
bpfptr_t urecord;
15349-
u32 prev_offset = 0;
1535015348
bool scalar_return;
1535115349
int ret = -ENOMEM;
1535215350

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

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

1537215369
krecord = prog->aux->func_info;
1537315370
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,
1540115398
goto err_free;
1540215399
}
1540315400

15404-
prev_offset = krecord[i].insn_off;
1540515401
bpfptr_add(&urecord, urec_size);
1540615402
}
1540715403

tools/testing/selftests/bpf/prog_tests/exceptions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ static void test_exceptions_success(void)
103103
goto done; \
104104
} \
105105
if (load_ret != 0) { \
106-
printf("%s\n", log_buf); \
107-
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) \
106+
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \
107+
printf("%s\n", log_buf); \
108108
goto done; \
109+
} \
109110
} \
110111
if (!load_ret && attach_err) { \
111112
if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \

0 commit comments

Comments
 (0)