]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
bpf: Do per-instruction state dumping in verifier when log_level > 1.
authorDavid S. Miller <davem@davemloft.net>
Wed, 10 May 2017 18:25:17 +0000 (11:25 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 May 2017 18:19:00 +0000 (14:19 -0400)
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 <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/verifier.c

index cc7b626fa44768e00fd5c8a920c815140731807f..ff2bfe1d656a67c9cb235cd9e2264a508789f82c 100644 (file)
@@ -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;
                }