Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add O_PATH-based BPF_OBJ_PIN and BPF_OBJ_GET support #5076

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: Add O_PATH-based BPF_OBJ_PIN and BPF_OBJ_GET support
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 108598c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 108598c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 108598c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 3879122
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: de58ef4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0697e43
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: cff3639
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 2a36c26
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8819495
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=747804
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=747804 expired. Closing PR.

Current UAPI of BPF_OBJ_PIN and BPF_OBJ_GET commands of bpf() syscall
forces users to specify pinning location as a string-based absolute or
relative (to current working directory) path. This has various
implications related to security (e.g., symlink-based attacks), forces
BPF FS to be exposed in the file system, which can cause races with
other applications.

One of the feedbacks we got from folks working with containers heavily
was that inability to use purely FD-based location specification was an
unfortunate limitation and hindrance for BPF_OBJ_PIN and BPF_OBJ_GET
commands. This patch closes this oversight, adding path_fd field to
BPF_OBJ_PIN and BPF_OBJ_GET UAPI, following conventions established by
*at() syscalls for dirfd + pathname combinations.

This now allows interesting possibilities like working with detached BPF
FS mount (e.g., to perform multiple pinnings without running a risk of
someone interfering with them), and generally making pinning/getting
more secure and not prone to any races and/or security attacks.

This is demonstrated by a selftest added in subsequent patch that takes
advantage of new mount APIs (fsopen, fsconfig, fsmount) to demonstrate
creating detached BPF FS mount, pinning, and then getting BPF map out of
it, all while never exposing this private instance of BPF FS to outside
worlds.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add path_fd support for bpf_obj_pin() and bpf_obj_get() operations
(through their opts-based variants). This allows to take advantage of
new kernel-side support for O_PATH-based pin/get location specification.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add a selftest demonstrating using detach-mounted BPF FS using new mount
APIs, and pinning and getting BPF map using such mount. This
demonstrates how something like container manager could setup BPF FS,
pin and adjust all the necessary objects in it, all before exposing BPF
FS to a particular mount namespace.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: effcf62
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=749044
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=749044 expired. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant