mirror of git://git.musl-libc.org/musl
protect against cancellation in dlopen
i'm not sure that it's "correct" for dlopen to block cancellation when calling constructors for libraries it loads, but it sure seems like the right thing. in any case, dlopen itself needs cancellation blocked.
This commit is contained in:
parent
700a8156ad
commit
f2baf4d7b8
|
@ -610,9 +610,11 @@ void *dlopen(const char *file, int mode)
|
||||||
{
|
{
|
||||||
struct dso *volatile p, *orig_tail = tail, *next;
|
struct dso *volatile p, *orig_tail = tail, *next;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int cs;
|
||||||
|
|
||||||
if (!file) return head;
|
if (!file) return head;
|
||||||
|
|
||||||
|
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
|
||||||
pthread_rwlock_wrlock(&lock);
|
pthread_rwlock_wrlock(&lock);
|
||||||
|
|
||||||
if (setjmp(rtld_fail)) {
|
if (setjmp(rtld_fail)) {
|
||||||
|
@ -628,8 +630,8 @@ void *dlopen(const char *file, int mode)
|
||||||
}
|
}
|
||||||
tail = orig_tail;
|
tail = orig_tail;
|
||||||
tail->next = 0;
|
tail->next = 0;
|
||||||
pthread_rwlock_unlock(&lock);
|
p = 0;
|
||||||
return 0;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = load_library(file);
|
p = load_library(file);
|
||||||
|
@ -658,6 +660,7 @@ void *dlopen(const char *file, int mode)
|
||||||
do_init_fini(tail);
|
do_init_fini(tail);
|
||||||
end:
|
end:
|
||||||
pthread_rwlock_unlock(&lock);
|
pthread_rwlock_unlock(&lock);
|
||||||
|
pthread_setcancelstate(cs, 0);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue