19 Sep, 2020

1 commit

  • s390 uses socketcall multiplexer instead of individual socket syscalls.
    Therefore, "kprobe/" SYSCALL(sys_connect) does not trigger and
    test_map_in_map fails. Fix by using "kprobe/__sys_connect" instead.

    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200915115519.3769807-1-iii@linux.ibm.com

    Ilya Leoshkevich
     

08 Jul, 2020

2 commits

  • From commit 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map
    support"), a way to define internal map in BTF-defined map has been
    added.

    Instead of using previous 'inner_map_idx' definition, the structure to
    be used for the inner map can be directly defined using array directive.

    __array(values, struct inner_map)

    This commit refactors map in map test program with libbpf by explicitly
    defining inner map with BTF-defined format.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200707184855.30968-3-danieltimlee@gmail.com

    Daniel T. Lee
     
  • Currently, BPF programs with kprobe/sys_connect does not work properly.

    Commit 34745aed515c ("samples/bpf: fix kprobe attachment issue on x64")
    This commit modifies the bpf_load behavior of kprobe events in the x64
    architecture. If the current kprobe event target starts with "sys_*",
    add the prefix "__x64_" to the front of the event.

    Appending "__x64_" prefix with kprobe/sys_* event was appropriate as a
    solution to most of the problems caused by the commit below.

    commit d5a00528b58c ("syscalls/core, syscalls/x86: Rename struct
    pt_regs-based sys_*() to __x64_sys_*()")

    However, there is a problem with the sys_connect kprobe event that does
    not work properly. For __sys_connect event, parameters can be fetched
    normally, but for __x64_sys_connect, parameters cannot be fetched.

    ffffffff818d3520 :
    ffffffff818d3520: e8 fb df 32 00 callq 0xffffffff81c01520

    ffffffff818d3525: 48 8b 57 60 movq 96(%rdi), %rdx
    ffffffff818d3529: 48 8b 77 68 movq 104(%rdi), %rsi
    ffffffff818d352d: 48 8b 7f 70 movq 112(%rdi), %rdi
    ffffffff818d3531: e8 1a ff ff ff callq 0xffffffff818d3450

    ffffffff818d3536: 48 98 cltq
    ffffffff818d3538: c3 retq
    ffffffff818d3539: 0f 1f 80 00 00 00 00 nopl (%rax)

    As the assembly code for __x64_sys_connect shows, parameters should be
    fetched and set into rdi, rsi, rdx registers prior to calling
    __sys_connect.

    Because of this problem, this commit fixes the sys_connect event by
    first getting the value of the rdi register and then the value of the
    rdi, rsi, and rdx register through an offset based on that value.

    Fixes: 34745aed515c ("samples/bpf: fix kprobe attachment issue on x64")
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200707184855.30968-2-danieltimlee@gmail.com

    Daniel T. Lee
     

21 Jan, 2020

1 commit

  • Fix all files in samples/bpf to include libbpf header files with the bpf/
    prefix, to be consistent with external users of the library. Also ensure
    that all includes of exported libbpf header files (those that are exported
    on 'make install' of the library) use bracketed includes instead of quoted.

    To make sure no new files are introduced that doesn't include the bpf/
    prefix in its include, remove tools/lib/bpf from the include path entirely,
    and use tools/lib instead.

    Fixes: 6910d7d3867a ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157952560911.1683545.8795966751309534150.stgit@toke.dk

    Toke Høiland-Jørgensen
     

03 Nov, 2019

1 commit

  • Use bpf_probe_read_user() helper instead of bpf_probe_read() for samples that
    attach to kprobes probing on user addresses.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/5b0144b3f8e031ec5e2438bd7de8d7877e63bf2f.1572649915.git.daniel@iogearbox.net

    Daniel Borkmann
     

09 Oct, 2019

2 commits

  • Split-off PT_REGS-related helpers into bpf_tracing.h header. Adjust
    selftests and samples to include it where necessary.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Acked-by: Song Liu
    Link: https://lore.kernel.org/bpf/20191008175942.1769476-5-andriin@fb.com

    Andrii Nakryiko
     
  • Split off few legacy things from bpf_helpers.h into separate
    bpf_legacy.h file:
    - load_{byte|half|word};
    - remove extra inner_idx and numa_node fields from bpf_map_def and
    introduce bpf_map_def_legacy for use in samples;
    - move BPF_ANNOTATE_KV_PAIR into bpf_legacy.h.

    Adjust samples and selftests accordingly by either including
    bpf_legacy.h and using bpf_map_def_legacy, or switching to BTF-defined
    maps altogether.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Acked-by: Song Liu
    Link: https://lore.kernel.org/bpf/20191008175942.1769476-3-andriin@fb.com

    Andrii Nakryiko
     

23 Mar, 2017

1 commit