Skip to content

Commit

Permalink
pull clearing RESTORE_SIGMASK into block_sigmask()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 1, 2012
1 parent 5754f41 commit a610d6e
Show file tree
Hide file tree
Showing 34 changed files with 130 additions and 387 deletions.
5 changes: 0 additions & 5 deletions arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,6 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
return;
}
block_sigmask(ka, sig);
/* A signal was successfully delivered, and the
saved sigmask was stored on the signal frame,
and will be restored by sigreturn. So we can
simply clear the restore sigmask flag. */
clear_thread_flag(TIF_RESTORE_SIGMASK);
}

static inline void
Expand Down
18 changes: 3 additions & 15 deletions arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
/*
* OK, we're invoking a handler
*/
static int
static void
handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, struct pt_regs *regs)
{
Expand Down Expand Up @@ -559,17 +559,14 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,

if (ret != 0) {
force_sigsegv(sig, tsk);
return ret;
return;
}

/*
* Block the signal if we were successful.
*/
block_sigmask(ka, sig);

tracehook_signal_handler(sig, info, ka, regs, 0);

return 0;
}

/*
Expand Down Expand Up @@ -633,16 +630,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
clear_thread_flag(TIF_SYSCALL_RESTARTSYS);
}

if (handle_signal(signr, &ka, &info, regs) == 0) {
/*
* A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag.
*/
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);
}
handle_signal(signr, &ka, &info, regs);
return;
}

Expand Down
11 changes: 4 additions & 7 deletions arch/avr32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
*/
ret |= !valid_user_regs(regs);

if (ret != 0) {
force_sigsegv(sig, current);
return;
}

/*
* Block the signal if we were successful.
*/
block_sigmask(ka, sig);
clear_thread_flag(TIF_RESTORE_SIGMASK);
if (ret != 0)
force_sigsegv(sig, current);
else
block_sigmask(ka, sig);
}

/*
Expand Down
24 changes: 7 additions & 17 deletions arch/blackfin/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
/*
* OK, we're invoking a handler
*/
static int
static void
handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs)
{
Expand All @@ -260,11 +260,12 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,

/* set up the stack frame */
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret)
return;

if (ret == 0)
block_sigmask(ka, sig);

return ret;
block_sigmask(ka, sig);
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP));
}

/*
Expand All @@ -290,18 +291,7 @@ asmlinkage void do_signal(struct pt_regs *regs)
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, regs) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);

tracehook_signal_handler(signr, &info, &ka, regs,
test_thread_flag(TIF_SINGLESTEP));
}

handle_signal(signr, &info, &ka, regs);
return;
}

Expand Down
23 changes: 6 additions & 17 deletions arch/c6x/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
/*
* handle the actual delivery of a signal to userspace
*/
static int handle_signal(int sig,
static void handle_signal(int sig,
siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs, int syscall)
{
Expand Down Expand Up @@ -277,11 +277,10 @@ static int handle_signal(int sig,
}

/* Set up the stack frame */
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret == 0)
block_sigmask(ka, sig);

return ret;
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
return;
block_sigmask(ka, sig);
tracehook_signal_handler(sig, info, ka, regs, 0);
}

/*
Expand All @@ -300,17 +299,7 @@ static void do_signal(struct pt_regs *regs, int syscall)

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
if (handle_signal(signr, &info, &ka, regs, syscall) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);

tracehook_signal_handler(signr, &info, &ka, regs, 0);
}

handle_signal(signr, &info, &ka, regs, syscall);
return;
}

Expand Down
14 changes: 2 additions & 12 deletions arch/cris/arch-v10/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
* OK, we're invoking a handler
*/

static inline int handle_signal(int canrestart, unsigned long sig,
static inline void handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -458,8 +458,6 @@ static inline int handle_signal(int canrestart, unsigned long sig,

if (ret == 0)
block_sigmask(ka, sig);

return ret;
}

/*
Expand Down Expand Up @@ -492,15 +490,7 @@ void do_signal(int canrestart, struct pt_regs *regs)
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka,
regs)) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);
}
handle_signal(canrestart, signr, &info, &ka, regs);
return;
}

Expand Down
15 changes: 2 additions & 13 deletions arch/cris/arch-v32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
}

/* Invoke a signal handler to, well, handle the signal. */
static inline int
static inline void
handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka,
struct pt_regs * regs)
Expand Down Expand Up @@ -491,8 +491,6 @@ handle_signal(int canrestart, unsigned long sig,

if (ret == 0)
block_sigmask(ka, sig);

return ret;
}

