bpf: don't check spilled reg state for non-STACK_SPILLed type slots
authorDaniel Borkmann <daniel@iogearbox.net>
Sat, 10 Jun 2017 22:50:41 +0000 (00:50 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Jun 2017 23:05:45 +0000 (19:05 -0400)
spilled_regs[] state is only used for stack slots of type STACK_SPILL,
never for STACK_MISC. Right now, in states_equal(), even if we have
old and current stack state of type STACK_MISC, we compare spilled_regs[]
for that particular offset. Just skip these like we do everywhere else.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/verifier.c

index 14ccb0759fa4daa57217fb334f43216feacd3f7b..d031b3b0752ea00e8e8d93106b68ab5226b0a65e 100644 (file)
@@ -2828,6 +2828,8 @@ static bool states_equal(struct bpf_verifier_env *env,
                        return false;
                if (i % BPF_REG_SIZE)
                        continue;
+               if (old->stack_slot_type[i] != STACK_SPILL)
+                       continue;
                if (memcmp(&old->spilled_regs[i / BPF_REG_SIZE],
                           &cur->spilled_regs[i / BPF_REG_SIZE],
                           sizeof(old->spilled_regs[0])))