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

Unable to mmap non-PIE ELF binaries #5

Open
athola opened this issue Oct 28, 2024 · 2 comments
Open

Unable to mmap non-PIE ELF binaries #5

athola opened this issue Oct 28, 2024 · 2 comments

Comments

@athola
Copy link

athola commented Oct 28, 2024

Apologies if this is out-of-scope and willing to do some further testing on this, but encountered an issue where non-PIE ELF binaries cannot be loaded/executed due to the nature of the Interpreter loader. I get Inconsistency detected by ld.so: rtld.c: 1494: dl_main: Assertion 'GL(dl_rtld_map).l_libname' failed! when trying to bypass the is_pie assertion.

I've looked into the implementation here and am curious about viability of integrating something along these lines:

https://github.com/rapid7/mettle/blob/master/libreflect/src/map_elf.c

Please let me know if I can provide some assistance on this matter. I think being able to execute non-PIE binaries would be a huge win for this project, but I do understand the challenge associated with the task.

@io12
Copy link
Owner

io12 commented Oct 29, 2024

I think the main challenge is that the fixed-offset might overlap userland-execve itself, so it needs to detect that and relocate (part of) itself before mapping the ELF. Does that match your understanding? Do you know of a better way? I might have to check how ld.so handles this when you run the interpreter manually, e.g. with /lib/ld-linux-x86-64.so.2 /bin/hello.

@io12
Copy link
Owner

io12 commented Oct 29, 2024

I might have to check how ld.so handles this when you run the interpreter manually, e.g. with /lib/ld-linux-x86-64.so.2 /bin/hello.

I tried to look into this, and I'm pretty sure the answer is just that non-PIE binaries are (nearly?) always loaded at low addresses, and the kernel always loads PIE libraries at high addresses, so they don't overlap, and the runtime dynamic linker is always PIE. This probably doesn't help here, because ideally userland-execve itself shouldn't need to be PIE to work.

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

No branches or pull requests

2 participants