This is an archive of the discontinued LLVM Phabricator instance.

[lsan] Fix deadlock in dl_iterate_phdr.
ClosedPublic

Authored by eugenis on Sep 18 2019, 3:56 PM.

Details

Summary

Do not grab the allocator lock before calling dl_iterate_phdr. This may
cause a lock order inversion with (valid) user code that uses malloc
inside a dl_iterate_phdr callback.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis created this revision.Sep 18 2019, 3:56 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 18 2019, 3:56 PM
Herald added subscribers: Restricted Project, jfb. · View Herald Transcript
hctim accepted this revision.Sep 18 2019, 6:41 PM
hctim added inline comments.
compiler-rt/test/lsan/TestCases/Linux/libdl_deadlock.cpp
5 ↗(On Diff #220766)

Nit: order includes

13 ↗(On Diff #220766)

nit: int Callback

20 ↗(On Diff #220766)

nit: replace with if (step == 0)

32 ↗(On Diff #220766)

Nit: 80chars

This revision is now accepted and ready to land.Sep 18 2019, 6:41 PM
eugenis updated this revision to Diff 220897.Sep 19 2019, 12:46 PM

addressed review comments

eugenis marked 4 inline comments as done.Sep 19 2019, 12:46 PM
This revision was automatically updated to reflect the committed changes.