]> git.baikalelectronics.ru Git - kernel.git/commit
bpf/verifier: fix verifier instability
authorAlexei Starovoitov <ast@kernel.org>
Wed, 5 Sep 2018 02:13:44 +0000 (19:13 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 6 Sep 2018 05:21:00 +0000 (22:21 -0700)
commite29c007c0c2bad51475a02dd0cf4bc863e2a9fe4
treef95baffc3d052a68d5ff23e2f1145ff1f6fefc9f
parent12557378b2f394df6234fccbbe54837e377b72a1
bpf/verifier: fix verifier instability

Edward Cree says:
In check_mem_access(), for the PTR_TO_CTX case, after check_ctx_access()
has supplied a reg_type, the other members of the register state are set
appropriately.  Previously reg.range was set to 0, but as it is in a
union with reg.map_ptr, which is larger, upper bytes of the latter were
left in place.  This then caused the memcmp() in regsafe() to fail,
preventing some branches from being pruned (and occasionally causing the
same program to take a varying number of processed insns on repeated
verifier runs).

Fix the instability by clearing bpf_reg_state in __mark_reg_[un]known()

Fixes: d4b79d1043b4 ("bpf/verifier: rework value tracking")
Debugged-by: Edward Cree <ecree@solarflare.com>
Acked-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c