Skip to content

Allow accessing map metadata for native images from user space #4361

@lmb

Description

@lmb

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.

Metadata

Metadata

Assignees

Labels

P2enhancementNew feature or requesttriagedDiscussed in a triage meeting

Type

No type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions