Skip to content

Commit 1fe7bcb

Browse files
committed
simulate tail call in verifier
1 parent 8a2f98f commit 1fe7bcb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

kernel/bpf/verifier.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11399,8 +11399,10 @@ static inline bool in_sleepable_context(struct bpf_verifier_env *env)
1139911399
in_sleepable(env);
1140011400
}
1140111401

11402-
static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
11403-
int *insn_idx_p)
11402+
static int check_helper_call(struct bpf_verifier_env *env,
11403+
struct bpf_insn *insn,
11404+
int *insn_idx_p,
11405+
bool *do_print_state)
1140411406
{
1140511407
enum bpf_prog_type prog_type = resolve_prog_type(env->prog);
1140611408
bool returns_cpu_specific_alloc_ptr = false;
@@ -11911,6 +11913,15 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
1191111913
env->prog->call_get_func_ip = true;
1191211914
}
1191311915

11916+
if (func_id == BPF_FUNC_tail_call) {
11917+
struct bpf_verifier_state *branch;
11918+
branch = push_stack(env, idx + 1, idx, false);
11919+
if (IS_ERR(branch))
11920+
return PTR_ERR(branch);
11921+
clear_all_pkt_pointers(env);
11922+
return process_bpf_exit_full(env, do_print_state, false);
11923+
}
11924+
1191411925
if (changes_data)
1191511926
clear_all_pkt_pointers(env);
1191611927
return 0;
@@ -19957,7 +19968,7 @@ static int do_check_insn(struct bpf_verifier_env *env, bool *do_print_state)
1995719968
if (!err && is_bpf_throw_kfunc(insn))
1995819969
return process_bpf_exit_full(env, do_print_state, true);
1995919970
} else {
19960-
err = check_helper_call(env, insn, &env->insn_idx);
19971+
err = check_helper_call(env, insn, &env->insn_idx, do_print_state);
1996119972
}
1996219973
if (err)
1996319974
return err;

0 commit comments

Comments
 (0)