GrapheneOS / hardened_malloc

Hardened allocator designed for modern systems. It has integration into Android's Bionic libc and can be used externally with musl and glibc as a dynamic library for use on other Linux-based platforms. It will gain more portability / integration over time.
https://grapheneos.org/
MIT License
1.26k stars 96 forks source link

[linux, question] Error loading shared libraries #207

Closed dkwo closed 1 year ago

dkwo commented 1 year ago

This is most likely a mistake on my end. On Void Linux (x86_64-musl) I tried to package hardened-malloc https://github.com/void-linux/void-packages/compare/master...dkwo:void-packages:stinger If I put /usr/lib/libhardened_malloc.so in /etc/ld-musl-x86_64.path, then most commands from coreutils fail to work, for example ls gives

Error loading shared library libcap.so.2: No such file or directory (needed by /bin/ls)
Error relocating /bin/ls: cap_to_text: symbol not found
Error relocating /bin/ls: cap_free: symbol not found
Error relocating /bin/ls: cap_get_file: symbol not found

If instead I use LD_PRELOAD, it works fine.

Do you see what I'm doing wrong?

thestinger commented 1 year ago

That's not the right place to configure it. You're overriding the default library search path so libraries can't be found.

dkwo commented 1 year ago

Thank you! I'm now using

$ cat /etc/ld.so.preload 
/usr/lib/libhardened_malloc.so