]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix states equal logic for varlen access
authorJosef Bacik <jbacik@fb.com>
Tue, 29 Nov 2016 17:27:09 +0000 (12:27 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Nov 2016 19:50:52 +0000 (14:50 -0500)
commit80e0e3b626e9634880743c1e3beb7f9400114388
tree44cb85851f4f9aebe00a6405197e4766bed2cf83
parent449c8d585711eefa8dd4812c2fe1cb79b4a56ecb
bpf: fix states equal logic for varlen access

If we have a branch that looks something like this

int foo = map->value;
if (condition) {
  foo += blah;
} else {
  foo = bar;
}
map->array[foo] = baz;

We will incorrectly assume that the !condition branch is equal to the condition
branch as the register for foo will be UNKNOWN_VALUE in both cases.  We need to
adjust this logic to only do this if we didn't do a varlen access after we
processed the !condition branch, otherwise we have different ranges and need to
check the other branch as well.

Fixes: 14f13004796b ("bpf: allow access into map value arrays")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/verifier.c