libbpf / libbpf-rs

Minimal and opinionated eBPF tooling for the Rust ecosystem
Other
741 stars 129 forks source link

libbpf-cargo: Don't populate datasec contents for kconfig map #911

Closed danielocfb closed 1 month ago

danielocfb commented 1 month ago

The .kconfig section is special in that libbpf sets its values as part of the load procedure. That means that until then, i.e., during open, contents are invalid. To that end the library doesn't even set the mmap pointer to anything but NULL, despite all heuristics pointing at it being mmapable and whatnot. That's a problem for us, because we generate section contents and attempt to have them reference this nonexistent mmap area, which will fail. Work around the issue by special casing this section and not permitting direct datasec access. If users require this access they have to manually iterate maps, retrieve initial value, and cast it to types::kconfig.

Closes: #909

danielocfb commented 1 month ago

Updated this PR to be a bit more lenient and provide kconfig data access after load.

danielocfb commented 1 month ago

Going ahead with the merge to get this into a release. @anakryiko if you have any post-land comments do let me know.