Commit 51a7b448 authored by Al Viro's avatar Al Viro

new helper: restore_saved_sigmask()

first fruits of ..._restore_sigmask() helpers: now we can take
boilerplate "signal didn't have a handler, clear RESTORE_SIGMASK
and restore the blocked mask from ->saved_mask" into a common
helper.  Open-coded instances switched...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4ebefe3e
...@@ -572,9 +572,7 @@ do_signal(struct pt_regs * regs, struct switch_stack * sw, ...@@ -572,9 +572,7 @@ do_signal(struct pt_regs * regs, struct switch_stack * sw,
} }
/* If there's no signal to deliver, we just restore the saved mask. */ /* If there's no signal to deliver, we just restore the saved mask. */
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK)) restore_saved_sigmask();
set_current_blocked(&current->saved_sigmask);
if (single_stepping) if (single_stepping)
ptrace_set_bpt(current); /* re-set breakpoint */ ptrace_set_bpt(current); /* re-set breakpoint */
} }
......
...@@ -663,11 +663,7 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -663,11 +663,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
set_thread_flag(TIF_SYSCALL_RESTARTSYS); set_thread_flag(TIF_SYSCALL_RESTARTSYS);
} }
/* If there's no signal to deliver, we just put the saved sigmask restore_saved_sigmask();
* back.
*/
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
} }
asmlinkage void asmlinkage void
......
...@@ -297,10 +297,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall) ...@@ -297,10 +297,7 @@ 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 */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return 0; return 0;
} }
......
...@@ -319,10 +319,7 @@ asmlinkage void do_signal(struct pt_regs *regs) ...@@ -319,10 +319,7 @@ asmlinkage void do_signal(struct pt_regs *regs)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -343,10 +343,7 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -343,10 +343,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -525,8 +525,5 @@ void do_signal(int canrestart, struct pt_regs *regs) ...@@ -525,8 +525,5 @@ void do_signal(int canrestart, struct pt_regs *regs)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
...@@ -560,10 +560,7 @@ do_signal(int canrestart, struct pt_regs *regs) ...@@ -560,10 +560,7 @@ do_signal(int canrestart, struct pt_regs *regs)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
asmlinkage void asmlinkage void
......
...@@ -536,11 +536,7 @@ static void do_signal(void) ...@@ -536,11 +536,7 @@ static void do_signal(void)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} /* end do_signal() */ } /* end do_signal() */
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -501,8 +501,7 @@ statis void do_signal(struct pt_regs *regs) ...@@ -501,8 +501,7 @@ statis void do_signal(struct pt_regs *regs)
} }
/* If there's no signal to deliver, we just restore the saved mask. */ /* If there's no signal to deliver, we just restore the saved mask. */
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK)) restore_saved_sigmask();
set_current_blocked(&current->saved_sigmask);
} }
asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags) asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)
......
...@@ -259,10 +259,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -259,10 +259,7 @@ static void do_signal(struct pt_regs *regs)
no_restart: no_restart:
/* If there's no signal to deliver, put the saved sigmask back */ /* If there's no signal to deliver, put the saved sigmask back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
......
...@@ -538,8 +538,5 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) ...@@ -538,8 +538,5 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
...@@ -360,10 +360,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -360,10 +360,7 @@ static void do_signal(struct pt_regs *regs)
prev_insn(regs); prev_insn(regs);
} }
} }
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -1182,10 +1182,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -1182,10 +1182,7 @@ static void do_signal(struct pt_regs *regs)
handle_restart(regs, NULL, 0); handle_restart(regs, NULL, 0);
/* If there's no signal to deliver, we just restore the saved mask. */ /* If there's no signal to deliver, we just restore the saved mask. */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
void do_notify_resume(struct pt_regs *regs) void do_notify_resume(struct pt_regs *regs)
......
...@@ -381,10 +381,7 @@ static void do_signal(struct pt_regs *regs, int in_syscall) ...@@ -381,10 +381,7 @@ static void do_signal(struct pt_regs *regs, int in_syscall)
* If there's no signal to deliver, we just put the saved sigmask * If there's no signal to deliver, we just put the saved sigmask
* back. * back.
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
void do_notify_resume(struct pt_regs *regs, int in_syscall) void do_notify_resume(struct pt_regs *regs, int in_syscall)
......
...@@ -614,10 +614,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -614,10 +614,7 @@ static void do_signal(struct pt_regs *regs)
* If there's no signal to deliver, we just put the saved sigmask * If there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -525,10 +525,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -525,10 +525,7 @@ static void do_signal(struct pt_regs *regs)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -339,11 +339,7 @@ void do_signal(struct pt_regs *regs) ...@@ -339,11 +339,7 @@ void do_signal(struct pt_regs *regs)
if (signr <= 0) { if (signr <= 0) {
/* no signal to deliver so we just put the saved sigmask /* no signal to deliver so we just put the saved sigmask
* back */ * back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} else { /* signr > 0 */ } else { /* signr > 0 */
sigset_t *oldset; sigset_t *oldset;
......
...@@ -621,12 +621,7 @@ do_signal(struct pt_regs *regs, long in_syscall) ...@@ -621,12 +621,7 @@ do_signal(struct pt_regs *regs, long in_syscall)
DBG(1,"do_signal: Exit (not delivered), regs->gr[28] = %ld\n", DBG(1,"do_signal: Exit (not delivered), regs->gr[28] = %ld\n",
regs->gr[28]); regs->gr[28]);
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return;
} }
void do_notify_resume(struct pt_regs *regs, long in_syscall) void do_notify_resume(struct pt_regs *regs, long in_syscall)
......
...@@ -132,12 +132,8 @@ static int do_signal(struct pt_regs *regs) ...@@ -132,12 +132,8 @@ static int do_signal(struct pt_regs *regs)
check_syscall_restart(regs, &ka, signr > 0); check_syscall_restart(regs, &ka, signr > 0);
if (signr <= 0) { if (signr <= 0) {
struct thread_info *ti = current_thread_info();
/* No signal to deliver -- put the saved sigmask back */ /* No signal to deliver -- put the saved sigmask back */
if (ti->local_flags & _TLF_RESTORE_SIGMASK) { restore_saved_sigmask();
ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
regs->trap = 0; regs->trap = 0;
return 0; /* no signals delivered */ return 0; /* no signals delivered */
} }
......
...@@ -484,10 +484,7 @@ void do_signal(struct pt_regs *regs) ...@@ -484,10 +484,7 @@ void do_signal(struct pt_regs *regs)
/* /*
* If there's no signal to deliver, we just put the saved sigmask back. * If there's no signal to deliver, we just put the saved sigmask back.
*/ */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
void do_notify_resume(struct pt_regs *regs) void do_notify_resume(struct pt_regs *regs)
......
...@@ -337,10 +337,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -337,10 +337,7 @@ static void do_signal(struct pt_regs *regs)
* If there's no signal to deliver, we just put the saved sigmask * If there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
/* /*
......
...@@ -610,10 +610,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) ...@@ -610,10 +610,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
* If there's no signal to deliver, we just put the saved sigmask * If there's no signal to deliver, we just put the saved sigmask
* back. * back.
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
} }
asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0, asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
......
...@@ -143,12 +143,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -143,12 +143,7 @@ static void do_signal(struct pt_regs *regs)
} }
/* No signal to deliver -- put the saved sigmask back */ /* No signal to deliver -- put the saved sigmask back */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return;
} }
/* /*
......
...@@ -872,10 +872,7 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs) ...@@ -872,10 +872,7 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs)
/* If there's no signal to deliver, we just put the saved sigmask /* If there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
} }
struct sigstack32 { struct sigstack32 {
......
...@@ -576,10 +576,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -576,10 +576,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
/* if there's no signal to deliver, we just put the saved sigmask /* if there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) { restore_saved_sigmask();
clear_thread_flag(TIF_RESTORE_SIGMASK);
set_current_blocked(&current->saved_sigmask);
}
} }
void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
......
...@@ -594,10 +594,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0) ...@@ -594,10 +594,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
/* If there's no signal to deliver, we just put the saved sigmask /* If there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
} }
void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags) void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
......
...@@ -350,10 +350,7 @@ void do_signal(struct pt_regs *regs) ...@@ -350,10 +350,7 @@ void do_signal(struct pt_regs *regs)
} }
/* If there's no signal to deliver, just put the saved sigmask back. */ /* If there's no signal to deliver, just put the saved sigmask back. */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
done: done:
/* Avoid double syscall restart if there are nested signals. */ /* Avoid double syscall restart if there are nested signals. */
......
...@@ -130,10 +130,8 @@ static int kern_do_signal(struct pt_regs *regs) ...@@ -130,10 +130,8 @@ static int kern_do_signal(struct pt_regs *regs)
* if there's no signal to deliver, we just put the saved sigmask * if there's no signal to deliver, we just put the saved sigmask
* back * back
*/ */
if (!handled_sig && test_thread_flag(TIF_RESTORE_SIGMASK)) { if (!handled_sig)
clear_thread_flag(TIF_RESTORE_SIGMASK); restore_saved_sigmask();
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return handled_sig; return handled_sig;
} }
......
...@@ -451,8 +451,7 @@ static void do_signal(struct pt_regs *regs, int syscall) ...@@ -451,8 +451,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
/* If there's no signal to deliver, we just put the saved /* If there's no signal to deliver, we just put the saved
* sigmask back. * sigmask back.
*/ */
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK)) restore_saved_sigmask();
set_current_blocked(&current->saved_sigmask);
} }
asmlinkage void do_notify_resume(struct pt_regs *regs, asmlinkage void do_notify_resume(struct pt_regs *regs,
......
...@@ -796,10 +796,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -796,10 +796,7 @@ static void do_signal(struct pt_regs *regs)
* If there's no signal to deliver, we just put the saved sigmask * If there's no signal to deliver, we just put the saved sigmask
* back. * back.
*/ */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) { restore_saved_sigmask();
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
} }
/* /*
......
...@@ -532,8 +532,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -532,8 +532,7 @@ static void do_signal(struct pt_regs *regs)
} }
/* If there's no signal to deliver, we just restore the saved mask. */ /* If there's no signal to deliver, we just restore the saved mask. */
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK)) restore_saved_sigmask();
set_current_blocked(&current->saved_sigmask);
if (current->ptrace & PT_SINGLESTEP) if (current->ptrace & PT_SINGLESTEP)
task_pt_regs(current)->icountlevel = 1; task_pt_regs(current)->icountlevel = 1;
......
...@@ -2207,6 +2207,12 @@ extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group); ...@@ -2207,6 +2207,12 @@ extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long); extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
static inline void restore_saved_sigmask(void)
{
if (test_and_clear_restore_sigmask())
set_current_blocked(&current->saved_sigmask);
}
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