Skip to content

Commit 80a58d0

Browse files
4astdavem330
authored andcommitted
bpf: reconcile bpf_tail_call and stack_depth
The next set of patches will take advantage of stack_depth tracking, so make sure that the program that does bpf_tail_call() has stack depth large enough for the callee. We could have tracked the stack depth of the prog_array owner program and only allow insertion of the programs with stack depth less than the owner, but it will break existing applications. Some of them have trivial root bpf program that only does multiple bpf_tail_calls and at init time the prog array is empty. In the future we may add a flag to do such tracking optionally, but for now play simple and safe. Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8726679 commit 80a58d0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
34703470
* the program array.
34713471
*/
34723472
prog->cb_access = 1;
3473+
env->prog->aux->stack_depth = MAX_BPF_STACK;
34733474

34743475
/* mark bpf_tail_call as different opcode to avoid
34753476
* conditional branch in the interpeter for every normal

0 commit comments

Comments
 (0)