1. 24 8月, 2022 23 次提交
  2. 01 10月, 2020 1 次提交
  3. 29 9月, 2020 2 次提交
  4. 20 8月, 2020 3 次提交
    • A
      libbpf: Fix libbpf build on compilers missing __builtin_mul_overflow · dda1ec9f
      Andrii Nakryiko 提交于
      GCC compilers older than version 5 don't support __builtin_mul_overflow yet.
      Given GCC 4.9 is the minimal supported compiler for building kernel and the
      fact that libbpf is a dependency of resolve_btfids, which is dependency of
      CONFIG_DEBUG_INFO_BTF=y, this needs to be handled. This patch fixes the issue
      by falling back to slower detection of integer overflow in such cases.
      
      Fixes: 029258d7 ("libbpf: Remove any use of reallocarray() in libbpf")
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200820061411.1755905-2-andriin@fb.com
      dda1ec9f
    • A
      libbpf: Implement enum value-based CO-RE relocations · eacaaed7
      Andrii Nakryiko 提交于
      Implement two relocations of a new enumerator value-based CO-RE relocation
      kind: ENUMVAL_EXISTS and ENUMVAL_VALUE.
      
      First, ENUMVAL_EXISTS, allows to detect the presence of a named enumerator
      value in the target (kernel) BTF. This is useful to do BPF helper/map/program
      type support detection from BPF program side. bpf_core_enum_value_exists()
      macro helper is provided to simplify built-in usage.
      
      Second, ENUMVAL_VALUE, allows to capture enumerator integer value and relocate
      it according to the target BTF, if it changes. This is useful to have
      a guarantee against intentional or accidental re-ordering/re-numbering of some
      of the internal (non-UAPI) enumerations, where kernel developers don't care
      about UAPI backwards compatiblity concerns. bpf_core_enum_value() allows to
      capture this succinctly and use correct enum values in code.
      
      LLVM uses ldimm64 instruction to capture enumerator value-based relocations,
      so add support for ldimm64 instruction patching as well.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200819194519.3375898-5-andriin@fb.com
      eacaaed7
    • A
      libbpf: Implement type-based CO-RE relocations support · 3fc32f40
      Andrii Nakryiko 提交于
      Implement support for TYPE_EXISTS/TYPE_SIZE/TYPE_ID_LOCAL/TYPE_ID_REMOTE
      relocations. These are examples of type-based relocations, as opposed to
      field-based relocations supported already. The difference is that they are
      calculating relocation values based on the type itself, not a field within
      a struct/union.
      
      Type-based relos have slightly different semantics when matching local types
      to kernel target types, see comments in bpf_core_types_are_compat() for
      details. Their behavior on failure to find target type in kernel BTF also
      differs. Instead of "poisoning" relocatable instruction and failing load
      subsequently in kernel, they return 0 (which is rarely a valid return result,
      so user BPF code can use that to detect success/failure of the relocation and
      deal with it without extra "guarding" relocations). Also, it's always possible
      to check existence of the type in target kernel with TYPE_EXISTS relocation,
      similarly to a field-based FIELD_EXISTS.
      
      TYPE_ID_LOCAL relocation is a bit special in that it always succeeds (barring
      any libbpf/Clang bugs) and resolved to BTF ID using **local** BTF info of BPF
      program itself. Tests in subsequent patches demonstrate the usage and
      semantics of new relocations.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200819194519.3375898-2-andriin@fb.com
      3fc32f40
  5. 19 8月, 2020 4 次提交
  6. 11 5月, 2020 1 次提交
    • G
      bpf, libbpf: Replace zero-length array with flexible-array · 385bbf7b
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200507185057.GA13981@embeddedor
      385bbf7b
  7. 19 12月, 2019 1 次提交
  8. 16 12月, 2019 1 次提交
  9. 14 12月, 2019 1 次提交
  10. 04 11月, 2019 1 次提交
  11. 21 10月, 2019 1 次提交
  12. 16 10月, 2019 1 次提交