Skip to content

fix(ld.so): errors UB

Anhad Singh requested to merge andypython/relibc:patch5 into master

Currently, how ld.so errors are handled by functions in dlfcn is wrong. dlopen calls linker.load_library which returns a Result<ObjectHandler, goblin::Error>. Now goblin::Error may have variants that are heap allocated. For example: Error::Malformed(format!("invalid path: '{}': {}", path, err)). The error string would be allocated by ld.so's allocator but will be dropped inside libc. This is UB.

After this patch, we now return a custom DlError instead. To get more information about the error, LD_DEBUG=all can be set.

Signed-off-by: Anhad Singh andypython@protonmail.com

Merge request reports