diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-05-02 04:57:02 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-05-02 04:57:02 +0000 |
commit | 64bbd9e4628abe8823de2913a59d94d90d53e524 (patch) | |
tree | d0cb7c94b69ee863c7bf83e9259e9b2a17deb654 /libexec | |
parent | b4b6194a60b2e4ac571bb4b5a0ce6d006f8d9a32 (diff) |
Combine the signal mask handling into _dl_thread_bind_lock(), as it's MI.
ok drahn@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/alpha/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/amd64/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/arm/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/dlfcn.c | 12 | ||||
-rw-r--r-- | libexec/ld.so/hppa/rtld_machine.c | 8 | ||||
-rw-r--r-- | libexec/ld.so/i386/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/powerpc/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/resolve.h | 5 | ||||
-rw-r--r-- | libexec/ld.so/sh/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/sparc/rtld_machine.c | 11 | ||||
-rw-r--r-- | libexec/ld.so/sparc64/rtld_machine.c | 11 |
11 files changed, 48 insertions, 65 deletions
diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c index 4d72f51c7fd..ac97fd3b583 100644 --- a/libexec/ld.so/alpha/rtld_machine.c +++ b/libexec/ld.so/alpha/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.43 2008/07/28 22:11:00 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.44 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -172,7 +172,7 @@ _dl_bind(elf_object_t *object, int reloff) Elf_Addr *addr, ooff; const Elf_Sym *sym, *this; const char *symn; - sigset_t omask, nmask; + sigset_t savedmask; rela = (Elf_RelA *)(object->Dyn.info[DT_JMPREL] + reloff); @@ -202,9 +202,7 @@ _dl_bind(elf_object_t *object, int reloff) /* if PLT is protected, allow the write */ if (object->plt_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect(addr, sizeof(Elf_Addr), PROT_READ|PROT_WRITE); } @@ -215,8 +213,7 @@ _dl_bind(elf_object_t *object, int reloff) if (object->plt_size != 0) { _dl_mprotect(addr, sizeof(Elf_Addr), PROT_READ); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return *addr; diff --git a/libexec/ld.so/amd64/rtld_machine.c b/libexec/ld.so/amd64/rtld_machine.c index dcf9669b983..6dad018143a 100644 --- a/libexec/ld.so/amd64/rtld_machine.c +++ b/libexec/ld.so/amd64/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.14 2008/04/09 21:45:26 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.15 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 2002,2004 Dale Rahn @@ -338,7 +338,7 @@ _dl_bind(elf_object_t *object, int index) const Elf_Sym *sym, *this; const char *symn; Elf_Addr ooff, newval; - sigset_t omask, nmask; + sigset_t savedmask; rel = (Elf_RelA *)(object->Dyn.info[DT_JMPREL]); @@ -362,9 +362,7 @@ _dl_bind(elf_object_t *object, int index) /* if GOT is protected, allow the write */ if (object->got_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ|PROT_WRITE); } @@ -375,8 +373,7 @@ _dl_bind(elf_object_t *object, int index) if (object->got_size != 0) { _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return(newval); diff --git a/libexec/ld.so/arm/rtld_machine.c b/libexec/ld.so/arm/rtld_machine.c index c509275acae..0ee18827cdd 100644 --- a/libexec/ld.so/arm/rtld_machine.c +++ b/libexec/ld.so/arm/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.14 2008/04/09 21:45:26 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.15 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 2004 Dale Rahn @@ -390,7 +390,7 @@ _dl_bind(elf_object_t *object, int relidx) const Elf_Sym *sym, *this; const char *symn; Elf_Addr ooff, newval; - sigset_t omask, nmask; + sigset_t savedmask; rel = ((Elf_Rel *)object->Dyn.info[DT_JMPREL]) + (relidx); @@ -412,9 +412,7 @@ _dl_bind(elf_object_t *object, int relidx) /* if GOT is protected, allow the write */ if (object->got_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ|PROT_WRITE); } @@ -426,8 +424,7 @@ _dl_bind(elf_object_t *object, int relidx) if (object->got_size != 0) { _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return newval; } diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c index f64245203cb..f09b8b5603e 100644 --- a/libexec/ld.so/dlfcn.c +++ b/libexec/ld.so/dlfcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dlfcn.c,v 1.80 2008/06/13 23:14:47 kurt Exp $ */ +/* $OpenBSD: dlfcn.c,v 1.81 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -516,10 +516,18 @@ _dl_show_objects(void) } void -_dl_thread_bind_lock(int what) +_dl_thread_bind_lock(int what, sigset_t *omask) { + if (! what) { + sigset_t nmask; + + sigfillset(&nmask); + _dl_sigprocmask(SIG_BLOCK, &nmask, omask); + } if (_dl_bind_lock_f != NULL) (*_dl_bind_lock_f)(what); + if (what) + _dl_sigprocmask(SIG_SETMASK, omask, NULL); } void diff --git a/libexec/ld.so/hppa/rtld_machine.c b/libexec/ld.so/hppa/rtld_machine.c index ab0714b8c21..e7e2b21ba4b 100644 --- a/libexec/ld.so/hppa/rtld_machine.c +++ b/libexec/ld.so/hppa/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.17 2010/01/03 22:18:04 kettenis Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.18 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 2004 Michael Shalayeff @@ -418,7 +418,7 @@ _dl_bind(elf_object_t *object, int reloff) const char *symn; Elf_Addr value; Elf_RelA *rela; - sigset_t omask, nmask; + sigset_t savedmask; rela = (Elf_RelA *)object->dyn.jmprel + reloff; @@ -440,9 +440,7 @@ _dl_bind(elf_object_t *object, int reloff) /* if PLT+GOT is protected, allow the write */ if (object->got_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); /* mprotect the actual modified region, not the whole plt */ _dl_mprotect((void*)addr, sizeof (Elf_Addr) * 2, PROT_READ|PROT_WRITE); diff --git a/libexec/ld.so/i386/rtld_machine.c b/libexec/ld.so/i386/rtld_machine.c index c43666e0fda..620a658fc78 100644 --- a/libexec/ld.so/i386/rtld_machine.c +++ b/libexec/ld.so/i386/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.23 2008/04/09 21:45:26 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.24 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -342,7 +342,7 @@ _dl_bind(elf_object_t *object, int index) const Elf_Sym *sym, *this; const char *symn; Elf_Addr ooff; - sigset_t omask, nmask; + sigset_t savedmask; rel = (Elf_Rel *)(object->Dyn.info[DT_JMPREL]); @@ -363,9 +363,7 @@ _dl_bind(elf_object_t *object, int index) /* if GOT is protected, allow the write */ if (object->got_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ|PROT_WRITE); } @@ -376,8 +374,7 @@ _dl_bind(elf_object_t *object, int index) if (object->got_size != 0) { _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return((Elf_Addr)ooff + this->st_value); diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c index 52df2ebc286..42f609c6a2f 100644 --- a/libexec/ld.so/powerpc/rtld_machine.c +++ b/libexec/ld.so/powerpc/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.45 2008/04/09 21:45:26 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.46 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -548,7 +548,7 @@ _dl_bind(elf_object_t *object, int reloff) Elf32_Addr *pltcall; Elf32_Addr *pltinfo; Elf32_Addr *plttable; - sigset_t omask, nmask; + sigset_t savedmask; relas = ((Elf_RelA *)object->Dyn.info[DT_JMPREL]) + (reloff>>2); @@ -568,9 +568,7 @@ _dl_bind(elf_object_t *object, int reloff) /* if PLT is protected, allow the write */ if (object->plt_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->plt_start, object->plt_size, PROT_READ|PROT_WRITE|PROT_EXEC); } @@ -622,8 +620,7 @@ _dl_bind(elf_object_t *object, int reloff) if (object->plt_size != 0) { _dl_mprotect((void*)object->plt_start, object->plt_size, PROT_READ|PROT_EXEC); /* only PPC is PROT_EXE */ - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return (value); } diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h index 8500a6703c9..feb11d5a584 100644 --- a/libexec/ld.so/resolve.h +++ b/libexec/ld.so/resolve.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.h,v 1.58 2010/03/27 20:16:15 kettenis Exp $ */ +/* $OpenBSD: resolve.h,v 1.59 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -32,6 +32,7 @@ #include <sys/queue.h> #include <link.h> #include <dlfcn.h> +#include <signal.h> struct load_list { struct load_list *next; @@ -221,7 +222,7 @@ void _dl_load_list_free(struct load_list *load_list); void _dl_thread_kern_go(void); void _dl_thread_kern_stop(void); -void _dl_thread_bind_lock(int); +void _dl_thread_bind_lock(int, sigset_t *); extern elf_object_t *_dl_objects; extern elf_object_t *_dl_last_object; diff --git a/libexec/ld.so/sh/rtld_machine.c b/libexec/ld.so/sh/rtld_machine.c index b09c4d3fa4d..28b16c0b4a3 100644 --- a/libexec/ld.so/sh/rtld_machine.c +++ b/libexec/ld.so/sh/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.13 2008/07/24 23:42:26 guenther Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.14 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 2004 Dale Rahn @@ -837,7 +837,7 @@ _dl_bind(elf_object_t *object, int relidx) const Elf_Sym *sym, *this; const char *symn; Elf_Addr ooff, newval; - sigset_t omask, nmask; + sigset_t savedmask; rel = ((Elf_Rel *)object->Dyn.info[DT_JMPREL]) + (relidx); @@ -859,9 +859,7 @@ _dl_bind(elf_object_t *object, int relidx) /* if GOT is protected, allow the write */ if (object->got_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ|PROT_WRITE); } @@ -873,8 +871,7 @@ _dl_bind(elf_object_t *object, int relidx) if (object->got_size != 0) { _dl_mprotect((void*)object->got_start, object->got_size, PROT_READ); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return newval; } diff --git a/libexec/ld.so/sparc/rtld_machine.c b/libexec/ld.so/sparc/rtld_machine.c index 1e44efa51aa..904965b0994 100644 --- a/libexec/ld.so/sparc/rtld_machine.c +++ b/libexec/ld.so/sparc/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.31 2008/04/09 21:45:26 kurt Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.32 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -316,7 +316,7 @@ _dl_bind(elf_object_t *object, int reloff) const char *symn; Elf_Addr value; Elf_RelA *rela; - sigset_t omask, nmask; + sigset_t savedmask; rela = (Elf_RelA *)(object->Dyn.info[DT_JMPREL] + reloff); @@ -338,9 +338,7 @@ _dl_bind(elf_object_t *object, int reloff) /* if PLT is protected, allow the write */ if (object->plt_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); /* mprotect the actual modified region, not the whole plt */ _dl_mprotect((void*)addr, sizeof (Elf_Addr) * 3, PROT_READ|PROT_WRITE|PROT_EXEC); @@ -353,8 +351,7 @@ _dl_bind(elf_object_t *object, int reloff) /* mprotect the actual modified region, not the whole plt */ _dl_mprotect((void*)addr, sizeof (Elf_Addr) * 3, PROT_READ|PROT_EXEC); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return (value); diff --git a/libexec/ld.so/sparc64/rtld_machine.c b/libexec/ld.so/sparc64/rtld_machine.c index 0776204ba71..feb9983b34b 100644 --- a/libexec/ld.so/sparc64/rtld_machine.c +++ b/libexec/ld.so/sparc64/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.44 2010/04/24 18:12:29 kettenis Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.45 2010/05/02 04:57:01 guenther Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -600,7 +600,7 @@ _dl_bind(elf_object_t *object, int index) Elf_Addr ooff; const Elf_Sym *sym, *this; const char *symn; - sigset_t omask, nmask; + sigset_t savedmask; rela = (Elf_RelA *)(object->Dyn.info[DT_JMPREL]); if (ELF_R_TYPE(rela->r_info) == R_TYPE(JMP_SLOT)) { @@ -643,9 +643,7 @@ _dl_bind(elf_object_t *object, int index) /* if PLT is protected, allow the write */ if (object->plt_size != 0) { - sigfillset(&nmask); - _dl_sigprocmask(SIG_BLOCK, &nmask, &omask); - _dl_thread_bind_lock(0); + _dl_thread_bind_lock(0, &savedmask); _dl_mprotect((void*)object->plt_start, object->plt_size, PROT_READ|PROT_WRITE|PROT_EXEC); } @@ -656,8 +654,7 @@ _dl_bind(elf_object_t *object, int index) if (object->plt_size != 0) { _dl_mprotect((void*)object->plt_start, object->plt_size, PROT_READ|PROT_EXEC); - _dl_thread_bind_lock(1); - _dl_sigprocmask(SIG_SETMASK, &omask, NULL); + _dl_thread_bind_lock(1, &savedmask); } return ooff + this->st_value; |