Page MenuHomeFreeBSD

rtld: implement _dl_iterate_phdr_locked
ClosedPublic

Authored by kevans on Wed, Nov 13, 10:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 11:45 AM
Unknown Object (File)
Thu, Nov 14, 5:44 PM
Unknown Object (File)
Thu, Nov 14, 3:25 AM
Subscribers

Details

Summary

Some sanitizers need to be able to use dl_iterate_phdr() after stopping
the rest of the process, but it's very hard to do so reliably as a
non-participant in the main logic of the program.

Introduce _dl_iterate_phdr_locked to bypass the locking that's normally
required for dl_iterate_phdr() and slap some scary warning on it. It
will remain undocumented and probably shouldn't be used for anything
else.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60537
Build 57421: arc lint + arc unit

Event Timeline

Now after a fresh look, I suggest to change the new function to be read-only. What I mean, is to remove hold/unhold_object and marker linkage. I believe this is 'better' in the sense that it would induce the UB memory accesses on the caller, but other threads would not see unlocked updates.

Re-implement r/o

Revert the previous implementation and just write a new short and sweet
implementation that iterates over the globallist and invokes the callback.

libexec/rtld-elf/rtld.c
4216

You still want to do rtld_fill_dl_phdr_info(&obj_rtld, &phdr_info); and then execute callback on rtld data.

kevans marked an inline comment as done.

Don't skip the rtld object itself, and use consistent sizeof() while here.

libexec/rtld-elf/rtld.c
4216

D'oh! Thanks

kib added inline comments.
libexec/rtld-elf/rtld.c
4207

I think the initialization is not needed.

This revision is now accepted and ready to land.Thu, Nov 14, 12:41 AM
This revision was automatically updated to reflect the committed changes.