1. 19 12月, 2021 1 次提交
    • H
      bpf: Introduce composable reg, ret and arg types. · d639b9d1
      Hao Luo 提交于
      There are some common properties shared between bpf reg, ret and arg
      values. For instance, a value may be a NULL pointer, or a pointer to
      a read-only memory. Previously, to express these properties, enumeration
      was used. For example, in order to test whether a reg value can be NULL,
      reg_type_may_be_null() simply enumerates all types that are possibly
      NULL. The problem of this approach is that it's not scalable and causes
      a lot of duplication. These properties can be combined, for example, a
      type could be either MAYBE_NULL or RDONLY, or both.
      
      This patch series rewrites the layout of reg_type, arg_type and
      ret_type, so that common properties can be extracted and represented as
      composable flag. For example, one can write
      
       ARG_PTR_TO_MEM | PTR_MAYBE_NULL
      
      which is equivalent to the previous
      
       ARG_PTR_TO_MEM_OR_NULL
      
      The type ARG_PTR_TO_MEM are called "base type" in this patch. Base
      types can be extended with flags. A flag occupies the higher bits while
      base types sits in the lower bits.
      
      This patch in particular sets up a set of macro for this purpose. The
      following patches will rewrite arg_types, ret_types and reg_types
      respectively.
      Signed-off-by: NHao Luo <haoluo@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211217003152.48334-2-haoluo@google.com
      d639b9d1
  2. 18 12月, 2021 3 次提交
  3. 17 12月, 2021 14 次提交
  4. 15 12月, 2021 8 次提交
  5. 14 12月, 2021 13 次提交
  6. 13 12月, 2021 1 次提交
    • A
      libbpf: Don't validate TYPE_ID relo's original imm value · 4b443bc1
      Andrii Nakryiko 提交于
      During linking, type IDs in the resulting linked BPF object file can
      change, and so ldimm64 instructions corresponding to
      BPF_CORE_TYPE_ID_TARGET and BPF_CORE_TYPE_ID_LOCAL CO-RE relos can get
      their imm value out of sync with actual CO-RE relocation information
      that's updated by BPF linker properly during linking process.
      
      We could teach BPF linker to adjust such instructions, but it feels
      a bit too much for linker to re-implement good chunk of
      bpf_core_patch_insns logic just for this. This is a redundant safety
      check for TYPE_ID relocations, as the real validation is in matching
      CO-RE specs, so if that works fine, it's very unlikely that there is
      something wrong with the instruction itself.
      
      So, instead, teach libbpf (and kernel) to ignore insn->imm for
      BPF_CORE_TYPE_ID_TARGET and BPF_CORE_TYPE_ID_LOCAL relos.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20211213010706.100231-1-andrii@kernel.org
      4b443bc1