[patch] ptrace-sigfix-2.5.51-A1

Ingo Molnar (mingo@elte.hu)
Thu, 12 Dec 2002 14:35:13 +0100 (CET)


the attached patch, against BK-curr fixes a threading/ptrace bug noticed
by the gdb people: when a thread is ptraced but other threads in the
thread group are not then a SIGTRAP (via int3 or any of the other debug
traps) causes the child thread(s) to die unexpectedly. This is because the
default behavior for a no-handler SIGTRAP is to broadcast it.

The solution is to make all such signals specific, then the ptracer (gdb)
can filter the signal and upon continuation it's being handled properly
(or put on the shared signal queue). SIGKILL and SIGSTOP are an exception.
The patch only affects threaded and ptrace-d processes.

Ingo

--- linux/kernel/signal.c.orig 2002-12-12 13:28:09.000000000 +0100
+++ linux/kernel/signal.c 2002-12-12 13:26:03.000000000 +0100
@@ -939,7 +947,8 @@
if (sig_ignored(p, sig))
goto out_unlock;

- if (sig_kernel_specific(sig))
+ if (sig_kernel_specific(sig) ||
+ ((p->ptrace & PT_PTRACED) && !sig_kernel_only(sig)))
goto out_send;

/* Does any of the threads unblock the signal? */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/