Commit efee984c authored by Al Viro's avatar Al Viro

new helper: signal_delivered()

Does block_sigmask() + tracehook_signal_handler();  called when
sigframe has been successfully built.  All architectures converted
to it; block_sigmask() itself is gone now (merged into this one).

I'm still not too happy with the signature, but that's a separate
story (IMO we need a structure that would contain signal number +
siginfo + k_sigaction, so that get_signal_to_deliver() would fill one,
signal_delivered(), handle_signal() and probably setup...frame() -
take one).
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 17440f17
...@@ -478,7 +478,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -478,7 +478,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
force_sigsegv(sig, current); force_sigsegv(sig, current);
return; return;
} }
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
static inline void static inline void
......
...@@ -557,12 +557,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -557,12 +557,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
force_sigsegv(sig, tsk); force_sigsegv(sig, tsk);
return; return;
} }
signal_delivered(sig, info, ka, regs, 0);
/*
* Block the signal if we were successful.
*/
block_sigmask(ka, sig);
tracehook_signal_handler(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -241,7 +241,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -241,7 +241,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
if (ret != 0) if (ret != 0)
force_sigsegv(sig, current); force_sigsegv(sig, current);
else else
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -260,8 +260,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -260,8 +260,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -276,8 +276,7 @@ static void handle_signal(int sig, ...@@ -276,8 +276,7 @@ static void handle_signal(int sig,
/* Set up the stack frame */ /* Set up the stack frame */
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
tracehook_signal_handler(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -453,7 +453,7 @@ static inline void handle_signal(int canrestart, unsigned long sig, ...@@ -453,7 +453,7 @@ static inline void handle_signal(int canrestart, unsigned long sig,
ret = setup_frame(sig, ka, oldset, regs); ret = setup_frame(sig, ka, oldset, regs);
if (ret == 0) if (ret == 0)
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -485,7 +485,7 @@ handle_signal(int canrestart, unsigned long sig, ...@@ -485,7 +485,7 @@ handle_signal(int canrestart, unsigned long sig,
ret = setup_frame(sig, ka, oldset, regs); ret = setup_frame(sig, ka, oldset, regs);
if (ret == 0) if (ret == 0)
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -460,8 +460,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -460,8 +460,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, __frame,
tracehook_signal_handler(sig, info, ka, __frame,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} /* end handle_signal() */ } /* end handle_signal() */
......
...@@ -439,7 +439,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -439,7 +439,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
ret = setup_frame(sig, ka, oldset, regs); ret = setup_frame(sig, ka, oldset, regs);
if (!ret) if (!ret)
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -186,8 +186,7 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -186,8 +186,7 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -419,12 +419,7 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -419,12 +419,7 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
if (!setup_frame(sig, ka, info, sigmask_to_save(), scr)) if (!setup_frame(sig, ka, info, sigmask_to_save(), scr))
return 0; return 0;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, &scr->pt,
/*
* Let tracing know that we've done the handler setup.
*/
tracehook_signal_handler(sig, info, ka, &scr->pt,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
return 1; return 1;
......
...@@ -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,
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs)) if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs))
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -1137,7 +1137,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -1137,7 +1137,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
if (err) if (err)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
if (test_thread_flag(TIF_DELAYED_TRACE)) { if (test_thread_flag(TIF_DELAYED_TRACE)) {
regs->sr &= ~0x8000; regs->sr &= ~0x8000;
......
...@@ -323,7 +323,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -323,7 +323,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -551,7 +551,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -551,7 +551,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
......
...@@ -461,8 +461,7 @@ static int handle_signal(int sig, ...@@ -461,8 +461,7 @@ static int handle_signal(int sig,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -259,8 +259,7 @@ handle_signal(unsigned long sig, ...@@ -259,8 +259,7 @@ handle_signal(unsigned long sig,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -449,9 +449,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -449,9 +449,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall)) if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall))
return 0; return 0;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP) || test_thread_flag(TIF_SINGLESTEP) ||
test_thread_flag(TIF_BLOCKSTEP)); test_thread_flag(TIF_BLOCKSTEP));
......
...@@ -148,11 +148,7 @@ static int do_signal(struct pt_regs *regs) ...@@ -148,11 +148,7 @@ static int do_signal(struct pt_regs *regs)
regs->trap = 0; regs->trap = 0;
if (ret) { if (ret) {
block_sigmask(&ka, signr); signal_delivered(signr, &info, &ka, regs,
/*
* Let tracing know that we've done the handler setup.
*/
tracehook_signal_handler(signr, &info, &ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -580,11 +580,7 @@ void handle_signal32(unsigned long sig, struct k_sigaction *ka, ...@@ -580,11 +580,7 @@ void handle_signal32(unsigned long sig, struct k_sigaction *ka,
ret = setup_frame32(sig, ka, oldset, regs); ret = setup_frame32(sig, ka, oldset, regs);
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
/*
* Let tracing know that we've done the handler setup.
*/
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLE_STEP)); test_thread_flag(TIF_SINGLE_STEP));
} }
...@@ -375,11 +375,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -375,11 +375,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
ret = setup_frame(sig, ka, oldset, regs); ret = setup_frame(sig, ka, oldset, regs);
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
/*
* Let tracing know that we've done the handler setup.
*/
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLE_STEP)); test_thread_flag(TIF_SINGLE_STEP));
} }
......
...@@ -267,7 +267,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -267,7 +267,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
if (setup_rt_frame(ka, regs, sig, sigmask_to_save(), info) < 0) if (setup_rt_frame(ka, regs, sig, sigmask_to_save(), info) < 0)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
......
...@@ -533,8 +533,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -533,8 +533,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -650,8 +650,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -650,8 +650,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -785,8 +785,7 @@ static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka, ...@@ -785,8 +785,7 @@ static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka,
if (err) if (err)
return; return;
block_sigmask(ka, signr); signal_delivered(signr, info, ka, regs, 0);
tracehook_signal_handler(signr, info, ka, regs, 0);
} }
static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs, static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs,
......
...@@ -460,8 +460,7 @@ handle_signal(unsigned long signr, struct k_sigaction *ka, ...@@ -460,8 +460,7 @@ handle_signal(unsigned long signr, struct k_sigaction *ka,
if (err) if (err)
return; return;
block_sigmask(ka, signr); signal_delivered(signr, info, ka, regs, 0);
tracehook_signal_handler(signr, info, ka, regs, 0);
} }
static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs, static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
......
...@@ -473,8 +473,7 @@ static inline void handle_signal(unsigned long signr, struct k_sigaction *ka, ...@@ -473,8 +473,7 @@ static inline void handle_signal(unsigned long signr, struct k_sigaction *ka,
if (err) if (err)
return; return;
block_sigmask(ka, signr); signal_delivered(signr, info, ka, regs, 0);
tracehook_signal_handler(signr, info, ka, regs, 0);
} }
static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs, static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
......
...@@ -278,7 +278,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -278,7 +278,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
ret = setup_rt_frame(sig, ka, info, oldset, regs); ret = setup_rt_frame(sig, ka, info, oldset, regs);
if (ret) if (ret)
return; return;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs, 0);
} }
/* /*
......
...@@ -61,7 +61,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr, ...@@ -61,7 +61,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
if (err) if (err)
force_sigsegv(signr, current); force_sigsegv(signr, current);
else else
block_sigmask(ka, signr); signal_delivered(signr, info, ka, regs, 0);
} }
static int kern_do_signal(struct pt_regs *regs) static int kern_do_signal(struct pt_regs *regs)
......
...@@ -362,10 +362,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -362,10 +362,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
return; return;
} }
/* signal_delivered(sig, info, ka, regs, 0);
* Block the signal if we were successful.
*/
block_sigmask(ka, sig);
} }
/* /*
......
...@@ -715,9 +715,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, ...@@ -715,9 +715,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
*/ */
regs->flags &= ~X86_EFLAGS_TF; regs->flags &= ~X86_EFLAGS_TF;
block_sigmask(ka, sig); signal_delivered(sig, info, ka, regs,
tracehook_signal_handler(sig, info, ka, regs,
test_thread_flag(TIF_SINGLESTEP)); test_thread_flag(TIF_SINGLESTEP));
} }
......
...@@ -493,7 +493,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -493,7 +493,7 @@ static void do_signal(struct pt_regs *regs)
if (ret) if (ret)
return; return;
block_sigmask(&ka, signr); signal_delivered(signr, info, ka, regs, 0);
if (current->ptrace & PT_SINGLESTEP) if (current->ptrace & PT_SINGLESTEP)
task_pt_regs(current)->icountlevel = 1; task_pt_regs(current)->icountlevel = 1;
......
...@@ -256,7 +256,7 @@ extern int show_unhandled_signals; ...@@ -256,7 +256,7 @@ extern int show_unhandled_signals;
extern int sigsuspend(sigset_t *); extern int sigsuspend(sigset_t *);
extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
extern void block_sigmask(struct k_sigaction *ka, int signr); extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping);
extern void exit_signals(struct task_struct *tsk); extern void exit_signals(struct task_struct *tsk);
extern struct kmem_cache *sighand_cachep; extern struct kmem_cache *sighand_cachep;
......
...@@ -2368,17 +2368,20 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -2368,17 +2368,20 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
} }
/** /**
* block_sigmask - add @ka's signal mask to current->blocked * signal_delivered -
* @ka: action for @signr * @sig: number of signal being delivered
* @signr: signal that has been successfully delivered * @info: siginfo_t of signal being delivered
* @ka: sigaction setting that chose the handler
* @regs: user register state
* @stepping: nonzero if debugger single-step or block-step in use
* *
* This function should be called when a signal has succesfully been * This function should be called when a signal has succesfully been
* delivered. It adds the mask of signals for @ka to current->blocked * delivered. It updates the blocked signals accordingly (@ka->sa.sa_mask
* so that they are blocked during the execution of the signal * is always blocked, and the signal itself is blocked unless %SA_NODEFER
* handler. In addition, @signr will be blocked unless %SA_NODEFER is * is set in @ka->sa.sa_flags. Tracing is notified.
* set in @ka->sa.sa_flags.
*/ */
void block_sigmask(struct k_sigaction *ka, int signr) void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs, int stepping)
{ {
sigset_t blocked; sigset_t blocked;
...@@ -2390,8 +2393,9 @@ void block_sigmask(struct k_sigaction *ka, int signr) ...@@ -2390,8 +2393,9 @@ void block_sigmask(struct k_sigaction *ka, int signr)
sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask); sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
if (!(ka->sa.sa_flags & SA_NODEFER)) if (!(ka->sa.sa_flags & SA_NODEFER))
sigaddset(&blocked, signr); sigaddset(&blocked, sig);
set_current_blocked(&blocked); set_current_blocked(&blocked);
tracehook_signal_handler(sig, info, ka, regs, stepping);
} }
/* /*
......
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