Skip to content

Commit

Permalink
bpf: verifier: reorder stack size check with dead code sanitization
Browse files Browse the repository at this point in the history
Reorder the calls to check_max_stack_depth() and sanitize_dead_code()
to separate functions which can rewrite instructions from pure checks.

No functional changes.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Jakub Kicinski authored and Daniel Borkmann committed Dec 20, 2018
1 parent 14507e3 commit 9b38c40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -6983,10 +6983,11 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr,
free_states(env);

if (ret == 0)
sanitize_dead_code(env);
ret = check_max_stack_depth(env);

/* instruction rewrites happen after this point */
if (ret == 0)
ret = check_max_stack_depth(env);
sanitize_dead_code(env);

if (ret == 0)
/* program is valid, convert *(u32*)(ctx + off) accesses */
Expand Down

0 comments on commit 9b38c40

Please sign in to comment.