[RFC bpf-next 0/9] BPF indirect jumps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patchset implements a new type of map, instruction set, and uses
it to build support for indirect branches in BPF (x86). (The same map
will be later used to provide support for indirect calls and static
keys.) See [1], [2] for more context.

Short table of contents:

  * Patches 1,2,3 implement the new map of type
    BPF_MAP_TYPE_INSN_SET. This map can be used to track the
    "original -> xlated -> jitted mapping" for a given program.

  * patches 4,5 implement the support for indirect jumps

  * 6,7,8,9 add support for LLVM-compiled programs containing
    indirect jumps. A special LLVM should be used for that, see [3]
    for the details and some related discussions.

There is a list of TBDs (mostly, more checks & selftests, faster
lookups, etc.), plus the tests only can be compiled by a custom
LLVM, thus this is an RFC. However, all the selftests which compile 
to contain an indirect jump work with this patchset, so it is looking
worth sending it as is already. Namely, the following selftests
will contain an indirect jump:

    * bpf_goto_x, cgroup_tcp_skb, cls_redirect, bpf_tcp_ca,
    * bpf_iter_setsockopt, tc_change_tail, net_timestamping,
    * user_ringbuf, tcp_hdr_options, tunnel, exceptions,
    * tcpbpf_user, tcp_custom_syncookie

See individual patches for more details on implementation details.

Links:
  1. https://lpc.events/event/18/contributions/1941/
  2. https://lwn.net/Articles/1017439/
  3. https://github.com/llvm/llvm-project/pull/133856

Anton Protopopov (9):
  bpf: save the start of functions in bpf_prog_aux
  bpf, x86: add new map type: instructions set
  selftests/bpf: add selftests for new insn_set map
  bpf, x86: allow indirect jumps to r8...r15
  bpf, x86: add support for indirect jumps
  bpf: workaround llvm behaviour with indirect jumps
  bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X
  libbpf: support llvm-generated indirect jumps
  selftests/bpf: add selftests for indirect jumps

 arch/x86/net/bpf_jit_comp.c                   |  44 +-
 include/linux/bpf.h                           |  24 +
 include/linux/bpf_types.h                     |   1 +
 include/linux/bpf_verifier.h                  |   6 +
 include/uapi/linux/bpf.h                      |  11 +
 kernel/bpf/Makefile                           |   2 +-
 kernel/bpf/bpf_insn_set.c                     | 407 +++++++++++++++
 kernel/bpf/core.c                             |   2 +
 kernel/bpf/disasm.c                           |  10 +
 kernel/bpf/syscall.c                          |  22 +
 kernel/bpf/verifier.c                         | 266 +++++++++-
 tools/include/uapi/linux/bpf.h                |  11 +
 tools/lib/bpf/libbpf.c                        | 333 +++++++++++-
 tools/lib/bpf/libbpf_internal.h               |   4 +
 tools/lib/bpf/linker.c                        |  66 ++-
 tools/testing/selftests/bpf/Makefile          |   4 +-
 .../selftests/bpf/prog_tests/bpf_goto_x.c     | 127 +++++
 .../selftests/bpf/prog_tests/bpf_insn_set.c   | 481 ++++++++++++++++++
 .../testing/selftests/bpf/progs/bpf_goto_x.c  | 336 ++++++++++++
 19 files changed, 2116 insertions(+), 41 deletions(-)
 create mode 100644 kernel/bpf/bpf_insn_set.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_goto_x.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_insn_set.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_goto_x.c

-- 
2.34.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux