Commit b7f9a11a authored by Al Viro's avatar Al Viro

new helper: sigmask_to_save()

replace boilerplate "should we use ->saved_sigmask or ->blocked?"
with calls of obvious inlined helper...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 51a7b448
...@@ -468,12 +468,9 @@ static inline void ...@@ -468,12 +468,9 @@ static inline void
handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
struct pt_regs * regs, struct switch_stack *sw) struct pt_regs * regs, struct switch_stack *sw)
{ {
sigset_t *oldset = &current->blocked; sigset_t *oldset = sigmask_to_save();
int ret; int ret;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
if (ka->sa.sa_flags & SA_SIGINFO) if (ka->sa.sa_flags & SA_SIGINFO)
ret = setup_rt_frame(sig, ka, info, oldset, regs, sw); ret = setup_rt_frame(sig, ka, info, oldset, regs, sw);
else else
......
...@@ -530,11 +530,11 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, ...@@ -530,11 +530,11 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
*/ */
static int static int
handle_signal(unsigned long sig, struct k_sigaction *ka, handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, siginfo_t *info, struct pt_regs *regs)
struct pt_regs * regs)
{ {
struct thread_info *thread = current_thread_info(); struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current; struct task_struct *tsk = current;
sigset_t *oldset = sigmask_to_save();
int usig = sig; int usig = sig;
int ret; int ret;
...@@ -617,8 +617,6 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -617,8 +617,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
*/ */
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
sigset_t *oldset;
/* /*
* Depending on the signal settings we may need to revert the * Depending on the signal settings we may need to revert the
* decision to restart the system call. But skip this if a * decision to restart the system call. But skip this if a
...@@ -635,11 +633,7 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -635,11 +633,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
clear_thread_flag(TIF_SYSCALL_RESTARTSYS); clear_thread_flag(TIF_SYSCALL_RESTARTSYS);
} }
if (test_thread_flag(TIF_RESTORE_SIGMASK)) if (handle_signal(signr, &ka, &info, regs) == 0) {
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -224,14 +224,14 @@ static inline void setup_syscall_restart(struct pt_regs *regs) ...@@ -224,14 +224,14 @@ static inline void setup_syscall_restart(struct pt_regs *regs)
static inline void static inline void
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs, int syscall) struct pt_regs *regs, int syscall)
{ {
int ret; int ret;
/* /*
* Set up the stack frame * Set up the stack frame
*/ */
ret = setup_rt_frame(sig, ka, info, oldset, regs); ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
/* /*
* Check that the resulting registers are sane * Check that the resulting registers are sane
...@@ -255,7 +255,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -255,7 +255,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
* doesn't want to handle. Thus you cannot kill init even with a * doesn't want to handle. Thus you cannot kill init even with a
* SIGKILL even by mistake. * SIGKILL even by mistake.
*/ */
int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall) static void do_signal(struct pt_regs *regs, int syscall)
{ {
siginfo_t info; siginfo_t info;
int signr; int signr;
...@@ -267,12 +267,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall) ...@@ -267,12 +267,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
* without doing anything if so. * without doing anything if so.
*/ */
if (!user_mode(regs)) if (!user_mode(regs))
return 0; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else if (!oldset)
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (syscall) { if (syscall) {
...@@ -298,11 +293,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall) ...@@ -298,11 +293,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
if (signr == 0) { if (signr == 0) {
/* No signal to deliver -- put the saved sigmask back */ /* No signal to deliver -- put the saved sigmask back */
restore_saved_sigmask(); restore_saved_sigmask();
return 0; return;
} }
handle_signal(signr, &ka, &info, oldset, regs, syscall); handle_signal(signr, &ka, &info, regs, syscall);
return 1;
} }
asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
...@@ -313,7 +307,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) ...@@ -313,7 +307,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
syscall = 1; syscall = 1;
if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
do_signal(regs, &current->blocked, syscall); do_signal(regs, syscall);
if (ti->flags & _TIF_NOTIFY_RESUME) { if (ti->flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME); clear_thread_flag(TIF_NOTIFY_RESUME);
......
...@@ -249,7 +249,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) ...@@ -249,7 +249,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
*/ */
static int static int
handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
int ret; int ret;
...@@ -259,7 +259,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -259,7 +259,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
handle_restart(regs, ka, 1); handle_restart(regs, ka, 1);
/* set up the stack frame */ /* set up the stack frame */
ret = setup_rt_frame(sig, ka, info, oldset, regs); ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret == 0) if (ret == 0)
block_sigmask(ka, sig); block_sigmask(ka, sig);
...@@ -281,22 +281,16 @@ asmlinkage void do_signal(struct pt_regs *regs) ...@@ -281,22 +281,16 @@ asmlinkage void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
current->thread.esp0 = (unsigned long)regs; current->thread.esp0 = (unsigned long)regs;
if (try_to_freeze()) if (try_to_freeze())
goto no_signal; goto no_signal;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -250,8 +250,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) ...@@ -250,8 +250,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
*/ */
static int handle_signal(int sig, static int handle_signal(int sig,
siginfo_t *info, struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs, struct pt_regs *regs, int syscall)
int syscall)
{ {
int ret; int ret;
...@@ -278,7 +277,7 @@ static int handle_signal(int sig, ...@@ -278,7 +277,7 @@ static int handle_signal(int sig,
} }
/* Set up the stack frame */ /* Set up the stack frame */
ret = setup_rt_frame(sig, ka, info, oldset, regs); ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret == 0) if (ret == 0)
block_sigmask(ka, sig); block_sigmask(ka, sig);
...@@ -292,7 +291,6 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -292,7 +291,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
{ {
struct k_sigaction ka; struct k_sigaction ka;
siginfo_t info; siginfo_t info;
sigset_t *oldset;
int signr; int signr;
/* we want the common case to go fast, which is why we may in certain /* we want the common case to go fast, which is why we may in certain
...@@ -300,15 +298,9 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -300,15 +298,9 @@ static void do_signal(struct pt_regs *regs, int syscall)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset, if (handle_signal(signr, &info, &ka, regs, syscall) == 0) {
regs, syscall) == 0) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -417,8 +417,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -417,8 +417,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
static inline int handle_signal(int canrestart, unsigned long sig, static inline int handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Are we from a system call? */ /* Are we from a system call? */
...@@ -478,7 +479,6 @@ void do_signal(int canrestart, struct pt_regs *regs) ...@@ -478,7 +479,6 @@ void do_signal(int canrestart, struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
...@@ -489,16 +489,11 @@ void do_signal(int canrestart, struct pt_regs *regs) ...@@ -489,16 +489,11 @@ void do_signal(int canrestart, struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka, if (handle_signal(canrestart, signr, &info, &ka,
oldset, regs)) { regs)) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -437,8 +437,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -437,8 +437,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
static inline int static inline int
handle_signal(int canrestart, unsigned long sig, handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs) struct pt_regs * regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Check if this got called from a system call. */ /* Check if this got called from a system call. */
...@@ -511,7 +512,6 @@ do_signal(int canrestart, struct pt_regs *regs) ...@@ -511,7 +512,6 @@ do_signal(int canrestart, struct pt_regs *regs)
int signr; int signr;
siginfo_t info; siginfo_t info;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* The common case should go fast, which is why this point is * The common case should go fast, which is why this point is
...@@ -521,17 +521,12 @@ do_signal(int canrestart, struct pt_regs *regs) ...@@ -521,17 +521,12 @@ do_signal(int canrestart, struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka, if (handle_signal(canrestart, signr, &info, &ka,
oldset, regs)) { regs)) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -427,8 +427,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -427,8 +427,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static int handle_signal(unsigned long sig, siginfo_t *info, static int handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, sigset_t *oldset) struct k_sigaction *ka)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Are we from a system call? */ /* Are we from a system call? */
...@@ -492,14 +493,9 @@ static void do_signal(void) ...@@ -492,14 +493,9 @@ static void do_signal(void)
if (try_to_freeze()) if (try_to_freeze())
goto no_signal; goto no_signal;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, __frame, NULL); signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
if (signr > 0) { if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset) == 0) { if (handle_signal(signr, &info, &ka) == 0) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -412,8 +412,9 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -412,8 +412,9 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
*/ */
static void static void
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs) struct pt_regs * regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* are we from a system call? */ /* are we from a system call? */
if (regs->orig_er0 >= 0) { if (regs->orig_er0 >= 0) {
...@@ -457,7 +458,6 @@ statis void do_signal(struct pt_regs *regs) ...@@ -457,7 +458,6 @@ statis void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
...@@ -473,15 +473,10 @@ statis void do_signal(struct pt_regs *regs) ...@@ -473,15 +473,10 @@ statis void do_signal(struct pt_regs *regs)
current->thread.esp0 = (unsigned long) regs; current->thread.esp0 = (unsigned long) regs;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
handle_signal(signr, &info, &ka, oldset, regs); handle_signal(signr, &info, &ka, regs);
return; return;
} }
no_signal: no_signal:
......
...@@ -150,7 +150,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, ...@@ -150,7 +150,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
* Setup invocation of signal handler * Setup invocation of signal handler
*/ */
static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
int rc; int rc;
...@@ -186,7 +186,7 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -186,7 +186,7 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
* Set up the stack frame; not doing the SA_SIGINFO thing. We * Set up the stack frame; not doing the SA_SIGINFO thing. We
* only set up the rt_frame flavor. * only set up the rt_frame flavor.
*/ */
rc = setup_rt_frame(sig, ka, info, oldset, regs); rc = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
/* If there was an error on setup, no signal was delivered. */ /* If there was an error on setup, no signal was delivered. */
if (rc) if (rc)
...@@ -215,14 +215,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -215,14 +215,7 @@ static void do_signal(struct pt_regs *regs)
signo = get_signal_to_deliver(&info, &sigact, regs, NULL); signo = get_signal_to_deliver(&info, &sigact, regs, NULL);
if (signo > 0) { if (signo > 0) {
sigset_t *oldset; if (handle_signal(signo, &info, &sigact, regs) == 0) {
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
if (handle_signal(signo, &info, &sigact, oldset, regs) == 0) {
/* /*
* Successful delivery case. The saved sigmask is * Successful delivery case. The saved sigmask is
* stored in the signal frame, and will be restored * stored in the signal frame, and will be restored
......
...@@ -415,10 +415,10 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, ...@@ -415,10 +415,10 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set,
} }
static long static long
handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *oldset, handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
struct sigscratch *scr) struct sigscratch *scr)
{ {
if (!setup_frame(sig, ka, info, oldset, scr)) if (!setup_frame(sig, ka, info, sigmask_to_save(), scr))
return 0; return 0;
block_sigmask(ka, sig); block_sigmask(ka, sig);
...@@ -440,7 +440,6 @@ void ...@@ -440,7 +440,6 @@ void
ia64_do_signal (struct sigscratch *scr, long in_syscall) ia64_do_signal (struct sigscratch *scr, long in_syscall)
{ {
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
siginfo_t info; siginfo_t info;
long restart = in_syscall; long restart = in_syscall;
long errno = scr->pt.r8; long errno = scr->pt.r8;
...@@ -453,11 +452,6 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) ...@@ -453,11 +452,6 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
if (!user_mode(&scr->pt)) if (!user_mode(&scr->pt))
return; return;
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
/* /*
* This only loops in the rare cases of handle_signal() failing, in which case we * This only loops in the rare cases of handle_signal() failing, in which case we
* need to push through a forced SIGSEGV. * need to push through a forced SIGSEGV.
...@@ -507,7 +501,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) ...@@ -507,7 +501,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
* Whee! Actually deliver the signal. If the delivery failed, we need to * Whee! Actually deliver the signal. If the delivery failed, we need to
* continue to iterate in this loop so we can deliver the SIGSEGV... * continue to iterate in this loop so we can deliver the SIGSEGV...
*/ */
if (handle_signal(signr, &ka, &info, oldset, scr)) { if (handle_signal(signr, &ka, &info, scr)) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -269,7 +269,7 @@ static int prev_insn(struct pt_regs *regs) ...@@ -269,7 +269,7 @@ static int prev_insn(struct pt_regs *regs)
static int static int
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
/* Are we from a system call? */ /* Are we from a system call? */
if (regs->syscall_nr >= 0) { if (regs->syscall_nr >= 0) {
...@@ -294,7 +294,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -294,7 +294,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
} }
/* Set up the stack frame */ /* Set up the stack frame */
if (setup_rt_frame(sig, ka, info, oldset, regs)) if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs))
return -EFAULT; return -EFAULT;
block_sigmask(ka, sig); block_sigmask(ka, sig);
...@@ -311,7 +311,6 @@ static void do_signal(struct pt_regs *regs) ...@@ -311,7 +311,6 @@ static void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
...@@ -325,11 +324,6 @@ static void do_signal(struct pt_regs *regs) ...@@ -325,11 +324,6 @@ static void do_signal(struct pt_regs *regs)
if (try_to_freeze()) if (try_to_freeze())
goto no_signal; goto no_signal;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Re-enable any watchpoints before delivering the /* Re-enable any watchpoints before delivering the
...@@ -339,7 +333,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -339,7 +333,7 @@ static void do_signal(struct pt_regs *regs)
*/ */
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &ka, &info, oldset, regs) == 0) if (handle_signal(signr, &ka, &info, regs) == 0)
clear_thread_flag(TIF_RESTORE_SIGMASK); clear_thread_flag(TIF_RESTORE_SIGMASK);
return; return;
......
...@@ -1123,8 +1123,9 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) ...@@ -1123,8 +1123,9 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
*/ */
static void static void
handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int err; int err;
/* are we from a system call? */ /* are we from a system call? */
if (regs->orig_d0 >= 0) if (regs->orig_d0 >= 0)
...@@ -1160,19 +1161,13 @@ static void do_signal(struct pt_regs *regs) ...@@ -1160,19 +1161,13 @@ static void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
struct k_sigaction ka; struct k_sigaction ka;
int signr; int signr;
sigset_t *oldset;
current->thread.esp0 = (unsigned long) regs; current->thread.esp0 = (unsigned long) regs;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
handle_signal(signr, &ka, &info, oldset, regs); handle_signal(signr, &ka, &info, regs);
return; return;
} }
......
...@@ -312,8 +312,9 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler) ...@@ -312,8 +312,9 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
static int static int
handle_signal(unsigned long sig, struct k_sigaction *ka, handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) siginfo_t *info, struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Set up the stack frame */ /* Set up the stack frame */
...@@ -344,18 +345,12 @@ static void do_signal(struct pt_regs *regs, int in_syscall) ...@@ -344,18 +345,12 @@ static void do_signal(struct pt_regs *regs, int in_syscall)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
#ifdef DEBUG_SIG #ifdef DEBUG_SIG
printk(KERN_INFO "do signal: %p %d\n", regs, in_syscall); printk(KERN_INFO "do signal: %p %d\n", regs, in_syscall);
printk(KERN_INFO "do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1, printk(KERN_INFO "do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1,
regs->r12, current_thread_info()->flags); regs->r12, current_thread_info()->flags);
#endif #endif
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
......
...@@ -515,8 +515,9 @@ struct mips_abi mips_abi = { ...@@ -515,8 +515,9 @@ struct mips_abi mips_abi = {
}; };
static int handle_signal(unsigned long sig, siginfo_t *info, static int handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs) struct k_sigaction *ka, struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
struct mips_abi *abi = current->thread.abi; struct mips_abi *abi = current->thread.abi;
void *vdso = current->mm->context.vdso; void *vdso = current->mm->context.vdso;
...@@ -560,7 +561,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info, ...@@ -560,7 +561,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
{ {
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
siginfo_t info; siginfo_t info;
int signr; int signr;
...@@ -572,15 +572,10 @@ static void do_signal(struct pt_regs *regs) ...@@ -572,15 +572,10 @@ static void do_signal(struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -430,8 +430,9 @@ static inline void stepback(struct pt_regs *regs) ...@@ -430,8 +430,9 @@ static inline void stepback(struct pt_regs *regs)
*/ */
static int handle_signal(int sig, static int handle_signal(int sig,
siginfo_t *info, struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Are we from a system call? */ /* Are we from a system call? */
...@@ -475,7 +476,6 @@ static void do_signal(struct pt_regs *regs) ...@@ -475,7 +476,6 @@ static void do_signal(struct pt_regs *regs)
{ {
struct k_sigaction ka; struct k_sigaction ka;
siginfo_t info; siginfo_t info;
sigset_t *oldset;
int signr; int signr;
/* we want the common case to go fast, which is why we may in certain /* we want the common case to go fast, which is why we may in certain
...@@ -483,14 +483,9 @@ static void do_signal(struct pt_regs *regs) ...@@ -483,14 +483,9 @@ static void do_signal(struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -254,11 +254,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -254,11 +254,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
static inline int static inline int
handle_signal(unsigned long sig, handle_signal(unsigned long sig,
siginfo_t *info, struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs) struct pt_regs *regs)
{ {
int ret; int ret;
ret = setup_rt_frame(sig, ka, info, oldset, regs); ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret) if (ret)
return ret; return ret;
...@@ -341,15 +341,9 @@ void do_signal(struct pt_regs *regs) ...@@ -341,15 +341,9 @@ void do_signal(struct pt_regs *regs)
* back */ * back */
restore_saved_sigmask(); restore_saved_sigmask();
} else { /* signr > 0 */ } else { /* signr > 0 */
sigset_t *oldset;
if (current_thread_info()->flags & _TIF_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (!handle_signal(signr, &info, &ka, oldset, regs)) { if (!handle_signal(signr, &info, &ka, regs)) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -443,8 +443,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -443,8 +443,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
static long static long
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs, int in_syscall) struct pt_regs *regs, int in_syscall)
{ {
sigset_t *oldset = sigmask_to_save();
DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n", DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n",
sig, ka, info, oldset, regs); sig, ka, info, oldset, regs);
...@@ -568,28 +569,17 @@ do_signal(struct pt_regs *regs, long in_syscall) ...@@ -568,28 +569,17 @@ do_signal(struct pt_regs *regs, long in_syscall)
siginfo_t info; siginfo_t info;
struct k_sigaction ka; struct k_sigaction ka;
int signr; int signr;
sigset_t *oldset;
DBG(1,"\ndo_signal: oldset=0x%p, regs=0x%p, sr7 %#lx, in_syscall=%d\n", DBG(1,"\ndo_signal: regs=0x%p, sr7 %#lx, in_syscall=%d\n",
oldset, regs, regs->sr[7], in_syscall); regs, regs->sr[7], in_syscall);
/* Everyone else checks to see if they are in kernel mode at /* Everyone else checks to see if they are in kernel mode at
this point and exits if that's the case. I'm not sure why this point and exits if that's the case. I'm not sure why
we would be called in that case, but for some reason we we would be called in that case, but for some reason we
are. */ are. */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
DBG(1,"do_signal: oldset %08lx / %08lx\n",
oldset->sig[0], oldset->sig[1]);
/* May need to force signal if handle_signal failed to deliver */ /* May need to force signal if handle_signal failed to deliver */
while (1) { while (1) {
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]);
...@@ -603,8 +593,7 @@ do_signal(struct pt_regs *regs, long in_syscall) ...@@ -603,8 +593,7 @@ do_signal(struct pt_regs *regs, long in_syscall)
/* Whee! Actually deliver the signal. If the /* Whee! Actually deliver the signal. If the
delivery failed, we need to continue to iterate in delivery failed, we need to continue to iterate in
this loop so we can deliver the SIGSEGV... */ this loop so we can deliver the SIGSEGV... */
if (handle_signal(signr, &info, &ka, oldset, if (handle_signal(signr, &info, &ka, regs, in_syscall)) {
regs, in_syscall)) {
DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n", DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
regs->gr[28]); regs->gr[28]);
if (test_thread_flag(TIF_RESTORE_SIGMASK)) if (test_thread_flag(TIF_RESTORE_SIGMASK))
......
...@@ -114,18 +114,13 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka, ...@@ -114,18 +114,13 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
static int do_signal(struct pt_regs *regs) static int do_signal(struct pt_regs *regs)
{ {
sigset_t *oldset; sigset_t *oldset = sigmask_to_save();
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
int ret; int ret;
int is32 = is_32bit_task(); int is32 = is_32bit_task();
if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
/* Is there any syscall restart business here ? */ /* Is there any syscall restart business here ? */
......
...@@ -398,12 +398,7 @@ void do_signal(struct pt_regs *regs) ...@@ -398,12 +398,7 @@ void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset; sigset_t *oldset = sigmask_to_save();
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
/* /*
* Get signal to deliver. When running under ptrace, at this point * Get signal to deliver. When running under ptrace, at this point
......
...@@ -242,7 +242,7 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, ...@@ -242,7 +242,7 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
} }
static int handle_signal(unsigned long sig, siginfo_t *info, static int handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs) struct k_sigaction *ka, struct pt_regs *regs)
{ {
int ret; int ret;
...@@ -269,7 +269,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info, ...@@ -269,7 +269,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
/* /*
* Set up the stack frame * Set up the stack frame
*/ */
ret = setup_rt_frame(ka, regs, sig, oldset, info); ret = setup_rt_frame(ka, regs, sig, sigmask_to_save(), info);
if (ret == 0) if (ret == 0)
block_sigmask(ka, sig); block_sigmask(ka, sig);
...@@ -280,7 +280,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info, ...@@ -280,7 +280,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
{ {
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
siginfo_t info; siginfo_t info;
int signr; int signr;
...@@ -292,15 +291,10 @@ static void do_signal(struct pt_regs *regs) ...@@ -292,15 +291,10 @@ static void do_signal(struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Actually deliver the signal. */ /* Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -524,8 +524,9 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs, ...@@ -524,8 +524,9 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
*/ */
static int static int
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs, unsigned int save_r0) struct pt_regs *regs, unsigned int save_r0)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Set up the stack frame */ /* Set up the stack frame */
...@@ -554,7 +555,6 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) ...@@ -554,7 +555,6 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
...@@ -565,17 +565,12 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) ...@@ -565,17 +565,12 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
handle_syscall_restart(save_r0, regs, &ka.sa); handle_syscall_restart(save_r0, regs, &ka.sa);
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &ka, &info, oldset, if (handle_signal(signr, &ka, &info,
regs, save_r0) == 0) { regs, save_r0) == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
static int static int
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs); struct pt_regs * regs);
static inline void static inline void
handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
...@@ -88,7 +88,6 @@ static void do_signal(struct pt_regs *regs) ...@@ -88,7 +88,6 @@ static void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
...@@ -99,17 +98,12 @@ static void do_signal(struct pt_regs *regs) ...@@ -99,17 +98,12 @@ static void do_signal(struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, 0); signr = get_signal_to_deliver(&info, &ka, regs, 0);
if (signr > 0) { if (signr > 0) {
handle_syscall_restart(regs, &ka.sa); handle_syscall_restart(regs, &ka.sa);
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* /*
* If a signal was successfully delivered, the * If a signal was successfully delivered, the
* saved sigmask is in its frame, and we can * saved sigmask is in its frame, and we can
...@@ -656,8 +650,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -656,8 +650,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
*/ */
static int static int
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs) struct pt_regs * regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Set up the stack frame */ /* Set up the stack frame */
......
...@@ -451,8 +451,9 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, ...@@ -451,8 +451,9 @@ static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
static inline int static inline int
handle_signal(unsigned long signr, struct k_sigaction *ka, handle_signal(unsigned long signr, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) siginfo_t *info, struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int err; int err;
if (ka->sa.sa_flags & SA_SIGINFO) if (ka->sa.sa_flags & SA_SIGINFO)
...@@ -498,7 +499,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -498,7 +499,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
{ {
struct k_sigaction ka; struct k_sigaction ka;
int restart_syscall; int restart_syscall;
sigset_t *oldset;
siginfo_t info; siginfo_t info;
int signr; int signr;
...@@ -523,11 +523,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -523,11 +523,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C))
regs->u_regs[UREG_G6] = orig_i0; regs->u_regs[UREG_G6] = orig_i0;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
/* If the debugger messes with the program counter, it clears /* If the debugger messes with the program counter, it clears
...@@ -544,7 +539,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -544,7 +539,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
if (signr > 0) { if (signr > 0) {
if (restart_syscall) if (restart_syscall)
syscall_restart(orig_i0, regs, &ka.sa); syscall_restart(orig_i0, regs, &ka.sa);
if (handle_signal(signr, &ka, &info, oldset, regs) == 0) { if (handle_signal(signr, &ka, &info, regs) == 0) {
/* a signal was successfully delivered; the saved /* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply * and will be restored by sigreturn, so we can simply
......
...@@ -512,7 +512,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -512,7 +512,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
{ {
struct k_sigaction ka; struct k_sigaction ka;
int restart_syscall; int restart_syscall;
sigset_t *oldset; sigset_t *oldset = sigmask_to_save();
siginfo_t info; siginfo_t info;
int signr; int signr;
...@@ -538,11 +538,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -538,11 +538,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
(regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
regs->u_regs[UREG_G6] = orig_i0; regs->u_regs[UREG_G6] = orig_i0;
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (test_thread_flag(TIF_32BIT)) { if (test_thread_flag(TIF_32BIT)) {
extern void do_signal32(sigset_t *, struct pt_regs *); extern void do_signal32(sigset_t *, struct pt_regs *);
......
...@@ -243,9 +243,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -243,9 +243,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
*/ */
static int handle_signal(unsigned long sig, siginfo_t *info, static int handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, sigset_t *oldset, struct k_sigaction *ka,
struct pt_regs *regs) struct pt_regs *regs)
{ {
sigset_t *oldset = sigmask_to_save();
int ret; int ret;
/* Are we from a system call? */ /* Are we from a system call? */
...@@ -299,7 +300,6 @@ void do_signal(struct pt_regs *regs) ...@@ -299,7 +300,6 @@ void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t *oldset;
/* /*
* i386 will check if we're coming from kernel mode and bail out * i386 will check if we're coming from kernel mode and bail out
...@@ -308,15 +308,10 @@ void do_signal(struct pt_regs *regs) ...@@ -308,15 +308,10 @@ void do_signal(struct pt_regs *regs)
* helpful, we can reinstate the check on "!user_mode(regs)". * helpful, we can reinstate the check on "!user_mode(regs)".
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { if (handle_signal(signr, &info, &ka, regs) == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -23,9 +23,9 @@ EXPORT_SYMBOL(unblock_signals); ...@@ -23,9 +23,9 @@ EXPORT_SYMBOL(unblock_signals);
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static int handle_signal(struct pt_regs *regs, unsigned long signr, static int handle_signal(struct pt_regs *regs, unsigned long signr,
struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka, siginfo_t *info)
sigset_t *oldset)
{ {
sigset_t *oldset = sigmask_to_save();
unsigned long sp; unsigned long sp;
int err; int err;
...@@ -77,14 +77,9 @@ static int kern_do_signal(struct pt_regs *regs) ...@@ -77,14 +77,9 @@ static int kern_do_signal(struct pt_regs *regs)
int sig, handled_sig = 0; int sig, handled_sig = 0;
while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
sigset_t *oldset;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
handled_sig = 1; handled_sig = 1;
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) { if (!handle_signal(regs, sig, &ka_copy, &info)) {
/* /*
* a signal was successfully delivered; the saved * a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame, * sigmask will have been stored in the signal frame,
......
...@@ -313,12 +313,11 @@ static inline void setup_syscall_restart(struct pt_regs *regs) ...@@ -313,12 +313,11 @@ static inline void setup_syscall_restart(struct pt_regs *regs)
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static int handle_signal(unsigned long sig, struct k_sigaction *ka, static int handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, siginfo_t *info, struct pt_regs *regs, int syscall)
struct pt_regs *regs, int syscall)
{ {
struct thread_info *thread = current_thread_info(); struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current; struct task_struct *tsk = current;
sigset_t blocked; sigset_t *oldset = sigmask_to_save();
int usig = sig; int usig = sig;
int ret; int ret;
...@@ -404,13 +403,7 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -404,13 +403,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
sigset_t *oldset; if (handle_signal(signr, &ka, &info, regs, syscall)
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
if (handle_signal(signr, &ka, &info, oldset, regs, syscall)
== 0) { == 0) {
/* /*
* A signal was successfully delivered; the saved * A signal was successfully delivered; the saved
......
...@@ -647,12 +647,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -647,12 +647,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
struct pt_regs *regs) struct pt_regs *regs)
{ {
int usig = signr_convert(sig); int usig = signr_convert(sig);
sigset_t *set = &current->blocked; sigset_t *set = sigmask_to_save();
int ret; int ret;
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
set = &current->saved_sigmask;
/* Set up the stack frame */ /* Set up the stack frame */
if (is_ia32) { if (is_ia32) {
if (ka->sa.sa_flags & SA_SIGINFO) if (ka->sa.sa_flags & SA_SIGINFO)
......
...@@ -452,16 +452,10 @@ static void do_signal(struct pt_regs *regs) ...@@ -452,16 +452,10 @@ static void do_signal(struct pt_regs *regs)
siginfo_t info; siginfo_t info;
int signr; int signr;
struct k_sigaction ka; struct k_sigaction ka;
sigset_t oldset;
if (try_to_freeze()) if (try_to_freeze())
goto no_signal; goto no_signal;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
task_pt_regs(current)->icountlevel = 0; task_pt_regs(current)->icountlevel = 0;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
...@@ -501,7 +495,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -501,7 +495,7 @@ static void do_signal(struct pt_regs *regs)
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
/* Set up the stack frame */ /* Set up the stack frame */
ret = setup_frame(signr, &ka, &info, oldset, regs); ret = setup_frame(signr, &ka, &info, sigmask_to_save(), regs);
if (ret) if (ret)
return; return;
......
...@@ -2213,6 +2213,14 @@ static inline void restore_saved_sigmask(void) ...@@ -2213,6 +2213,14 @@ static inline void restore_saved_sigmask(void)
set_current_blocked(&current->saved_sigmask); set_current_blocked(&current->saved_sigmask);
} }
static inline sigset_t *sigmask_to_save(void)
{
sigset_t *res = &current->blocked;
if (unlikely(test_restore_sigmask()))
res = &current->saved_sigmask;
return res;
}
static inline int kill_cad_pid(int sig, int priv) static inline int kill_cad_pid(int sig, int priv)
{ {
return kill_pid(cad_pid, sig, priv); return kill_pid(cad_pid, sig, priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment