diff options
author | Alexei Starovoitov <ast@fb.com> | 2016-12-07 10:57:59 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-08 13:31:11 -0500 |
commit | d2a4dd37f6b41fbcad76efbf63124eb3126c66fe (patch) | |
tree | bc95a7d565111605886a99832603452c5f9bd8b1 /kernel/bpf | |
parent | 3665f3817cd354ab7a811b3a4f282c4f5cb1a0d0 (diff) | |
download | linux-d2a4dd37f6b41fbcad76efbf63124eb3126c66fe.tar.bz2 |
bpf: fix state equivalence
Commmits 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
and 484611357c19 ("bpf: allow access into map value arrays") by themselves
are correct, but in combination they make state equivalence ignore 'id' field
of the register state which can lead to accepting invalid program.
Fixes: 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
Fixes: 484611357c19 ("bpf: allow access into map value arrays")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf')
-rw-r--r-- | kernel/bpf/verifier.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index da9fb2a9b7eb..5b14f85f45c6 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2528,7 +2528,7 @@ static bool states_equal(struct bpf_verifier_env *env, * we didn't do a variable access into a map then we are a-ok. */ if (!varlen_map_access && - rold->type == rcur->type && rold->imm == rcur->imm) + memcmp(rold, rcur, offsetofend(struct bpf_reg_state, id)) == 0) continue; /* If we didn't map access then again we don't care about the |