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: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2012-05-21 23:33:55 -04:00
parent 4ebefe3ec7
commit 51a7b448d4
32 changed files with 38 additions and 125 deletions

View file

@ -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 (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
restore_saved_sigmask();
if (single_stepping)
ptrace_set_bpt(current); /* re-set breakpoint */
}

View file

@ -663,11 +663,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
set_thread_flag(TIF_SYSCALL_RESTARTSYS);
}
/* If there's no signal to deliver, we just put the saved sigmask
* back.
*/
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
restore_saved_sigmask();
}
asmlinkage void

View file

@ -297,10 +297,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
if (signr == 0) {
/* No signal to deliver -- put the saved sigmask back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
return 0;
}

View file

@ -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
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -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
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -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
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}

View file

@ -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
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
asmlinkage void

View file

@ -536,11 +536,7 @@ static void do_signal(void)
/* if there's no signal to deliver, we just put the saved sigmask
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
} /* end do_signal() */
/*****************************************************************************/

View file

@ -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 (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
restore_saved_sigmask();
}
asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)

View file

@ -259,10 +259,7 @@ static void do_signal(struct pt_regs *regs)
no_restart:
/* If there's no signal to deliver, put the saved sigmask back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)

View file

@ -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
* back */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}

View file

@ -360,10 +360,7 @@ static void do_signal(struct pt_regs *regs)
prev_insn(regs);
}
}
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -1182,10 +1182,7 @@ static void do_signal(struct pt_regs *regs)
handle_restart(regs, NULL, 0);
/* If there's no signal to deliver, we just restore the saved mask. */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs)

View file

@ -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
* back.
*/
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs, int in_syscall)

View file

@ -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
* back
*/
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -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
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -339,11 +339,7 @@ void do_signal(struct pt_regs *regs)
if (signr <= 0) {
/* no signal to deliver so we just put the saved sigmask
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
} else { /* signr > 0 */
sigset_t *oldset;

View file

@ -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",
regs->gr[28]);
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return;
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs, long in_syscall)

View file

@ -132,12 +132,8 @@ static int do_signal(struct pt_regs *regs)
check_syscall_restart(regs, &ka, signr > 0);
if (signr <= 0) {
struct thread_info *ti = current_thread_info();
/* No signal to deliver -- put the saved sigmask back */
if (ti->local_flags & _TLF_RESTORE_SIGMASK) {
ti->local_flags &= ~_TLF_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
regs->trap = 0;
return 0; /* no signals delivered */
}

View file

@ -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 (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs)

View file

@ -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
* back
*/
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
/*

View file

@ -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
* back.
*/
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
}
asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,

View file

@ -143,12 +143,7 @@ static void do_signal(struct pt_regs *regs)
}
/* No signal to deliver -- put the saved sigmask back */
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return;
restore_saved_sigmask();
}
/*

View file

@ -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
* back
*/
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
restore_saved_sigmask();
}
struct sigstack32 {

View file

@ -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
* back
*/
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
set_current_blocked(&current->saved_sigmask);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,

View file

@ -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
* back
*/
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
restore_saved_sigmask();
}
void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)

View file

@ -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 (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
restore_saved_sigmask();
done:
/* Avoid double syscall restart if there are nested signals. */

View file

@ -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
* back
*/
if (!handled_sig && test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
if (!handled_sig)
restore_saved_sigmask();
return handled_sig;
}

View file

@ -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
* sigmask back.
*/
if (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
restore_saved_sigmask();
}
asmlinkage void do_notify_resume(struct pt_regs *regs,

View file

@ -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
* back.
*/
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
set_current_blocked(&current->saved_sigmask);
}
restore_saved_sigmask();
}
/*

View file

@ -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 (test_and_clear_thread_flag(TIF_RESTORE_SIGMASK))
set_current_blocked(&current->saved_sigmask);
restore_saved_sigmask();
if (current->ptrace & PT_SINGLESTEP)
task_pt_regs(current)->icountlevel = 1;

View file

@ -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_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)
{
return kill_pid(cad_pid, sig, priv);