diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 63749ad5ac6b..a9e23b6b8e8f 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -21285,6 +21285,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3 if (ret == 0) ret = do_misc_fixups(env); + /* max stack depth verification must be done after rewrites as well */ + if (ret == 0) + ret = check_max_stack_depth(env); + /* do 32-bit optimization after insn patching has done so those patched * insns could be handled correctly. */