1. 22 Apr, 2024 2 commits
  2. 21 Apr, 2024 2 commits
  3. 20 Apr, 2024 7 commits
  4. 18 Apr, 2024 1 commit
  5. 17 Apr, 2024 2 commits
    • Quentin Deslandes's avatar
      libbpf: Fix dump of subsequent char arrays · e739e01d
      Quentin Deslandes authored
      When dumping a character array, libbpf will watch for a '\0' and set
      is_array_terminated=true if found. This prevents libbpf from printing
      the remaining characters of the array, treating it as a nul-terminated
      string.
      
      However, once this flag is set, it's never reset, leading to subsequent
      characters array not being printed properly:
      
      .str_multi = (__u8[2][16])[
          [
              'H',
              'e',
              'l',
          ],
      ],
      
      This patch saves the is_array_terminated flag and restores its
      default (false) value before looping over the elements of an array,
      then restores it afterward. This way, libbpf's behavior is unchanged
      when dumping the characters of an array, but subsequent arrays are
      printed properly:
      
      .str_multi = (__u8[2][16])[
          [
              'H',
              'e',
              'l',
          ],
          [
              'l',
              'o',
          ],
      ],
      Signed-off-by: default avatarQuentin Deslandes <qde@naccy.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240413211258.134421-3-qde@naccy.de
      e739e01d
    • Quentin Deslandes's avatar
      libbpf: Fix misaligned array closing bracket · 9213e529
      Quentin Deslandes authored
      In btf_dump_array_data(), libbpf will call btf_dump_dump_type_data() for
      each element. For an array of characters, each element will be
      processed the following way:
      
      - btf_dump_dump_type_data() is called to print the character
      - btf_dump_data_pfx() prefixes the current line with the proper number
        of indentations
      - btf_dump_int_data() is called to print the character
      - After the last character is printed, btf_dump_dump_type_data() calls
        btf_dump_data_pfx() before writing the closing bracket
      
      However, for an array containing characters, btf_dump_int_data() won't
      print any '\0' and subsequent characters. This leads to situations where
      the line prefix is written, no character is added, then the prefix is
      written again before adding the closing bracket:
      
      (struct sk_metadata){
          .str_array = (__u8[14])[
              'H',
              'e',
              'l',
              'l',
              'o',
                      ],
      
      This change solves this issue by printing the '\0' character, which
      has two benefits:
      
      - The bracket closing the array is properly aligned
      - It's clear from a user point of view that libbpf uses '\0' as a
        terminator for arrays of characters.
      Signed-off-by: default avatarQuentin Deslandes <qde@naccy.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240413211258.134421-2-qde@naccy.de
      9213e529
  6. 16 Apr, 2024 5 commits
  7. 12 Apr, 2024 2 commits
  8. 11 Apr, 2024 11 commits
  9. 09 Apr, 2024 2 commits
  10. 08 Apr, 2024 1 commit
  11. 06 Apr, 2024 4 commits
  12. 05 Apr, 2024 1 commit
    • Andrii Nakryiko's avatar
      Merge branch 'bpf-allow-invoking-kfuncs-from-bpf_prog_type_syscall-progs' · d564ffde
      Andrii Nakryiko authored
      David Vernet says:
      
      ====================
      bpf: Allow invoking kfuncs from BPF_PROG_TYPE_SYSCALL progs
      
      Currently, a set of core BPF kfuncs (e.g. bpf_task_*, bpf_cgroup_*,
      bpf_cpumask_*, etc) cannot be invoked from BPF_PROG_TYPE_SYSCALL
      programs. The whitelist approach taken for enabling kfuncs makes sense:
      it not safe to call these kfuncs from every program type. For example,
      it may not be safe to call bpf_task_acquire() in an fentry to
      free_task().
      
      BPF_PROG_TYPE_SYSCALL, on the other hand, is a perfectly safe program
      type from which to invoke these kfuncs, as it's a very controlled
      environment, and we should never be able to run into any of the typical
      problems such as recursive invoations, acquiring references on freeing
      kptrs, etc. Being able to invoke these kfuncs would be useful, as
      BPF_PROG_TYPE_SYSCALL can be invoked with BPF_PROG_RUN, and would
      therefore enable user space programs to synchronously call into BPF to
      manipulate these kptrs.
      ---
      
      v1: https://lore.kernel.org/all/20240404010308.334604-1-void@manifault.com/
      v1 -> v2:
      
      - Create new verifier_kfunc_prog_types testcase meant to specifically
        validate calling core kfuncs from various program types. Remove the
        macros and testcases that had been added to the task, cgrp, and
        cpumask kfunc testcases (Andrii and Yonghong)
      ====================
      
      Link: https://lore.kernel.org/r/20240405143041.632519-1-void@manifault.comSigned-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      d564ffde