From: Alexei Starovoitov Date: Thu, 13 Dec 2018 19:42:31 +0000 (-0800) Subject: bpf: speed up stacksafe check X-Git-Tag: v5.4-rc1~1957^2~15^2~17^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b233920c97a6201eb47fbafd78365c6946e6d7b6;p=platform%2Fkernel%2Flinux-rpi.git bpf: speed up stacksafe check Don't check the same stack liveness condition 8 times. once is enough. Signed-off-by: Alexei Starovoitov Acked-by: Edward Cree Acked-by: Jakub Kicinski Signed-off-by: Daniel Borkmann --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ba8e313..0c6deb3 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -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;