diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-08-08 12:57:11 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2013-08-08 12:57:11 +1000 |
commit | 072e58983d2272939de4986a06322c258f77d4ef (patch) | |
tree | cbcb55cffeab59c4111d4cfb2bd01f719f8efbf5 /fs | |
parent | a8c81cb28c357bd1d2c4c012d5f765ac1d62c5f0 (diff) |
signals: eventpoll: set ->saved_sigmask at the start
task_struct->saved_sigmask has no meaning unless we return with
set_restore_sigmask() and nobody except current can use it.
This means that sys_epoll_pwait() doesn't need to save ->blocked
into the local var and then memcopy it into ->saved_sigmask, we
can simply set ->saved_sigmask right before set_current_blocked().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Eric Wong <normalperson@yhbt.net>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/eventpoll.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 9ad17b15b454..d5e7de07901f 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1966,23 +1966,23 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, size_t, sigsetsize) { int error; - sigset_t ksigmask, sigsaved; - /* * If the caller wants a certain signal mask to be set during the wait, * we apply it here. */ if (sigmask) { + sigset_t ksigmask; + if (sigsetsize != sizeof(sigset_t)) return -EINVAL; if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask))) return -EFAULT; - sigsaved = current->blocked; + + current->saved_sigmask = current->blocked; set_current_blocked(&ksigmask); } error = sys_epoll_wait(epfd, events, maxevents, timeout); - /* * If we changed the signal mask, we need to restore the original one. * In case we've got a signal while waiting, we do not restore the @@ -1990,12 +1990,10 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, * the way back to userspace, before the signal mask is restored. */ if (sigmask) { - if (error == -EINTR) { - memcpy(¤t->saved_sigmask, &sigsaved, - sizeof(sigsaved)); + if (error == -EINTR) set_restore_sigmask(); - } else - set_current_blocked(&sigsaved); + else + __set_current_blocked(¤t->saved_sigmask); } return error; @@ -2009,25 +2007,25 @@ COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, compat_size_t, sigsetsize) { long err; - compat_sigset_t csigmask; - sigset_t ksigmask, sigsaved; - /* * If the caller wants a certain signal mask to be set during the wait, * we apply it here. */ if (sigmask) { + compat_sigset_t csigmask; + sigset_t ksigmask; + if (sigsetsize != sizeof(compat_sigset_t)) return -EINVAL; if (copy_from_user(&csigmask, sigmask, sizeof(csigmask))) return -EFAULT; sigset_from_compat(&ksigmask, &csigmask); - sigsaved = current->blocked; + + current->saved_sigmask = current->blocked; set_current_blocked(&ksigmask); } err = sys_epoll_wait(epfd, events, maxevents, timeout); - /* * If we changed the signal mask, we need to restore the original one. * In case we've got a signal while waiting, we do not restore the @@ -2035,12 +2033,10 @@ COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, * the way back to userspace, before the signal mask is restored. */ if (sigmask) { - if (err == -EINTR) { - memcpy(¤t->saved_sigmask, &sigsaved, - sizeof(sigsaved)); + if (err == -EINTR) set_restore_sigmask(); - } else - set_current_blocked(&sigsaved); + else + __set_current_blocked(¤t->saved_sigmask); } return err; |