Skip to content

Commit b233920

Browse files
Alexei Starovoitovborkmann
authored andcommitted
bpf: speed up stacksafe check
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>
1 parent eb415c9 commit b233920

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/bpf/verifier.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5204,9 +5204,11 @@ static bool stacksafe(struct bpf_func_state *old,
52045204
for (i = 0; i < old->allocated_stack; i++) {
52055205
spi = i / BPF_REG_SIZE;
52065206

5207-
if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ))
5207+
if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) {
5208+
i += BPF_REG_SIZE - 1;
52085209
/* explored state didn't use this */
52095210
continue;
5211+
}
52105212

52115213
if (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_INVALID)
52125214
continue;

0 commit comments

Comments
 (0)