• Andrii Nakryiko's avatar
    bpf: propagate precision across all frames, not just the last one · 529409ea
    Andrii Nakryiko authored
    When equivalent completed state is found and it has additional precision
    restrictions, BPF verifier propagates precision to
    currently-being-verified state chain (i.e., including parent states) so
    that if some of the states in the chain are not yet completed, necessary
    precision restrictions are enforced.
    
    Unfortunately, right now this happens only for the last frame (deepest
    active subprogram's frame), not all the frames. This can lead to
    incorrect matching of states due to missing precision marker. Currently
    this doesn't seem possible as BPF verifier forces everything to precise
    when validated BPF program has any subprograms. But with the next patch
    lifting this restriction, this becomes problematic.
    
    In fact, without this fix, we'll start getting failure in one of the
    existing test_verifier test cases:
    
      #906/p precise: cross frame pruning FAIL
      Unexpected success to load!
      verification time 48 usec
      stack depth 0+0
      processed 26 insns (limit 1000000) max_states_per_insn 3 total_states 17 peak_states 17 mark_read 8
    
    This patch adds precision propagation across all frames.
    
    Fixes: a3ce685d ("bpf: fix precision tracking")
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20221104163649.121784-3-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    529409ea
verifier.c 438 KB