From: Tom Hughes Date: Wed, 7 Mar 2007 09:48:32 +0000 (+0000) Subject: Handle some additional ptrace reason codes. Based on a patch X-Git-Tag: svn/VALGRIND_3_3_0~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbb98bc70d97e51a6e340f5ffb3284765b442b08;p=thirdparty%2Fvalgrind.git Handle some additional ptrace reason codes. Based on a patch from Magnus Vesterlund . git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6630 --- diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 781d63e018..7d4daa337e 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -517,7 +517,11 @@ PRE(sys_arch_prctl) } // 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(sys_ptrace) 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; } @@ -565,6 +578,15 @@ POST(sys_ptrace) 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. + */ + POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t)); + break; default: break; } diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 081f9a001a..a607251587 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1042,7 +1042,11 @@ PRE(sys_get_thread_area) } // 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(sys_ptrace) 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; } @@ -1101,6 +1114,15 @@ POST(sys_ptrace) 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. + */ + POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t)); + break; default: break; } diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 209d88c4c9..a2903cdc42 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -2091,7 +2091,7 @@ struct vki_console_font_op { typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */ //---------------------------------------------------------------------- -// From linux-2.6.9/include/linux/ptrace.h +// From linux-2.6.20.1/include/linux/ptrace.h //---------------------------------------------------------------------- #define VKI_PTRACE_TRACEME 0 @@ -2100,7 +2100,11 @@ typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory #define VKI_PTRACE_PEEKUSR 3 #define VKI_PTRACE_POKEUSR 6 -#define VKI_PTRACE_DETACH 0x11 +#define VKI_PTRACE_DETACH 17 + +#define VKI_PTRACE_GETEVENTMSG 0x4201 +#define VKI_PTRACE_GETSIGINFO 0x4202 +#define VKI_PTRACE_SETSIGINFO 0x4203 //---------------------------------------------------------------------- // From linux-2.6.14/include/sound/asound.h