• Andrii Nakryiko's avatar
    selftests/bpf: add precision propagation tests in the presence of subprogs · 3ef3d217
    Andrii Nakryiko authored
    Add a bunch of tests validating verifier's precision backpropagation
    logic in the presence of subprog calls and/or callback-calling
    helpers/kfuncs.
    
    We validate the following conditions:
      - subprog_result_precise: static subprog r0 result precision handling;
      - global_subprog_result_precise: global subprog r0 precision
        shortcutting, similar to BPF helper handling;
      - callback_result_precise: similarly r0 marking precise for
        callback-calling helpers;
      - parent_callee_saved_reg_precise, parent_callee_saved_reg_precise_global:
        propagation of precision for callee-saved registers bypassing
        static/global subprogs;
      - parent_callee_saved_reg_precise_with_callback: same as above, but in
        the presence of callback-calling helper;
      - parent_stack_slot_precise, parent_stack_slot_precise_global:
        similar to above, but instead propagating precision of stack slot
        (spilled SCALAR reg);
      - parent_stack_slot_precise_with_callback: same as above, but in the
        presence of callback-calling helper;
      - subprog_arg_precise: propagation of precision of static subprog's
        input argument back to caller;
      - subprog_spill_into_parent_stack_slot_precise: negative test
        validating that verifier currently can't support backtracking of stack
        access with non-r10 register, we validate that we fallback to
        forcing precision for all SCALARs.
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20230505043317.3629845-10-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    3ef3d217
verifier_subprog_precision.c 15.7 KB