1. 25 Aug, 2023 1 commit
    • Dave Marchevsky's avatar
      bpf: Ensure kptr_struct_meta is non-NULL for collection insert and refcount_acquire · f0d991a0
      Dave Marchevsky authored
      It's straightforward to prove that kptr_struct_meta must be non-NULL for
      any valid call to these kfuncs:
      
        * btf_parse_struct_metas in btf.c creates a btf_struct_meta for any
          struct in user BTF with a special field (e.g. bpf_refcount,
          {rb,list}_node). These are stored in that BTF's struct_meta_tab.
      
        * __process_kf_arg_ptr_to_graph_node in verifier.c ensures that nodes
          have {rb,list}_node field and that it's at the correct offset.
          Similarly, check_kfunc_args ensures bpf_refcount field existence for
          node param to bpf_refcount_acquire.
      
        * So a btf_struct_meta must have been created for the struct type of
          node param to these kfuncs
      
        * That BTF and its struct_meta_tab are guaranteed to still be around.
          Any arbitrary {rb,list} node the BPF program interacts with either:
          came from bpf_obj_new or a collection removal kfunc in the same
          program, in which case the BTF is associated with the program and
          still around; or came from bpf_kptr_xchg, in which case the BTF was
          associated with the map and is still around
      
      Instead of silently continuing with NULL struct_meta, which caused
      confusing bugs such as those addressed by commit 2140a6e3 ("bpf: Set
      kptr_struct_meta for node param to list and rbtree insert funcs"), let's
      error out. Then, at runtime, we can confidently say that the
      implementations of these kfuncs were given a non-NULL kptr_struct_meta,
      meaning that special-field-specific functionality like
      bpf_obj_free_fields and the bpf_obj_drop change introduced later in this
      series are guaranteed to execute.
      
      This patch doesn't change functionality, just makes it easier to reason
      about existing functionality.
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Link: https://lore.kernel.org/r/20230821193311.3290257-2-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f0d991a0
  2. 24 Aug, 2023 21 commits
  3. 23 Aug, 2023 3 commits
  4. 22 Aug, 2023 6 commits
  5. 21 Aug, 2023 9 commits