microsoft / microsoft/ebpf-for-windows

Allow accessing map metadata for native images from user space

Open
#4,361 1 comment 0 reactions 1 assignee Claimed by @saxena-anurag View on GitHub
enhancement P2 triaged
Dominant language
C
Stars
3.6k
Forks
311
Avg merge
6d 10h
Merged PRs (30d)
21

Description

### Describe the feature you'd like supported

ebpf-go has logic around handling maps which are pinned by name which is used to ensure persistence across application restarts. It works something like this:

* User sets `LIBBPF_PIN_BY_NAME` in C
* User loads the ELF while specifying a prefix (there is no default to discourage clashes) in Go
* Then there is some logic which mirrors _ebpf_native_validate_map in the code base.

Implementing this scheme is not possible because for native images, the kernel part of the runtime handles pinning. If a map exists of wrong type we simply get EINVAL, which is too coarse an error.

### Proposed solution

I'd like to be able to query pre-creation map metadata (essentially struct bpf_map_def) from a native image, after it has been loaded. I'd also like to be able to opt-out of handling of LIBBPF_PIN_BY_NAME in the runtime.

### Additional context

I think that this could also allow reducing the amount of code we need in kernel space, since the runtime could do pinning in user space instead. Since pinning involves string manipulation / concatenation this could be valuable from a hardening perspective as well.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.