fix stale lock when allocation of ctor queue fails during dlopen
authorRich Felker <dalias@aerifal.cx>
Tue, 29 Sep 2020 22:42:05 +0000 (18:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 15 Oct 2020 00:27:12 +0000 (20:27 -0400)
commit1efc8eb2c7eda7664232ef0292b7283adf0db114
tree3a1780dc7e0bdbaf39b7946995272c66a45681c0
parent69a1b39019c51258af14c0b2d836c23d20929c9a
fix stale lock when allocation of ctor queue fails during dlopen

queue_ctors should not be called with the init_fini_lock held, since
it may longjmp out on allocation failure. this introduces a minor
TOCTOU race with p->constructed, but one already exists further down
anyway, and by design it's okay to run through the queue more than
once anyway. the only reason we bother to check p->constructed at all
is to avoid spurious failure of dlopen when the library is already
fully loaded and constructed.
ldso/dynlink.c