/*
Expand Down Expand Up @@ -525,16 +523,7 @@ do_signal(int canrestart, struct pt_regs *regs)

if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka,
regs)) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);
}

handle_signal(canrestart, signr, &info, &ka, regs);
return;
}

Expand Down
24 changes: 7 additions & 17 deletions arch/frv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
/*
* OK, we're invoking a handler
*/
static int handle_signal(unsigned long sig, siginfo_t *info,
static void handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka)
{
sigset_t *oldset = sigmask_to_save();
Expand Down Expand Up @@ -461,11 +461,12 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
else
ret = setup_frame(sig, ka, oldset);

if (ret == 0)
block_sigmask(ka, sig);

return ret;
if (ret)
return;

block_sigmask(ka, sig);
tracehook_signal_handler(sig, info, ka, __frame,
test_thread_flag(TIF_SINGLESTEP));
} /* end handle_signal() */

/*****************************************************************************/
Expand Down Expand Up @@ -495,18 +496,7 @@ static void do_signal(void)

signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
if (signr > 0) {
if (handle_signal(signr, &info, &ka) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);

tracehook_signal_handler(signr, &info, &ka, __frame,
test_thread_flag(TIF_SINGLESTEP));
}

handle_signal(signr, &info, &ka);
return;
}

Expand Down
4 changes: 1 addition & 3 deletions arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,8 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
else
ret = setup_frame(sig, ka, oldset, regs);

if (!ret) {
if (!ret)
block_sigmask(ka, sig);
clear_thread_flag(TIF_RESTORE_SIGMASK);
}
}

/*
Expand Down
26 changes: 6 additions & 20 deletions arch/hexagon/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,9 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
/*
* Setup invocation of signal handler
*/
static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs)
{
int rc;

/*
* If we're handling a signal that aborted a system call,
* set up the error return value before adding the signal
Expand Down Expand Up @@ -186,15 +184,13 @@ 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
* only set up the rt_frame flavor.
*/
rc = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);

/* If there was an error on setup, no signal was delivered. */
if (rc)
return rc;
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
return;

block_sigmask(ka, sig);

return 0;
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP));
}

/*
Expand All @@ -215,17 +211,7 @@ static void do_signal(struct pt_regs *regs)
signo = get_signal_to_deliver(&info, &sigact, regs, NULL);

if (signo > 0) {
if (handle_signal(signo, &info, &sigact, regs) == 0) {
/*
* Successful delivery case. The saved sigmask is
* stored in the signal frame, and will be restored
* by sigreturn. We can clear the TIF flag.
*/
clear_thread_flag(TIF_RESTORE_SIGMASK);

tracehook_signal_handler(signo, &info, &sigact, regs,
test_thread_flag(TIF_SINGLESTEP));
}
handle_signal(signo, &info, &sigact, regs);
return;
}

Expand Down
10 changes: 1 addition & 9 deletions arch/ia64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,8 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
* Whee! Actually deliver the signal. If the delivery failed, we need to
* continue to iterate in this loop so we can deliver the SIGSEGV...
*/
if (handle_signal(signr, &ka, &info, scr)) {
/*
* A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TS_RESTORE_SIGMASK flag.
*/
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
if (handle_signal(signr, &ka, &info, scr))
return;
}
}

/* Did we come from a system call? */
Expand Down
8 changes: 3 additions & 5 deletions arch/m32r/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static int prev_insn(struct pt_regs *regs)
* OK, we're invoking a handler
*/

static int
static void
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -295,10 +295,9 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,

/* Set up the stack frame */
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs))
return -EFAULT;
return;

block_sigmask(ka, sig);
return 0;
}

/*
Expand Down Expand Up @@ -333,8 +332,7 @@ static void do_signal(struct pt_regs *regs)
*/

/* Whee! Actually deliver the signal. */
if (handle_signal(signr, &ka, &info, regs) == 0)
clear_thread_flag(TIF_RESTORE_SIGMASK);
handle_signal(signr, &ka, &info, regs);

return;
}
Expand Down
Loading

0 comments on commit a610d6e

Please sign in to comment.