Skip to content

Add O_PATH-based BPF_OBJ_PIN and BPF_OBJ_GET support

Andrii Nakryiko bpf linux-fsdevel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 1 replyIn review
  2. v34 patches 5 repliesSuperseded
  3. v23 patches 7 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches26 repliesSuperseded

Changes in v4 from the cover letter

- libbpf v1.3 bump (Daniel);

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4bpf: Validate BPF object in BPF_OBJ_PIN before calling LSMkernel/bpf/inode.c+5 -60 replies
2/4libbpf: start v1.3 development cycletools/lib/bpf/libbpf.map tools/lib/bpf/libbpf_version.h+4 -10 replies
3/4bpf: support O_PATH FDs in BPF_OBJ_PIN and BPF_OBJ_GET commandsinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/inode.c +5 more+82 -200 replies
4/4selftests/bpf: add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET teststools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c+268 -00 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by.

PatchChristian Brauner
1/4R-b
2/4
3/4R-b
4/4

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

Read the v4 thread

Cover letter [PATCH v4 bpf-next 0/4] Add O_PATH-based BPF_OBJ_PIN and BPF_OBJ_GET support

Add ability to specify pinning location within BPF FS using O_PATH-based FDs, similar to openat() family of APIs. Patch #2 adds necessary kernel-side changes. Patch #3 exposes this through libbpf APIs. Patch #4 uses new mount APIs (fsopen, fsconfig, fsmount) to demonstrated how now it's possible to work with detach-mounted BPF FS using new BPF_OBJ_PIN and BPF_OBJ_GET functionality. We also add few more tests using various combinations of path_fd and pathname to validate proper argument propagation in kernel code.

This feature is inspired as a result of recent conversations during LSF/MM/BPF 2023 conference about shortcomings of being able to perform BPF objects pinning only using lookup-based paths.

v3->v4:
- libbpf v1.3 bump (Daniel);
v2->v3:
- __s32 for path_fd in union bpf_attr (Christian);
- added subtest for absolute/relative paths during pinning/getting;
- added pre-patch moving LSM hook (security_path_mknod) around (Christian);
v1->v2:
- add BPF_F_PATH_FD flag that should go along with path FD (Christian).

Andrii Nakryiko (4):
bpf: Validate BPF object in BPF_OBJ_PIN before calling LSM
libbpf: start v1.3 development cycle
bpf: support O_PATH FDs in BPF_OBJ_PIN and BPF_OBJ_GET commands selftests/bpf: add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET tests

 include/linux/bpf.h                           |   4 +-
 include/uapi/linux/bpf.h                      |  10 +
 kernel/bpf/inode.c                            |  27 +-
 kernel/bpf/syscall.c                          |  25 +-
 tools/include/uapi/linux/bpf.h                |  10 +
 tools/lib/bpf/bpf.c                           |  17 +-
 tools/lib/bpf/bpf.h                           |  18 +-
 tools/lib/bpf/libbpf.map                      |   5 +
 tools/lib/bpf/libbpf_version.h                |   2 +-
 .../bpf/prog_tests/bpf_obj_pinning.c          | 268 ++++++++++++++++++
 10 files changed, 359 insertions(+), 27 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c
Signature · 1 line
2.34.1