Skip to content

Commit

Permalink
bpf: speed up stacksafe check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexei Starovoitov authored and Daniel Borkmann committed Dec 15, 2018
1 parent eb415c9 commit b233920
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b233920

Please sign in to comment.