summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-08-29 14:25:01 +0000
committerkib <kib@FreeBSD.org>2015-08-29 14:25:01 +0000
commit146b187d13b83615f02a68c038af82670588495f (patch)
treeadcae95aa50cd2cbf281d867115b7156006965ea /lib/libc/stdlib
parent8cde3bfeee04d11f30244c875082f0c8423cbcd8 (diff)
downloadFreeBSD-src-146b187d13b83615f02a68c038af82670588495f.zip
FreeBSD-src-146b187d13b83615f02a68c038af82670588495f.tar.gz
Switch libc from using _sig{procmask,action,suspend} symbols, which
are aliases for the syscall stubs and are plt-interposed, to the libc-private aliases of internally interposed sigprocmask() etc. Since e.g. _sigaction is not interposed by libthr, calling signal() removes thr_sighandler() from the handler slot etc. The result was breaking signal semantic and rtld locking. The added __libc_sigprocmask and other symbols are hidden, they are not exported and cannot be called through PLT. The setjmp/longjmp functions for x86 were changed to use direct calls, and since PIC_PROLOGUE only needed for functional PLT indirection on i386, it is removed as well. The PowerPC bug of calling the syscall directly in the setjmp/longjmp implementation is kept as is. Reported by: Pete French <petefrench@ingresso.co.uk> Tested by: Michiel Boland <boland37@xs4all.nl> Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/abort.c6
-rw-r--r--lib/libc/stdlib/system.c22
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index b137e49..022c6aa 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -61,7 +61,7 @@ abort()
* any errors -- ISO C doesn't allow abort to return anyway.
*/
sigdelset(&act.sa_mask, SIGABRT);
- (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
(void)raise(SIGABRT);
/*
@@ -71,9 +71,9 @@ abort()
act.sa_handler = SIG_DFL;
act.sa_flags = 0;
sigfillset(&act.sa_mask);
- (void)_sigaction(SIGABRT, &act, NULL);
+ (void)__libc_sigaction(SIGABRT, &act, NULL);
sigdelset(&act.sa_mask, SIGABRT);
- (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL);
(void)raise(SIGABRT);
exit(1);
}
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index bd9ea5a..2b298e4 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -70,16 +70,20 @@ __libc_system(const char *command)
(void)sigaddset(&newsigblock, SIGCHLD);
(void)sigaddset(&newsigblock, SIGINT);
(void)sigaddset(&newsigblock, SIGQUIT);
- (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
+ (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
switch(pid = vfork()) {
+ /*
+ * In the child, use unwrapped syscalls. libthr is in
+ * undefined state after vfork().
+ */
case -1: /* error */
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
return (-1);
case 0: /* child */
/*
* Restore original signal dispositions and exec the command.
*/
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ (void)__sys_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
_exit(127);
}
@@ -92,16 +96,16 @@ __libc_system(const char *command)
memset(&ign, 0, sizeof(ign));
ign.sa_handler = SIG_IGN;
(void)sigemptyset(&ign.sa_mask);
- (void)_sigaction(SIGINT, &ign, &intact);
- (void)_sigaction(SIGQUIT, &ign, &quitact);
+ (void)__libc_sigaction(SIGINT, &ign, &intact);
+ (void)__libc_sigaction(SIGQUIT, &ign, &quitact);
savedpid = pid;
do {
pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
- (void)_sigaction(SIGINT, &intact, NULL);
- (void)_sigaction(SIGQUIT, &quitact, NULL);
- (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
- return(pid == -1 ? -1 : pstat);
+ (void)__libc_sigaction(SIGINT, &intact, NULL);
+ (void)__libc_sigaction(SIGQUIT, &quitact, NULL);
+ (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
+ return (pid == -1 ? -1 : pstat);
}
__weak_reference(__libc_system, __system);
OpenPOWER on IntegriCloud