]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix callees pruning callers
authorAlexei Starovoitov <ast@kernel.org>
Sat, 15 Jun 2019 19:12:21 +0000 (12:12 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 19 Jun 2019 00:22:51 +0000 (02:22 +0200)
commit1437839f741fed7ca8cc341044d46c5f51917ef1
tree0fffe3316643073b9b7c33ef99aa0a3c777969d3
parentf07a3d2cf6637328ed7c806e8ca88e32e5114fc5
bpf: fix callees pruning callers

The commit 358ebc90d756 partially resolved the issue of callees
incorrectly pruning the callers.
With introduction of bounded loops and jmps_processed heuristic
single verifier state may contain multiple branches and calls.
It's possible that new verifier state (for future pruning) will be
allocated inside callee. Then callee will exit (still within the same
verifier state). It will go back to the caller and there R6-R9 registers
will be read and will trigger mark_reg_read. But the reg->live for all frames
but the top frame is not set to LIVE_NONE. Hence mark_reg_read will fail
to propagate liveness into parent and future walking will incorrectly
conclude that the states are equivalent because LIVE_READ is not set.
In other words the rule for parent/live should be:
whenever register parentage chain is set the reg->live should be set to LIVE_NONE.
is_state_visited logic already follows this rule for spilled registers.

Fixes: 358ebc90d756 ("bpf: verifier: make sure callees don't prune with caller differences")
Fixes: 53deca2aeecd ("bpf: introduce function calls (verification)")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/verifier.c