get_signal_to_deliver() assumes that either tracehook_get_signal() does
nothing (without CONFIG_UTRACE), or it also reports the signal to ptrace
engine implemented on top of utrace. Now that ptrace works independently
this doesn't work.

Change the code to call ptrace_signal() after tracehook_get_signal().

Move ->ptrace check from ptrace_signal() to get_signal_to_deliver(),
we do not want to change *return_ka if it was initialized by utrace
and the task is not traced.

IOW, roughly, ptrace acts as if it is the last attached engine, it
takes the final decision about the signal.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---
 kernel/signal.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 89e691d..d0e0c67 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2006,9 +2006,6 @@ retry:
 static int ptrace_signal(int signr, siginfo_t *info,
                         struct pt_regs *regs, void *cookie)
 {
-       if (!task_ptrace(current))
-               return signr;
-
        ptrace_signal_deliver(regs, cookie);
 
        /* Let the debugger run.  */
@@ -2110,6 +2107,7 @@ relock:
                signr = tracehook_get_signal(current, regs, info, return_ka);
                if (unlikely(signr < 0))
                        goto relock;
+
                if (unlikely(signr != 0))
                        ka = return_ka;
                else {
@@ -2117,18 +2115,18 @@ relock:
                                     GROUP_STOP_PENDING) && do_signal_stop(0))
                                goto relock;
 
-                       signr = dequeue_signal(current, &current->blocked,
-                                              info);
+                       signr = dequeue_signal(current, &current->blocked, 
info);
 
-                       if (!signr)
-                               break; /* will return 0 */
+                       ka = &sighand->action[signr-1];
+               }
 
-                       if (signr != SIGKILL) {
-                               signr = ptrace_signal(signr, info,
-                                                     regs, cookie);
-                               if (!signr)
-                                       continue;
-                       }
+               if (!signr)
+                       break; /* will return 0 */
+
+               if (signr != SIGKILL && current->ptrace) {
+                       signr = ptrace_signal(signr, info, regs, cookie);
+                       if (!signr)
+                               continue;
 
                        ka = &sighand->action[signr-1];
                }
-- 
1.5.5.1


Reply via email to