bpf: speed up stacksafe check
authorAlexei Starovoitov <ast@kernel.org>
Thu, 13 Dec 2018 19:42:31 +0000 (11:42 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 15 Dec 2018 00:28:32 +0000 (01:28 +0100)
Don't check the same stack liveness condition 8 times.
once is enough.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Edward Cree <ecree@solarflare.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/verifier.c

index ba8e313..0c6deb3 100644 (file)
@@ -5204,9 +5204,11 @@ static bool stacksafe(struct bpf_func_state *old,
        for (i = 0; i < old->allocated_stack; i++) {
                spi = i / BPF_REG_SIZE;
 
-               if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ))
+               if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) {
+                       i += BPF_REG_SIZE - 1;
                        /* explored state didn't use this */
                        continue;
+               }
 
                if (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_INVALID)
                        continue;