1. 21 Sep, 2022 7 commits
  2. 20 Sep, 2022 5 commits
  3. 19 Sep, 2022 1 commit
  4. 17 Sep, 2022 1 commit
  5. 16 Sep, 2022 8 commits
  6. 15 Sep, 2022 1 commit
    • Dave Marchevsky's avatar
      bpf: Add verifier check for BPF_PTR_POISON retval and arg · 47e34cb7
      Dave Marchevsky authored
      BPF_PTR_POISON was added in commit c0a5a21c ("bpf: Allow storing
      referenced kptr in map") to denote a bpf_func_proto btf_id which the
      verifier will replace with a dynamically-determined btf_id at verification
      time.
      
      This patch adds verifier 'poison' functionality to BPF_PTR_POISON in
      order to prepare for expanded use of the value to poison ret- and
      arg-btf_id in ongoing work, namely rbtree and linked list patchsets
      [0, 1]. Specifically, when the verifier checks helper calls, it assumes
      that BPF_PTR_POISON'ed ret type will be replaced with a valid type before
      - or in lieu of - the default ret_btf_id logic. Similarly for arg btf_id.
      
      If poisoned btf_id reaches default handling block for either, consider
      this a verifier internal error and fail verification. Otherwise a helper
      w/ poisoned btf_id but no verifier logic replacing the type will cause a
      crash as the invalid pointer is dereferenced.
      
      Also move BPF_PTR_POISON to existing include/linux/posion.h header and
      remove unnecessary shift.
      
        [0]: lore.kernel.org/bpf/20220830172759.4069786-1-davemarchevsky@fb.com
        [1]: lore.kernel.org/bpf/20220904204145.3089-1-memxor@gmail.com
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Acked-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Link: https://lore.kernel.org/r/20220912154544.1398199-1-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      47e34cb7
  7. 11 Sep, 2022 9 commits
  8. 10 Sep, 2022 2 commits
  9. 09 Sep, 2022 5 commits
  10. 07 Sep, 2022 1 commit
    • Kumar Kartikeya Dwivedi's avatar
      bpf: Add helper macro bpf_for_each_reg_in_vstate · b239da34
      Kumar Kartikeya Dwivedi authored
      For a lot of use cases in future patches, we will want to modify the
      state of registers part of some same 'group' (e.g. same ref_obj_id). It
      won't just be limited to releasing reference state, but setting a type
      flag dynamically based on certain actions, etc.
      
      Hence, we need a way to easily pass a callback to the function that
      iterates over all registers in current bpf_verifier_state in all frames
      upto (and including) the curframe.
      
      While in C++ we would be able to easily use a lambda to pass state and
      the callback together, sadly we aren't using C++ in the kernel. The next
      best thing to avoid defining a function for each case seems like
      statement expressions in GNU C. The kernel already uses them heavily,
      hence they can passed to the macro in the style of a lambda. The
      statement expression will then be substituted in the for loop bodies.
      
      Variables __state and __reg are set to current bpf_func_state and reg
      for each invocation of the expression inside the passed in verifier
      state.
      
      Then, convert mark_ptr_or_null_regs, clear_all_pkt_pointers,
      release_reference, find_good_pkt_pointers, find_equal_scalars to
      use bpf_for_each_reg_in_vstate.
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Link: https://lore.kernel.org/r/20220904204145.3089-16-memxor@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b239da34