stephenrkell / libcrunch

A dynamically safe implementation of C, using your existing C compiler. Tolerates idiomatic C code pretty well. Not perfect... yet.
100 stars 4 forks source link

Stubs and preload DSOs suffer duplication #5

Open stephenrkell opened 3 years ago

stephenrkell commented 3 years ago

The shadow space has caused our stubs library to become not-so-minimal. It relies on mmap nudging, so depends on parts of liballocs, but it should be possible to make it avoid most duplication. This is also important for use of RTLD_NEXT -- we don't want a second copy of any of wrappers which use this.

stephenrkell commented 3 years ago

Non-obvious explanation: our preload wrappers don't compose because of the __avoid_libdl_calls hack. Once one of them is told not to make libdl calls, it will conservatively avoid downcalling (say to orig_dl_iterate_phdr) even if its callee is not the libdl version. This might be broken logic.

stephenrkell commented 3 years ago

Probably the right thing is to refactor so that the core runtime is in the _stubs.so, and the preload lib is just a minimal selection of hook points. But how does this design play with liballocs? And with the idea that we want to be our own ld.so, rather than a preload library?