Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106218
b: refs/heads/master
c: 7bcf6a2
h: refs/heads/master
v: v3
  • Loading branch information
Roland McGrath authored and Linus Torvalds committed Jul 26, 2008
1 parent c3353da commit 661d23d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 283d7559e7712f95a05331eb0a85394c6368101b
refs/heads/master: 7bcf6a2ca5f639b038c48711ebe6c4eca2036641
29 changes: 29 additions & 0 deletions trunk/include/linux/tracehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,33 @@ static inline int tracehook_consider_fatal_signal(struct task_struct *task,
return (task_ptrace(task) & PT_PTRACED) != 0;
}

/**
* tracehook_get_signal - deliver synthetic signal to traced task
* @task: @current
* @regs: task_pt_regs(@current)
* @info: details of synthetic signal
* @return_ka: sigaction for synthetic signal
*
* Return zero to check for a real pending signal normally.
* Return -1 after releasing the siglock to repeat the check.
* Return a signal number to induce an artifical signal delivery,
* setting *@info and *@return_ka to specify its details and behavior.
*
* The @return_ka->sa_handler value controls the disposition of the
* signal, no matter the signal number. For %SIG_DFL, the return value
* is a representative signal to indicate the behavior (e.g. %SIGTERM
* for death, %SIGQUIT for core dump, %SIGSTOP for job control stop,
* %SIGTSTP for stop unless in an orphaned pgrp), but the signal number
* reported will be @info->si_signo instead.
*
* Called with @task->sighand->siglock held, before dequeuing pending signals.
*/
static inline int tracehook_get_signal(struct task_struct *task,
struct pt_regs *regs,
siginfo_t *info,
struct k_sigaction *return_ka)
{
return 0;
}

#endif /* <linux/tracehook.h> */
38 changes: 27 additions & 11 deletions trunk/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,17 +1754,33 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
do_signal_stop(0))
goto relock;

signr = dequeue_signal(current, &current->blocked, info);
if (!signr)
break; /* will return 0 */
/*
* Tracing can induce an artifical signal and choose sigaction.
* The return value in @signr determines the default action,
* but @info->si_signo is the signal number we will report.
*/
signr = tracehook_get_signal(current, regs, info, return_ka);
if (unlikely(signr < 0))
goto relock;
if (unlikely(signr != 0))
ka = return_ka;
else {
signr = dequeue_signal(current, &current->blocked,
info);

if (signr != SIGKILL) {
signr = ptrace_signal(signr, info, regs, cookie);
if (!signr)
continue;
break; /* will return 0 */

if (signr != SIGKILL) {
signr = ptrace_signal(signr, info,
regs, cookie);
if (!signr)
continue;
}

ka = &sighand->action[signr-1];
}

ka = &sighand->action[signr-1];
if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */
continue;
if (ka->sa.sa_handler != SIG_DFL) {
Expand Down Expand Up @@ -1812,7 +1828,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
spin_lock_irq(&sighand->siglock);
}

if (likely(do_signal_stop(signr))) {
if (likely(do_signal_stop(info->si_signo))) {
/* It released the siglock. */
goto relock;
}
Expand All @@ -1833,7 +1849,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,

if (sig_kernel_coredump(signr)) {
if (print_fatal_signals)
print_fatal_signal(regs, signr);
print_fatal_signal(regs, info->si_signo);
/*
* If it was able to dump core, this kills all
* other threads in the group and synchronizes with
Expand All @@ -1842,13 +1858,13 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
* first and our do_group_exit call below will use
* that value and ignore the one we pass it.
*/
do_coredump((long)signr, signr, regs);
do_coredump(info->si_signo, info->si_signo, regs);
}

/*
* Death signals, no core dump.
*/
do_group_exit(signr);
do_group_exit(info->si_signo);
/* NOTREACHED */
}
spin_unlock_irq(&sighand->siglock);
Expand Down

0 comments on commit 661d23d

Please sign in to comment.