[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Bug 162774] strace ignores int3 SIGTRAP



Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug.


https://bugzilla.redhat.com/show_bug.cgi?id=162774





--- Comment #10 from Denys Vlasenko <dvlasenk redhat com>  2008-09-24 09:05:15 EDT ---
Created an attachment (id=317582)
 --> (https://bugzilla.redhat.com/attachment.cgi?id=317582)
Kernel patch to make ALL ptrace SIGTRAPs to be affected by
PTRACE_O_TRACESYSGOOD

The idea behind PTRACE_O_TRACESYSGOOD is to make it possible to distinguish
real SIGTRAP (like int3 instruction on x86) and ptrace generated one.

Current wording of ptrace manpage says that PTRACE_O_TRACESYSGOOD should affect
only PTRACE_SYSCALL related traps. This completely negates the whole idea of
PTRACE_O_TRACESYSGOOD, since now we can't detect other SIGTRAPs. In particular,
one which is emitted after successful execve().

I propose to re-formulate ptrace description so that PTRACE_O_TRACESYSGOOD
affects all ptrace-related SIGTRAPs which otherwise would be indistinguishable
from ordinary ones.

The patch implements this. The patch is against current git+utrace patch.

I tested it with strace patched with previously attatched strace patch and
verified that ugly workaround to detect post-execve() SIGTRAP is not needed
anymore.

This is where it is fiexd for utrace:

-       send_sig(SIGTRAP, task, 0);
+       send_sig(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0),
+               task, 0);

and ordinary ptrace:

-       if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) &&
-           unlikely(task_ptrace(current) & PT_PTRACED))
-               send_sig(SIGTRAP, current, 0);
+       /* if PTRACE_O_TRACEEXEC option is active */
+       if (ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0))
+               return;
+       if (unlikely(task_ptrace(current) & PT_PTRACED)) {
+               ptrace_notify_SIGTRAP80();
+       }

Patch also makes other SIGTRAPs send (SIGTRAP | 0x80), like single-stepping.
Not tested.

-- 
Configure bugmail: https://bugzilla.redhat.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]