Skip to content

Attach a cookie to a tracing program.

Kui-Feng Lee bpf 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest posting 2/25 patches 1 replyIn review
  2. v8 posting 1/25 patches 4 repliesApplied 5/5
  3. v75 patches 13 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v66 patches10 repliesSuperseded
v55 patches11 repliesSuperseded
v45 patches2 repliesSuperseded
v35 patches3 repliesSuperseded
v24 patches26 repliesSuperseded
v15 patches10 repliesSuperseded

Patches in v8 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5bpf, x86: Generate trampolines from bpf_tramp_linksarch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/linux/bpf_types.h +7 more+164 -1030 replies
2/5bpf, x86: Create bpf_tramp_run_ctx on the caller thread's stackarch/x86/net/bpf_jit_comp.c include/linux/bpf.h kernel/bpf/syscall.c +1 more+66 -190 replies
3/5bpf, x86: Attach a cookie to fentry/fexit/fmod_ret/lsm.arch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/uapi/linux/bpf.h +5 more+71 -80 replies
4/5libbpf: Assign cookies to links in libbpf.tools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.c +2 more+39 -40 replies
5/5selftest/bpf: The test cses of BPF cookie for fentry/fexit/fmod_ret/lsm.tools/testing/selftests/bpf/prog_tests/bpf_cookie.c tools/testing/selftests/bpf/progs/test_bpf_cookie.c+133 -80 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchAndrii Nakryiko
1/5A-b
2/5A-b
3/5A-b
4/5A-b
5/5A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v8 thread

Cover letter [PATCH bpf-next v8 0/5] Attach a cookie to a tracing program.

Allow users to attach a 64-bits cookie to a bpf_link of fentry, fexit, or fmod_ret.

This patchset includes several major changes.

- Define struct bpf_tramp_links to replace bpf_tramp_prog. struct bpf_tramp_links collects bpf_links of a trampoline

- Generate a trampoline to call bpf_progs of given bpf_links.

- Trampolines always set/reset bpf_run_ctx before/after calling/leaving a tracing program.

- Attach a cookie to a bpf_link of fentry/fexit/fmod_ret/lsm. The value will be available when running the associated bpf_prog.

Th major differences from v6:

- bpf_link_create() can create links of BPF_LSM_MAC attach type.

- Add a test for lsm.

- Add function proto of bpf_get_attach_cookie() for lsm.

- Check BPF_LSM_MAC in bpf_prog_has_trampoline().

- Adapt to the changes of LINK_CREATE made by Andrii.

The major differences from v7:

- Change stack_size instead of pushing/popping run_ctx.

- Move cookie to bpf_tramp_link from bpf_tracing_link..

v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/bpf/[email protected]/
v3: https://lore.kernel.org/bpf/[email protected]/
v4: https://lore.kernel.org/bpf/[email protected]/
v5: https://lore.kernel.org/bpf/[email protected]/
v6: https://lore.kernel.org/bpf/[email protected]/
v7: https://lore.kernel.org/bpf/[email protected]/

Kui-Feng Lee (5):
bpf, x86: Generate trampolines from bpf_tramp_links bpf, x86: Create bpf_tramp_run_ctx on the caller thread's stack bpf, x86: Attach a cookie to fentry/fexit/fmod_ret/lsm.
libbpf: Assign cookies to links in libbpf. selftest/bpf: The test cses of BPF cookie for
fentry/fexit/fmod_ret/lsm.

 arch/x86/net/bpf_jit_comp.c                   |  76 ++++++++-----
 include/linux/bpf.h                           |  54 +++++++---
 include/linux/bpf_types.h                     |   1 +
 include/uapi/linux/bpf.h                      |  10 ++
 kernel/bpf/bpf_lsm.c                          |  17 +++
 kernel/bpf/bpf_struct_ops.c                   |  71 +++++++++----
 kernel/bpf/syscall.c                          |  42 ++++----
 kernel/bpf/trampoline.c                       | 100 +++++++++++-------
 kernel/trace/bpf_trace.c                      |  17 +++
 net/bpf/bpf_dummy_struct_ops.c                |  24 ++++-
 tools/bpf/bpftool/link.c                      |   1 +
 tools/include/uapi/linux/bpf.h                |  10 ++
 tools/lib/bpf/bpf.c                           |   8 ++
 tools/lib/bpf/bpf.h                           |   3 +
 tools/lib/bpf/libbpf.c                        |  19 +++-
 tools/lib/bpf/libbpf.h                        |  12 +++
 tools/lib/bpf/libbpf.map                      |   1 +
 .../selftests/bpf/prog_tests/bpf_cookie.c     |  89 ++++++++++++++++
 .../selftests/bpf/progs/test_bpf_cookie.c     |  52 +++++++--
 19 files changed, 469 insertions(+), 138 deletions(-)
Signature · 1 line
2.30.2