mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 14:19:09 -04:00
UPSTREAM: bpf: Fix error path under memory pressure
Restore the 'if (env->cur_state)' check that was incorrectly removed during
code move. Under memory pressure env->cur_state can be freed and zeroed inside
do_check(). Hence the check is necessary.
Fixes: 51c39bb1d5d1 ("bpf: Introduce function-by-function verification")
Reported-by: syzbot+b296579ba5015704d9fa@syzkaller.appspotmail.com
Change-Id: I3e183c6fe8f103b887137a3001da57d617b8942d
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200122024138.3385590-1-ast@kernel.org
This commit is contained in:
parent
8916a903bd
commit
e6b0d7434f
1 changed files with 7 additions and 2 deletions
|
|
@ -9874,8 +9874,13 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
|
|||
|
||||
ret = do_check(env);
|
||||
out:
|
||||
free_verifier_state(env->cur_state, true);
|
||||
env->cur_state = NULL;
|
||||
/* check for NULL is necessary, since cur_state can be freed inside
|
||||
* do_check() under memory pressure.
|
||||
*/
|
||||
if (env->cur_state) {
|
||||
free_verifier_state(env->cur_state, true);
|
||||
env->cur_state = NULL;
|
||||
}
|
||||
while (!pop_stack(env, NULL, NULL));
|
||||
free_states(env);
|
||||
if (ret)
|
||||
|
|
|
|||
Loading…
Reference in a new issue