fix race condition in dlopen
orig_tail was being saved before the lock was obtained, allowing dlopen failure to roll-back other dlopens that had succeeded.
This commit is contained in:
parent
99a2af6f45
commit
642b7593c3
1 changed files with 3 additions and 1 deletions
|
|
@ -886,7 +886,7 @@ void *__dynlink(int argc, char **argv)
|
||||||
|
|
||||||
void *dlopen(const char *file, int mode)
|
void *dlopen(const char *file, int mode)
|
||||||
{
|
{
|
||||||
struct dso *volatile p, *orig_tail = tail, *next;
|
struct dso *volatile p, *orig_tail, *next;
|
||||||
size_t i;
|
size_t i;
|
||||||
int cs;
|
int cs;
|
||||||
|
|
||||||
|
|
@ -895,6 +895,8 @@ void *dlopen(const char *file, int mode)
|
||||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
|
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
|
||||||
pthread_rwlock_wrlock(&lock);
|
pthread_rwlock_wrlock(&lock);
|
||||||
|
|
||||||
|
orig_tail = tail;
|
||||||
|
|
||||||
if (setjmp(rtld_fail)) {
|
if (setjmp(rtld_fail)) {
|
||||||
/* Clean up anything new that was (partially) loaded */
|
/* Clean up anything new that was (partially) loaded */
|
||||||
if (p->deps) for (i=0; p->deps[i]; i++)
|
if (p->deps) for (i=0; p->deps[i]; i++)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue