1. 20 7月, 2022 4 次提交
    • A
      libbpf: add ksyscall/kretsyscall sections support for syscall kprobes · 708ac5be
      Andrii Nakryiko 提交于
      Add SEC("ksyscall")/SEC("ksyscall/<syscall_name>") and corresponding
      kretsyscall variants (for return kprobes) to allow users to kprobe
      syscall functions in kernel. These special sections allow to ignore
      complexities and differences between kernel versions and host
      architectures when it comes to syscall wrapper and corresponding
      __<arch>_sys_<syscall> vs __se_sys_<syscall> differences, depending on
      whether host kernel has CONFIG_ARCH_HAS_SYSCALL_WRAPPER (though libbpf
      itself doesn't rely on /proc/config.gz for detecting this, see
      BPF_KSYSCALL patch for how it's done internally).
      
      Combined with the use of BPF_KSYSCALL() macro, this allows to just
      specify intended syscall name and expected input arguments and leave
      dealing with all the variations to libbpf.
      
      In addition to SEC("ksyscall+") and SEC("kretsyscall+") add
      bpf_program__attach_ksyscall() API which allows to specify syscall name
      at runtime and provide associated BPF cookie value.
      
      At the moment SEC("ksyscall") and bpf_program__attach_ksyscall() do not
      handle all the calling convention quirks for mmap(), clone() and compat
      syscalls. It also only attaches to "native" syscall interfaces. If host
      system supports compat syscalls or defines 32-bit syscalls in 64-bit
      kernel, such syscall interfaces won't be attached to by libbpf.
      
      These limitations may or may not change in the future. Therefore it is
      recommended to use SEC("kprobe") for these syscalls or if working with
      compat and 32-bit interfaces is required.
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220714070755.3235561-5-andrii@kernel.orgSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      708ac5be
    • A
      libbpf: improve BPF_KPROBE_SYSCALL macro and rename it to BPF_KSYSCALL · 6f5d467d
      Andrii Nakryiko 提交于
      Improve BPF_KPROBE_SYSCALL (and rename it to shorter BPF_KSYSCALL to
      match libbpf's SEC("ksyscall") section name, added in next patch) to use
      __kconfig variable to determine how to properly fetch syscall arguments.
      
      Instead of relying on hard-coded knowledge of whether kernel's
      architecture uses syscall wrapper or not (which only reflects the latest
      kernel versions, but is not necessarily true for older kernels and won't
      necessarily hold for later kernel versions on some particular host
      architecture), determine this at runtime by attempting to create
      perf_event (with fallback to kprobe event creation through tracefs on
      legacy kernels, just like kprobe attachment code is doing) for kernel
      function that would correspond to bpf() syscall on a system that has
      CONFIG_ARCH_HAS_SYSCALL_WRAPPER set (e.g., for x86-64 it would try
      '__x64_sys_bpf').
      
      If host kernel uses syscall wrapper, syscall kernel function's first
      argument is a pointer to struct pt_regs that then contains syscall
      arguments. In such case we need to use bpf_probe_read_kernel() to fetch
      actual arguments (which we do through BPF_CORE_READ() macro) from inner
      pt_regs.
      
      But if the kernel doesn't use syscall wrapper approach, input
      arguments can be read from struct pt_regs directly with no probe reading.
      
      All this feature detection is done without requiring /proc/config.gz
      existence and parsing, and BPF-side helper code uses newly added
      LINUX_HAS_SYSCALL_WRAPPER virtual __kconfig extern to keep in sync with
      user-side feature detection of libbpf.
      
      BPF_KSYSCALL() macro can be used both with SEC("kprobe") programs that
      define syscall function explicitly (e.g., SEC("kprobe/__x64_sys_bpf"))
      and SEC("ksyscall") program added in the next patch (which are the same
      kprobe program with added benefit of libbpf determining correct kernel
      function name automatically).
      
      Kretprobe and kretsyscall (added in next patch) programs don't need
      BPF_KSYSCALL as they don't provide access to input arguments. Normal
      BPF_KRETPROBE is completely sufficient and is recommended.
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220714070755.3235561-4-andrii@kernel.orgSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      6f5d467d
    • A
      selftests/bpf: add test of __weak unknown virtual __kconfig extern · ce6dc74a
      Andrii Nakryiko 提交于
      Exercise libbpf's logic for unknown __weak virtual __kconfig externs.
      USDT selftests are already excercising non-weak known virtual extern
      already (LINUX_HAS_BPF_COOKIE), so no need to add explicit tests for it.
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220714070755.3235561-3-andrii@kernel.orgSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      ce6dc74a
    • A
      libbpf: generalize virtual __kconfig externs and use it for USDT · 55d00c37
      Andrii Nakryiko 提交于
      Libbpf supports single virtual __kconfig extern currently: LINUX_KERNEL_VERSION.
      LINUX_KERNEL_VERSION isn't coming from /proc/kconfig.gz and is intead
      customly filled out by libbpf.
      
      This patch generalizes this approach to support more such virtual
      __kconfig externs. One such extern added in this patch is
      LINUX_HAS_BPF_COOKIE which is used for BPF-side USDT supporting code in
      usdt.bpf.h instead of using CO-RE-based enum detection approach for
      detecting bpf_get_attach_cookie() BPF helper. This allows to remove
      otherwise not needed CO-RE dependency and keeps user-space and BPF-side
      parts of libbpf's USDT support strictly in sync in terms of their
      feature detection.
      
      We'll use similar approach for syscall wrapper detection for
      BPF_KSYSCALL() BPF-side macro in follow up patch.
      
      Generally, currently libbpf reserves CONFIG_ prefix for Kconfig values
      and LINUX_ for virtual libbpf-backed externs. In the future we might
      extend the set of prefixes that are supported. This can be done without
      any breaking changes, as currently any __kconfig extern with
      unrecognized name is rejected.
      
      For LINUX_xxx externs we support the normal "weak rule": if libbpf
      doesn't recognize given LINUX_xxx extern but such extern is marked as
      __weak, it is not rejected and defaults to zero.  This follows
      CONFIG_xxx handling logic and will allow BPF applications to
      opportunistically use newer libbpf virtual externs without breaking on
      older libbpf versions unnecessarily.
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Reviewed-by: NAlan Maguire <alan.maguire@oracle.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/r/20220714070755.3235561-2-andrii@kernel.orgSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      55d00c37
  2. 16 7月, 2022 6 次提交
  3. 15 7月, 2022 5 次提交
  4. 14 7月, 2022 6 次提交
  5. 13 7月, 2022 6 次提交
  6. 12 7月, 2022 7 次提交
  7. 11 7月, 2022 3 次提交
    • J
      fddi/skfp: fix repeated words in comments · edb2c347
      Jilin Yuan 提交于
      Delete the redundant word 'test'.
      Signed-off-by: NJilin Yuan <yuanjilin@cdjrlc.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      edb2c347
    • J
      ethernet/via: fix repeated words in comments · 1377a5b2
      Jilin Yuan 提交于
      Delete the redundant word 'driver'.
      Signed-off-by: NJilin Yuan <yuanjilin@cdjrlc.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1377a5b2
    • S
      net: Find dst with sk's xfrm policy not ctl_sk · e22aa148
      sewookseo 提交于
      If we set XFRM security policy by calling setsockopt with option
      IPV6_XFRM_POLICY, the policy will be stored in 'sock_policy' in 'sock'
      struct. However tcp_v6_send_response doesn't look up dst_entry with the
      actual socket but looks up with tcp control socket. This may cause a
      problem that a RST packet is sent without ESP encryption & peer's TCP
      socket can't receive it.
      This patch will make the function look up dest_entry with actual socket,
      if the socket has XFRM policy(sock_policy), so that the TCP response
      packet via this function can be encrypted, & aligned on the encrypted
      TCP socket.
      
      Tested: We encountered this problem when a TCP socket which is encrypted
      in ESP transport mode encryption, receives challenge ACK at SYN_SENT
      state. After receiving challenge ACK, TCP needs to send RST to
      establish the socket at next SYN try. But the RST was not encrypted &
      peer TCP socket still remains on ESTABLISHED state.
      So we verified this with test step as below.
      [Test step]
      1. Making a TCP state mismatch between client(IDLE) & server(ESTABLISHED).
      2. Client tries a new connection on the same TCP ports(src & dst).
      3. Server will return challenge ACK instead of SYN,ACK.
      4. Client will send RST to server to clear the SOCKET.
      5. Client will retransmit SYN to server on the same TCP ports.
      [Expected result]
      The TCP connection should be established.
      
      Cc: Maciej Żenczykowski <maze@google.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Sehee Lee <seheele@google.com>
      Signed-off-by: NSewook Seo <sewookseo@google.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e22aa148
  8. 10 7月, 2022 1 次提交
    • J
      Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · 0076cad3
      Jakub Kicinski 提交于
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf-next 2022-07-09
      
      We've added 94 non-merge commits during the last 19 day(s) which contain
      a total of 125 files changed, 5141 insertions(+), 6701 deletions(-).
      
      The main changes are:
      
      1) Add new way for performing BTF type queries to BPF, from Daniel Müller.
      
      2) Add inlining of calls to bpf_loop() helper when its function callback is
         statically known, from Eduard Zingerman.
      
      3) Implement BPF TCP CC framework usability improvements, from Jörn-Thorben Hinz.
      
      4) Add LSM flavor for attaching per-cgroup BPF programs to existing LSM
         hooks, from Stanislav Fomichev.
      
      5) Remove all deprecated libbpf APIs in prep for 1.0 release, from Andrii Nakryiko.
      
      6) Add benchmarks around local_storage to BPF selftests, from Dave Marchevsky.
      
      7) AF_XDP sample removal (given move to libxdp) and various improvements around AF_XDP
         selftests, from Magnus Karlsson & Maciej Fijalkowski.
      
      8) Add bpftool improvements for memcg probing and bash completion, from Quentin Monnet.
      
      9) Add arm64 JIT support for BPF-2-BPF coupled with tail calls, from Jakub Sitnicki.
      
      10) Sockmap optimizations around throughput of UDP transmissions which have been
          improved by 61%, from Cong Wang.
      
      11) Rework perf's BPF prologue code to remove deprecated functions, from Jiri Olsa.
      
      12) Fix sockmap teardown path to avoid sleepable sk_psock_stop, from John Fastabend.
      
      13) Fix libbpf's cleanup around legacy kprobe/uprobe on error case, from Chuang Wang.
      
      14) Fix libbpf's bpf_helpers.h to work with gcc for the case of its sec/pragma
          macro, from James Hilliard.
      
      15) Fix libbpf's pt_regs macros for riscv to use a0 for RC register, from Yixun Lan.
      
      16) Fix bpftool to show the name of type BPF_OBJ_LINK, from Yafang Shao.
      
      * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (94 commits)
        selftests/bpf: Fix xdp_synproxy build failure if CONFIG_NF_CONNTRACK=m/n
        bpf: Correctly propagate errors up from bpf_core_composites_match
        libbpf: Disable SEC pragma macro on GCC
        bpf: Check attach_func_proto more carefully in check_return_code
        selftests/bpf: Add test involving restrict type qualifier
        bpftool: Add support for KIND_RESTRICT to gen min_core_btf command
        MAINTAINERS: Add entry for AF_XDP selftests files
        selftests, xsk: Rename AF_XDP testing app
        bpf, docs: Remove deprecated xsk libbpf APIs description
        selftests/bpf: Add benchmark for local_storage RCU Tasks Trace usage
        libbpf, riscv: Use a0 for RC register
        libbpf: Remove unnecessary usdt_rel_ip assignments
        selftests/bpf: Fix few more compiler warnings
        selftests/bpf: Fix bogus uninitialized variable warning
        bpftool: Remove zlib feature test from Makefile
        libbpf: Cleanup the legacy uprobe_event on failed add/attach_event()
        libbpf: Fix wrong variable used in perf_event_uprobe_open_legacy()
        libbpf: Cleanup the legacy kprobe_event on failed add/attach_event()
        selftests/bpf: Add type match test against kernel's task_struct
        selftests/bpf: Add nested type to type based tests
        ...
      ====================
      
      Link: https://lore.kernel.org/r/20220708233145.32365-1-daniel@iogearbox.netSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      0076cad3
  9. 09 7月, 2022 2 次提交