|
From: Magnus V. <mag...@ho...> - 2007-02-19 13:14:38
|
Hi!
Here is a patch against trunk that improves ptrace support on x86 and amd64:
* Only mark output structs as written if the syscall succeeded.
* Adds support for PTRACE_GETEVENTMSG, PTRACE_GETSIGINFO and
PTRACE_SETSIGINFO.
/Magnus
Index: include/vki/vki-linux.h
===================================================================
--- include/vki/vki-linux.h (revision 6605)
+++ include/vki/vki-linux.h (working copy)
@@ -2103,6 +2103,14 @@
#define VKI_PTRACE_DETACH 0x11
//----------------------------------------------------------------------
+// From linux-2.6.20/include/linux/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PTRACE_GETEVENTMSG 0x4201
+#define VKI_PTRACE_GETSIGINFO 0x4202
+#define VKI_PTRACE_SETSIGINFO 0x4203
+
+//----------------------------------------------------------------------
// From linux-2.6.14/include/sound/asound.h
//----------------------------------------------------------------------
Index: coregrind/m_syswrap/syswrap-amd64-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-amd64-linux.c (revision 6605)
+++ coregrind/m_syswrap/syswrap-amd64-linux.c (working copy)
@@ -517,7 +517,11 @@
}
// Parts of this are amd64-specific, but the *PEEK* cases are generic.
-// XXX: Why is the memory pointed to by ARG3 never checked?
+//
+// ARG3 is only used for pointers into the traced process's address space
and
+// for offsets into the traced process's struct user_regs_struct. It is
never a
+// pointer into this process's memory space, and we should therefore not
check
+// anything it points to.
PRE(sys_ptrace)
{
PRINT("sys_ptrace ( %d, %d, %p, %p )", ARG1,ARG2,ARG3,ARG4);
@@ -546,6 +550,15 @@
PRE_MEM_READ( "ptrace(setfpregs)", ARG4,
sizeof (struct vki_user_i387_struct));
break;
+ case VKI_PTRACE_GETEVENTMSG:
+ PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
+ break;
+ case VKI_PTRACE_GETSIGINFO:
+ PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
+ break;
+ case VKI_PTRACE_SETSIGINFO:
+ PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
+ break;
default:
break;
}
@@ -553,6 +566,9 @@
POST(sys_ptrace)
{
+ if (FAILURE)
+ return;
+
switch (ARG1) {
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
@@ -565,6 +581,14 @@
case VKI_PTRACE_GETFPREGS:
POST_MEM_WRITE( ARG4, sizeof (struct vki_user_i387_struct));
break;
+ case VKI_PTRACE_GETEVENTMSG:
+ POST_MEM_WRITE( ARG4, sizeof(unsigned long));
+ break;
+ case VKI_PTRACE_GETSIGINFO:
+ /* XXX: This is a simplification. Different parts of the siginfo_t
are
+ valid depending on the type of signal, see "man sigaction".*/
+ POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
+ break;
default:
break;
}
Index: coregrind/m_syswrap/syswrap-x86-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-x86-linux.c (revision 6605)
+++ coregrind/m_syswrap/syswrap-x86-linux.c (working copy)
@@ -1042,7 +1042,11 @@
}
// Parts of this are x86-specific, but the *PEEK* cases are generic.
-// XXX: Why is the memory pointed to by ARG3 never checked?
+//
+// ARG3 is only used for pointers into the traced process's address space
and
+// for offsets into the traced process's struct user_regs_struct. It is
never a
+// pointer into this process's memory space, and we should therefore not
check
+// anything it points to.
PRE(sys_ptrace)
{
PRINT("sys_ptrace ( %d, %d, %p, %p )", ARG1,ARG2,ARG3,ARG4);
@@ -1079,6 +1083,15 @@
PRE_MEM_READ( "ptrace(setfpxregs)", ARG4,
sizeof(struct vki_user_fxsr_struct) );
break;
+ case VKI_PTRACE_GETEVENTMSG:
+ PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
+ break;
+ case VKI_PTRACE_GETSIGINFO:
+ PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
+ break;
+ case VKI_PTRACE_SETSIGINFO:
+ PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
+ break;
default:
break;
}
@@ -1086,6 +1099,9 @@
POST(sys_ptrace)
{
+ if (FAILURE)
+ return;
+
switch (ARG1) {
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
@@ -1101,6 +1117,14 @@
case VKI_PTRACE_GETFPXREGS:
POST_MEM_WRITE( ARG4, sizeof(struct vki_user_fxsr_struct) );
break;
+ case VKI_PTRACE_GETEVENTMSG:
+ POST_MEM_WRITE( ARG4, sizeof(unsigned long));
+ break;
+ case VKI_PTRACE_GETSIGINFO:
+ /* XXX: This is a simplification. Different parts of the siginfo_t
are
+ valid depending on the type of signal, see "man sigaction".*/
+ POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
+ break;
default:
break;
}
|
|
From: Tom H. <to...@co...> - 2007-02-19 14:06:39
|
In message <BAY...@ph...l>
Magnus Vesterlund <mag...@ho...> wrote:
> * Only mark output structs as written if the syscall succeeded.
This should not be needed - the POST handler is only called if the
system call succeeds (or if the SfPostOnFail flag has been set by
the PRE handler).
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|
|
From: Nicholas N. <nj...@cs...> - 2007-02-19 21:49:07
|
On Mon, 19 Feb 2007, Tom Hughes wrote: >> * Only mark output structs as written if the syscall succeeded. > > This should not be needed - the POST handler is only called if the > system call succeeds (or if the SfPostOnFail flag has been set by > the PRE handler). So the "if (FAILURE)" lines aren't necessary? The rest seems good -- if you agree, Tom, could you commit it? Thanks. Nick |
|
From: Tom H. <th...@cy...> - 2007-03-07 09:49:23
|
In message <BAY...@ph...l>
Magnus Vesterlund <mag...@ho...> wrote:
> Here is a patch against trunk that improves ptrace support on x86 and amd64:
>
> * Only mark output structs as written if the syscall succeeded.
As I said before, this part should not be needed.
> * Adds support for PTRACE_GETEVENTMSG, PTRACE_GETSIGINFO and
> PTRACE_SETSIGINFO.
This has now been committed.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|