bpf: fix max call depth check

fix off by one error in max call depth check
and add a test

Fixes: f4d7e40a5b ("bpf: introduce function calls (verification)")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
Alexei Starovoitov
2017-12-25 13:15:42 -08:00
committed by Daniel Borkmann
parent 6b86c4217c
commit aada9ce644
2 changed files with 37 additions and 2 deletions

View File

@ -2126,9 +2126,9 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
struct bpf_func_state *caller, *callee;
int i, subprog, target_insn;
if (state->curframe >= MAX_CALL_FRAMES) {
if (state->curframe + 1 >= MAX_CALL_FRAMES) {
verbose(env, "the call stack of %d frames is too deep\n",
state->curframe);
state->curframe + 2);
return -E2BIG;
}