]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: verifier: propagate liveness on all frames
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 21 Mar 2019 21:34:36 +0000 (14:34 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 22 Mar 2019 02:57:02 +0000 (19:57 -0700)
commit06b021374cc21c46cb08abaea6a297f33c1e2465
tree0efb88a71d45a495137c28f26eb94575bf28ff2c
parent16b5d46da7c718a81bf668ad908b6c26d204329d
bpf: verifier: propagate liveness on all frames

Commit 358ebc90d756 ("bpf: verifier: make sure callees don't prune
with caller differences") connected up parentage chains of all
frames of the stack.  It didn't, however, ensure propagate_liveness()
propagates all liveness information along those chains.

This means pruning happening in the callee may generate explored
states with incomplete liveness for the chains in lower frames
of the stack.

The included selftest is similar to the prior one from commit
358ebc90d756 ("bpf: verifier: make sure callees don't prune with
caller differences"), where callee would prune regardless of the
difference in r8 state.

Now we also initialize r9 to 0 or 1 based on a result from get_random().
r9 is never read so the walk with r9 = 0 gets pruned (correctly) after
the walk with r9 = 1 completes.

The selftest is so arranged that the pruning will happen in the
callee.  Since callee does not propagate read marks of r8, the
explored state at the pruning point prior to the callee will
now ignore r8.

Propagate liveness on all frames of the stack when pruning.

Fixes: 53deca2aeecd ("bpf: introduce function calls (verification)")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/verifier/calls.c