Skip to content

Commit

Permalink
bpf: Do per-instruction state dumping in verifier when log_level > 1.
Browse files Browse the repository at this point in the history
If log_level > 1, do a state dump every instruction and emit it in
a more compact way (without a leading newline).

This will facilitate more sophisticated test cases which inspect the
verifier log for register state.

Signed-off-by: David S. Miller <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
  • Loading branch information
davem330 committed May 11, 2017
1 parent d117441 commit c5fc969
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -2926,8 +2926,12 @@ static int do_check(struct bpf_verifier_env *env)
goto process_bpf_exit;
}

if (log_level && do_print_state) {
verbose("\nfrom %d to %d:", prev_insn_idx, insn_idx);
if (log_level > 1 || (log_level && do_print_state)) {
if (log_level > 1)
verbose("%d:", insn_idx);
else
verbose("\nfrom %d to %d:",
prev_insn_idx, insn_idx);
print_verifier_state(&env->cur_state);
do_print_state = false;
}
Expand Down

0 comments on commit c5fc969

Please sign in to comment.