diff options
author | kib <kib@FreeBSD.org> | 2015-09-05 08:55:51 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-09-05 08:55:51 +0000 |
commit | 438719ab519dd2b4b76f22db4f09fc1ecacd16f4 (patch) | |
tree | d0067728c5e8d2139aa12f79004c5285fec61bba /lib/libc/gen | |
parent | 906861047e3b66a3d4c92eb83ea28b542ca143ff (diff) | |
download | FreeBSD-src-438719ab519dd2b4b76f22db4f09fc1ecacd16f4.zip FreeBSD-src-438719ab519dd2b4b76f22db4f09fc1ecacd16f4.tar.gz |
MFC r287292:
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.
MFC r287300:
Use libthr interposed functions instead of syscalls, in posix_spawn()'
child.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/daemon.c | 8 | ||||
-rw-r--r-- | lib/libc/gen/posix_spawn.c | 9 | ||||
-rw-r--r-- | lib/libc/gen/readpassphrase.c | 37 | ||||
-rw-r--r-- | lib/libc/gen/setmode.c | 5 | ||||
-rw-r--r-- | lib/libc/gen/siginterrupt.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/signal.c | 6 | ||||
-rw-r--r-- | lib/libc/gen/wordexp.c | 9 |
7 files changed, 42 insertions, 39 deletions
diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c index b359a87..15c6f4a 100644 --- a/lib/libc/gen/daemon.c +++ b/lib/libc/gen/daemon.c @@ -41,10 +41,10 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" int -daemon(nochdir, noclose) - int nochdir, noclose; +daemon(int nochdir, int noclose) { struct sigaction osa, sa; int fd; @@ -56,7 +56,7 @@ daemon(nochdir, noclose) sigemptyset(&sa.sa_mask); sa.sa_handler = SIG_IGN; sa.sa_flags = 0; - osa_ok = _sigaction(SIGHUP, &sa, &osa); + osa_ok = __libc_sigaction(SIGHUP, &sa, &osa); switch (fork()) { case -1: @@ -74,7 +74,7 @@ daemon(nochdir, noclose) newgrp = setsid(); oerrno = errno; if (osa_ok != -1) - _sigaction(SIGHUP, &osa, NULL); + __libc_sigaction(SIGHUP, &osa, NULL); if (newgrp == -1) { errno = oerrno; diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index e3124b2..c65a730 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -118,15 +118,18 @@ process_spawnattr(const posix_spawnattr_t sa) return (errno); } - /* Set signal masks/defaults */ + /* + * Set signal masks/defaults. + * Use unwrapped syscall, libthr is in undefined state after vfork(). + */ if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { - _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); + __sys_sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); } if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { for (i = 1; i <= _SIG_MAXSIG; i++) { if (sigismember(&sa->sa_sigdefault, i)) - if (_sigaction(i, &sigact, NULL) != 0) + if (__sys_sigaction(i, &sigact, NULL) != 0) return (errno); } } diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c index 95ae725..60051a1 100644 --- a/lib/libc/gen/readpassphrase.c +++ b/lib/libc/gen/readpassphrase.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <readpassphrase.h> #include "un-namespace.h" +#include "libc_private.h" static volatile sig_atomic_t signo[NSIG]; @@ -104,15 +105,15 @@ restart: sigemptyset(&sa.sa_mask); sa.sa_flags = 0; /* don't restart system calls */ sa.sa_handler = handler; - (void)_sigaction(SIGALRM, &sa, &savealrm); - (void)_sigaction(SIGHUP, &sa, &savehup); - (void)_sigaction(SIGINT, &sa, &saveint); - (void)_sigaction(SIGPIPE, &sa, &savepipe); - (void)_sigaction(SIGQUIT, &sa, &savequit); - (void)_sigaction(SIGTERM, &sa, &saveterm); - (void)_sigaction(SIGTSTP, &sa, &savetstp); - (void)_sigaction(SIGTTIN, &sa, &savettin); - (void)_sigaction(SIGTTOU, &sa, &savettou); + (void)__libc_sigaction(SIGALRM, &sa, &savealrm); + (void)__libc_sigaction(SIGHUP, &sa, &savehup); + (void)__libc_sigaction(SIGINT, &sa, &saveint); + (void)__libc_sigaction(SIGPIPE, &sa, &savepipe); + (void)__libc_sigaction(SIGQUIT, &sa, &savequit); + (void)__libc_sigaction(SIGTERM, &sa, &saveterm); + (void)__libc_sigaction(SIGTSTP, &sa, &savetstp); + (void)__libc_sigaction(SIGTTIN, &sa, &savettin); + (void)__libc_sigaction(SIGTTOU, &sa, &savettou); if (!(flags & RPP_STDIN)) (void)_write(output, prompt, strlen(prompt)); @@ -142,15 +143,15 @@ restart: errno == EINTR && !signo[SIGTTOU]) continue; } - (void)_sigaction(SIGALRM, &savealrm, NULL); - (void)_sigaction(SIGHUP, &savehup, NULL); - (void)_sigaction(SIGINT, &saveint, NULL); - (void)_sigaction(SIGQUIT, &savequit, NULL); - (void)_sigaction(SIGPIPE, &savepipe, NULL); - (void)_sigaction(SIGTERM, &saveterm, NULL); - (void)_sigaction(SIGTSTP, &savetstp, NULL); - (void)_sigaction(SIGTTIN, &savettin, NULL); - (void)_sigaction(SIGTTOU, &savettou, NULL); + (void)__libc_sigaction(SIGALRM, &savealrm, NULL); + (void)__libc_sigaction(SIGHUP, &savehup, NULL); + (void)__libc_sigaction(SIGINT, &saveint, NULL); + (void)__libc_sigaction(SIGQUIT, &savequit, NULL); + (void)__libc_sigaction(SIGPIPE, &savepipe, NULL); + (void)__libc_sigaction(SIGTERM, &saveterm, NULL); + (void)__libc_sigaction(SIGTSTP, &savetstp, NULL); + (void)__libc_sigaction(SIGTTIN, &savettin, NULL); + (void)__libc_sigaction(SIGTTOU, &savettou, NULL); if (input != STDIN_FILENO) (void)_close(input); diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 815cf14..7525567 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #endif #include "un-namespace.h" +#include "libc_private.h" #define SET_LEN 6 /* initial # of bitcmd struct to malloc */ #define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */ @@ -364,9 +365,9 @@ getumask(void) * handler, protect them as best we can. */ sigfillset(&sigset); - (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); + (void)__libc_sigprocmask(SIG_BLOCK, &sigset, &sigoset); (void)umask(mask = umask(0)); - (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &sigoset, NULL); return (mask); } diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c index fde33ca..d99b772 100644 --- a/lib/libc/gen/siginterrupt.c +++ b/lib/libc/gen/siginterrupt.c @@ -43,14 +43,13 @@ __FBSDID("$FreeBSD$"); * after an instance of the indicated signal. */ int -siginterrupt(sig, flag) - int sig, flag; +siginterrupt(int sig, int flag) { extern sigset_t _sigintr __hidden; struct sigaction sa; int ret; - if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0) + if ((ret = __libc_sigaction(sig, (struct sigaction *)0, &sa)) < 0) return (ret); if (flag) { sigaddset(&_sigintr, sig); @@ -59,5 +58,5 @@ siginterrupt(sig, flag) sigdelset(&_sigintr, sig); sa.sa_flags |= SA_RESTART; } - return (_sigaction(sig, &sa, (struct sigaction *)0)); + return (__libc_sigaction(sig, &sa, (struct sigaction *)0)); } diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c index ee96dcc..70e7f17 100644 --- a/lib/libc/gen/signal.c +++ b/lib/libc/gen/signal.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); sigset_t _sigintr __hidden; /* shared with siginterrupt */ sig_t -signal(s, a) - int s; - sig_t a; +signal(int s, sig_t a) { struct sigaction sa, osa; @@ -55,7 +53,7 @@ signal(s, a) sa.sa_flags = 0; if (!sigismember(&_sigintr, s)) sa.sa_flags |= SA_RESTART; - if (_sigaction(s, &sa, &osa) < 0) + if (__libc_sigaction(s, &sa, &osa) < 0) return (SIG_ERR); return (osa.sa_handler); } diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c index c7f4b1d..329044d 100644 --- a/lib/libc/gen/wordexp.c +++ b/lib/libc/gen/wordexp.c @@ -38,6 +38,7 @@ #include <unistd.h> #include <wordexp.h> #include "un-namespace.h" +#include "libc_private.h" __FBSDID("$FreeBSD$"); @@ -127,12 +128,12 @@ we_askshell(const char *words, wordexp_t *we, int flags) return (WRDE_NOSPACE); /* XXX */ (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); - (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); + (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); if ((pid = fork()) < 0) { serrno = errno; _close(pdes[0]); _close(pdes[1]); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); errno = serrno; return (WRDE_NOSPACE); /* XXX */ } @@ -141,7 +142,7 @@ we_askshell(const char *words, wordexp_t *we, int flags) * We are the child; just get /bin/sh to run the wordexp * builtin on `words'. */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); if ((pdes[1] != STDOUT_FILENO ? _dup2(pdes[1], STDOUT_FILENO) : _fcntl(pdes[1], F_SETFD, 0)) < 0) @@ -210,7 +211,7 @@ cleanup: do wpid = _waitpid(pid, &status, 0); while (wpid < 0 && errno == EINTR); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); if (error != 0) { errno = serrno; return (error); |