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


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
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -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;

+1 −1
Original line number Diff line number Diff line
@@ -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");
}
+1 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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);
	}
+3 −2
Original line number Diff line number Diff line
@@ -103,10 +103,11 @@ static void test_exceptions_success(void)
			goto done;						  \
		}								  \
		if (load_ret != 0) {						  \
			if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) {	  \
				printf("%s\n", log_buf);			  \
			if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr"))	  \
				goto done;					  \
			}							  \
		}								  \
		if (!load_ret && attach_err) {					  \
			if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \
				goto done;					  \