Open
Conversation
Author
|
Made binfmt only handle v1 FatElf binaries. |
M3Henry
commented
Oct 12, 2024
| if(MEMFD) | ||
| add_fatelf_executable(fatelf-exec) | ||
|
|
||
| find_program(BINFMT systemd-binfmt PATHS /usr/lib/systemd) |
Author
There was a problem hiding this comment.
I'm on the fence as to whether /usr/lib ought to be replaced with ${CMAKE_INSTALL_FULL_LIBDIR}.
M3Henry
commented
Oct 12, 2024
Add the ability to execute fatelf binaries from a memfd with fatelf-exec. It reads its own ELF header via /proc/self/exe to determine the target. Use systemd-binfmt to tell the kernel to execute FatElf with fatelf-exec. Future improvements: * Read into a mmap of the memfd. * Be aware of non-exact record matches which are compatible with the OS. e.g. Linux x86 & x32 binaries can run on x86_64. * Compile time knowledge of current architecture to avoid /proc/self/exe. * OpenBSD support may be possible with shm_mkstemp. * Defer to other binfmt handlers?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for your work coming up with a sensible spec. I stumbled across
systemd-binfmtrecently and remembered FatElf.As it stands,
fatelf-execcopies the contained ELF into an anonymous memory backed file and executes it. This works for statically linked binaries and dynamically linked binaries that are linked to normal ELF dynamic libraries.For the use case of FatElf dynamic libraries, this does not provide a solution, though it could be possible in theory to shim
ld-linux.sosomehow.It turns out there is demand for this sort of thing. Though it seems one only gets support when done with clever tricks: APE