Commit a610d6e6 authored by Al Viro's avatar Al Viro

pull clearing RESTORE_SIGMASK into block_sigmask()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 5754f412
......@@ -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
......
......@@ -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)
{
......@@ -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;
}
/*
......@@ -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;
}
......
......@@ -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);
}
/*
......
......@@ -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)
{
......@@ -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));
}
/*
......@@ -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;
}
......
......@@ -248,7 +248,7 @@ do_restart:
/*
* 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)
{
......@@ -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);
}
/*
......@@ -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;
}
......
......@@ -415,7 +415,7 @@ give_sigsegv:
* 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)
{
......@@ -458,8 +458,6 @@ static inline int handle_signal(int canrestart, unsigned long sig,
if (ret == 0)
block_sigmask(ka, sig);
return ret;
}
/*
......@@ -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;
}
......
......@@ -434,7 +434,7 @@ give_sigsegv:
}
/* 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)
......@@ -491,8 +491,6 @@ handle_signal(int canrestart, unsigned long sig,
if (ret == 0)
block_sigmask(ka, sig);
return ret;
}
/*
......@@ -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;
}
......
......@@ -426,7 +426,7 @@ give_sigsegv:
/*
* 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();
......@@ -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() */
/*****************************************************************************/
......@@ -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;
}
......
......@@ -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);
}
}
/*
......
......@@ -149,11 +149,9 @@ sigsegv:
/*
* 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
......@@ -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));
}
/*
......@@ -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;
}
......
......@@ -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? */
......
......@@ -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)
{
......@@ -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;
}
/*
......@@ -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;
}
......
......@@ -1147,8 +1147,6 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
regs->sr &= ~0x8000;
send_sig(SIGTRAP, current, 1);
}
clear_thread_flag(TIF_RESTORE_SIGMASK);
}
/*
......
......@@ -310,7 +310,7 @@ do_restart:
* 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)
{
......@@ -324,11 +324,9 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
ret = setup_rt_frame(sig, ka, NULL, oldset, regs);
if (ret)
return ret;
return;
block_sigmask(ka, sig);
return 0;
}
/*
......@@ -356,16 +354,7 @@ static void do_signal(struct pt_regs *regs, int in_syscall)
/* Whee! Actually deliver the signal. */
if (in_syscall)
handle_restart(regs, &ka, 1);
if (!handle_signal(signr, &ka, &info, oldset, 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 TS_RESTORE_SIGMASK flag.
*/
current_thread_info()->status &=
~TS_RESTORE_SIGMASK;
}
handle_signal(signr, &ka, &info, regs);
return;
}
......
......@@ -514,7 +514,7 @@ struct mips_abi mips_abi = {
.restart = __NR_restart_syscall
};
static int handle_signal(unsigned long sig, siginfo_t *info,
static void handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, struct pt_regs *regs)
{
sigset_t *oldset = sigmask_to_save();
......@@ -551,11 +551,9 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
ka, regs, sig, oldset);
if (ret)
return ret;
return;
block_sigmask(ka, sig);
return ret;
}
static void do_signal(struct pt_regs *regs)
......@@ -575,17 +573,7 @@ static 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);
}
handle_signal(signr, &info, &ka, regs);
return;
}
......
......@@ -462,11 +462,12 @@ static int handle_signal(int sig,
ret = setup_rt_frame(sig, ka, info, oldset, regs);
else
ret = setup_frame(sig, ka, oldset, 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));
}
/*
......@@ -486,15 +487,6 @@ static void do_signal(struct pt_regs *regs)
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
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));
}
return;
......
......@@ -263,8 +263,6 @@ handle_signal(unsigned long sig,
return;
block_sigmask(ka, sig);
clear_thread_flag(TIF_RESTORE_SIGMASK);
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP));
}
......
......@@ -459,6 +459,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
test_thread_flag(TIF_SINGLESTEP) ||
test_thread_flag(TIF_BLOCKSTEP));
DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
regs->gr[28]);
return 1;
}
......@@ -593,13 +596,8 @@ do_signal(struct pt_regs *regs, 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, &info, &ka, regs, in_syscall)) {
DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
regs->gr[28]);
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);
if (handle_signal(signr, &info, &ka, regs, in_syscall))
return;
}
}
/* end of while(1) looping forever if we can't force a signal */
......
......@@ -159,13 +159,6 @@ static int do_signal(struct pt_regs *regs)
regs->trap = 0;
if (ret) {
block_sigmask(&ka, signr);
/*
* A signal was successfully delivered; the saved sigmask is in
* its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
*/
current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
/*
* Let tracing know that we've done the handler setup.
*/
......
......@@ -572,7 +572,7 @@ give_sigsegv:
* OK, we're invoking a handler
*/
int handle_signal32(unsigned long sig, struct k_sigaction *ka,
void handle_signal32(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
{
int ret;
......@@ -583,8 +583,12 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka,
else
ret = setup_frame32(sig, ka, oldset, regs);
if (ret)
return ret;
return;
block_sigmask(ka, sig);
return 0;
/*
* Let tracing know that we've done the handler setup.
*/
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLE_STEP));
}
......@@ -31,7 +31,7 @@ void do_per_trap(struct pt_regs *regs);
void syscall_trace(struct pt_regs *regs, int entryexit);
void kernel_stack_overflow(struct pt_regs * regs);
void do_signal(struct pt_regs *regs);
int handle_signal32(unsigned long sig, struct k_sigaction *ka,
void handle_signal32(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs *regs);
void do_notify_resume(struct pt_regs *regs);
......
......@@ -367,7 +367,7 @@ give_sigsegv:
return -EFAULT;
}
static int handle_signal(unsigned long sig, struct k_sigaction *ka,
static void handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset,
struct pt_regs *regs)
{
......@@ -379,9 +379,13 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
else
ret = setup_frame(sig, ka, oldset, regs);
if (ret)