|
From: <sv...@va...> - 2017-03-15 15:23:35
|
Author: petarj
Date: Wed Mar 15 15:23:27 2017
New Revision: 16273
Log:
Add support for syscall ptrace(traceme)
It fixes Bug 377376.
Patch by Aleksandra Karadzic.
Modified:
trunk/coregrind/m_signals.c
trunk/coregrind/m_syswrap/priv_syswrap-linux.h
trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
trunk/coregrind/m_syswrap/syswrap-arm-linux.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
trunk/coregrind/m_syswrap/syswrap-x86-linux.c
trunk/coregrind/pub_core_threadstate.h
trunk/include/vki/vki-linux.h
Modified: trunk/coregrind/m_signals.c
==============================================================================
--- trunk/coregrind/m_signals.c (original)
+++ trunk/coregrind/m_signals.c Wed Mar 15 15:23:27 2017
@@ -1667,6 +1667,7 @@
Bool core = False; /* kills process w/ core */
struct vki_rlimit corelim;
Bool could_core;
+ ThreadState* tst = VG_(get_ThreadState)(tid);
vg_assert(VG_(is_running_thread)(tid));
@@ -1728,6 +1729,12 @@
if (!terminate)
return; /* nothing to do */
+ if (terminate && (tst->ptrace & VKI_PT_PTRACED)
+ && (sigNo != VKI_SIGKILL)) {
+ VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
+ return;
+ }
+
could_core = core;
if (core) {
@@ -1746,7 +1753,6 @@
if (VG_(clo_xml)) {
VG_(printf_xml)("<fatal_signal>\n");
VG_(printf_xml)(" <tid>%d</tid>\n", tid);
- ThreadState* tst = VG_(get_ThreadState)(tid);
if (tst->thread_name) {
VG_(printf_xml)(" <threadname>%s</threadname>\n",
tst->thread_name);
Modified: trunk/coregrind/m_syswrap/priv_syswrap-linux.h
==============================================================================
--- trunk/coregrind/m_syswrap/priv_syswrap-linux.h (original)
+++ trunk/coregrind/m_syswrap/priv_syswrap-linux.h Wed Mar 15 15:23:27 2017
@@ -318,6 +318,7 @@
// Linux-specific (but non-arch-specific) ptrace wrapper helpers
extern void ML_(linux_PRE_getregset) ( ThreadId, long, long );
extern void ML_(linux_PRE_setregset) ( ThreadId, long, long );
+extern void ML_(linux_POST_traceme) ( ThreadId );
extern void ML_(linux_POST_getregset)( ThreadId, long, long );
#undef TId
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-amd64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c Wed Mar 15 15:23:27 2017
@@ -349,6 +349,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/m_syswrap/syswrap-arm-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-arm-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-arm-linux.c Wed Mar 15 15:23:27 2017
@@ -482,6 +482,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Wed Mar 15 15:23:27 2017
@@ -11101,6 +11101,13 @@
------------------------------------------------------------------ */
void
+ML_(linux_POST_traceme) ( ThreadId tid )
+{
+ ThreadState *tst = VG_(get_ThreadState)(tid);
+ tst->ptrace = VKI_PT_PTRACED;
+}
+
+void
ML_(linux_PRE_getregset) ( ThreadId tid, long arg3, long arg4 )
{
struct vki_iovec *iov = (struct vki_iovec *) arg4;
Modified: trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-mips32-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-mips32-linux.c Wed Mar 15 15:23:27 2017
@@ -471,6 +471,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-mips64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-mips64-linux.c Wed Mar 15 15:23:27 2017
@@ -365,6 +365,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-s390x-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-s390x-linux.c Wed Mar 15 15:23:27 2017
@@ -271,6 +271,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-x86-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c Wed Mar 15 15:23:27 2017
@@ -900,6 +900,9 @@
POST(sys_ptrace)
{
switch (ARG1) {
+ case VKI_PTRACE_TRACEME:
+ ML_(linux_POST_traceme)(tid);
+ break;
case VKI_PTRACE_PEEKTEXT:
case VKI_PTRACE_PEEKDATA:
case VKI_PTRACE_PEEKUSR:
Modified: trunk/coregrind/pub_core_threadstate.h
==============================================================================
--- trunk/coregrind/pub_core_threadstate.h (original)
+++ trunk/coregrind/pub_core_threadstate.h Wed Mar 15 15:23:27 2017
@@ -407,6 +407,7 @@
/* This thread's name. NULL, if no name. */
HChar *thread_name;
+ UInt ptrace;
}
ThreadState;
Modified: trunk/include/vki/vki-linux.h
==============================================================================
--- trunk/include/vki/vki-linux.h (original)
+++ trunk/include/vki/vki-linux.h Wed Mar 15 15:23:27 2017
@@ -2324,6 +2324,8 @@
#define VKI_PTRACE_GETREGSET 0x4204
#define VKI_PTRACE_SETREGSET 0x4205
+#define VKI_PT_PTRACED 0x00000001
+
//----------------------------------------------------------------------
// From linux-2.6.14/include/sound/asound.h
//----------------------------------------------------------------------
|
|
Re: [Valgrind-developers] Valgrind: r16273 - in /trunk: coregrind/
coregrind/m_syswrap/ include/vki/
From: Rhys K. <rhy...@gm...> - 2017-03-16 05:30:56
|
On 15 March 2017 at 11:23, <sv...@va...> wrote:
> Author: petarj
> Date: Wed Mar 15 15:23:27 2017
> New Revision: 16273
>
> Log:
> Add support for syscall ptrace(traceme)
>
> It fixes Bug 377376.
>
> Patch by Aleksandra Karadzic.
>
> Modified:
> trunk/coregrind/m_signals.c
> trunk/coregrind/m_syswrap/priv_syswrap-linux.h
> trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
> trunk/coregrind/m_syswrap/syswrap-arm-linux.c
> trunk/coregrind/m_syswrap/syswrap-linux.c
> trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
> trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
> trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
> trunk/coregrind/m_syswrap/syswrap-x86-linux.c
> trunk/coregrind/pub_core_threadstate.h
> trunk/include/vki/vki-linux.h
>
> Modified: trunk/coregrind/m_signals.c
> ============================================================
> ==================
> --- trunk/coregrind/m_signals.c (original)
> +++ trunk/coregrind/m_signals.c Wed Mar 15 15:23:27 2017
> @@ -1667,6 +1667,7 @@
> Bool core = False; /* kills process w/ core */
> struct vki_rlimit corelim;
> Bool could_core;
> + ThreadState* tst = VG_(get_ThreadState)(tid);
>
> vg_assert(VG_(is_running_thread)(tid));
>
> @@ -1728,6 +1729,12 @@
> if (!terminate)
> return; /* nothing to do */
>
> + if (terminate && (tst->ptrace & VKI_PT_PTRACED)
> + && (sigNo != VKI_SIGKILL)) {
> + VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
> + return;
> + }
> +
>
This patch is causing regression test failures on a number of systems,
including Solaris and macOS (i.e. non GNU/Linux).
Refer to the valgrind mailing list for reports similar to:
m_signals.c: In function 'default_action':
m_signals.c:1732:36: error: 'VKI_PT_PTRACED' undeclared (first use in this
function)
if (terminate && (tst->ptrace & VKI_PT_PTRACED)
^
m_signals.c:1732:36: note: each undeclared identifier is reported only once
for each function it appears in
make[3]: *** [libcoregrind_amd64_solaris_a-m_signals.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/libcoregrind_amd64_solaris_a-m_redir.Tpo
.deps/libcoregrind_amd64_solaris_a-m_redir.Po
make[3]: Leaving directory
`/export/home/tester1/nightly/valgrind-new/coregrind'
make[2]: *** [all] Error 2
make[2]: Leaving directory
`/export/home/tester1/nightly/valgrind-new/coregrind'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/export/home/tester1/nightly/valgrind-new'
make: *** [all] Error 2
> could_core = core;
>
> if (core) {
> @@ -1746,7 +1753,6 @@
> if (VG_(clo_xml)) {
> VG_(printf_xml)("<fatal_signal>\n");
> VG_(printf_xml)(" <tid>%d</tid>\n", tid);
> - ThreadState* tst = VG_(get_ThreadState)(tid);
> if (tst->thread_name) {
> VG_(printf_xml)(" <threadname>%s</threadname>\n",
> tst->thread_name);
>
> Modified: trunk/coregrind/m_syswrap/priv_syswrap-linux.h
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/priv_syswrap-linux.h (original)
> +++ trunk/coregrind/m_syswrap/priv_syswrap-linux.h Wed Mar 15 15:23:27
> 2017
> @@ -318,6 +318,7 @@
> // Linux-specific (but non-arch-specific) ptrace wrapper helpers
> extern void ML_(linux_PRE_getregset) ( ThreadId, long, long );
> extern void ML_(linux_PRE_setregset) ( ThreadId, long, long );
> +extern void ML_(linux_POST_traceme) ( ThreadId );
> extern void ML_(linux_POST_getregset)( ThreadId, long, long );
>
> #undef TId
>
> Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-amd64-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c Wed Mar 15 15:23:27
> 2017
> @@ -349,6 +349,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/m_syswrap/syswrap-arm-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-arm-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-arm-linux.c Wed Mar 15 15:23:27 2017
> @@ -482,6 +482,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-linux.c Wed Mar 15 15:23:27 2017
> @@ -11101,6 +11101,13 @@
> ------------------------------------------------------------------ */
>
> void
> +ML_(linux_POST_traceme) ( ThreadId tid )
> +{
> + ThreadState *tst = VG_(get_ThreadState)(tid);
> + tst->ptrace = VKI_PT_PTRACED;
> +}
> +
> +void
> ML_(linux_PRE_getregset) ( ThreadId tid, long arg3, long arg4 )
> {
> struct vki_iovec *iov = (struct vki_iovec *) arg4;
>
> Modified: trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-mips32-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-mips32-linux.c Wed Mar 15 15:23:27
> 2017
> @@ -471,6 +471,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-mips64-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-mips64-linux.c Wed Mar 15 15:23:27
> 2017
> @@ -365,6 +365,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-s390x-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-s390x-linux.c Wed Mar 15 15:23:27
> 2017
> @@ -271,6 +271,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.c
> ============================================================
> ==================
> --- trunk/coregrind/m_syswrap/syswrap-x86-linux.c (original)
> +++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c Wed Mar 15 15:23:27 2017
> @@ -900,6 +900,9 @@
> POST(sys_ptrace)
> {
> switch (ARG1) {
> + case VKI_PTRACE_TRACEME:
> + ML_(linux_POST_traceme)(tid);
> + break;
> case VKI_PTRACE_PEEKTEXT:
> case VKI_PTRACE_PEEKDATA:
> case VKI_PTRACE_PEEKUSR:
>
> Modified: trunk/coregrind/pub_core_threadstate.h
> ============================================================
> ==================
> --- trunk/coregrind/pub_core_threadstate.h (original)
> +++ trunk/coregrind/pub_core_threadstate.h Wed Mar 15 15:23:27 2017
> @@ -407,6 +407,7 @@
>
> /* This thread's name. NULL, if no name. */
> HChar *thread_name;
> + UInt ptrace;
> }
> ThreadState;
>
>
> Modified: trunk/include/vki/vki-linux.h
> ============================================================
> ==================
> --- trunk/include/vki/vki-linux.h (original)
> +++ trunk/include/vki/vki-linux.h Wed Mar 15 15:23:27 2017
> @@ -2324,6 +2324,8 @@
> #define VKI_PTRACE_GETREGSET 0x4204
> #define VKI_PTRACE_SETREGSET 0x4205
>
> +#define VKI_PT_PTRACED 0x00000001
> +
> //----------------------------------------------------------------------
> // From linux-2.6.14/include/sound/asound.h
> //----------------------------------------------------------------------
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
>
|
|
Re: [Valgrind-developers] Valgrind: r16273 - in /trunk: coregrind/
coregrind/m_syswrap/ include/vki/
From: Petar J. <mip...@gm...> - 2017-03-16 13:12:41
|
On Thu, Mar 16, 2017 at 6:30 AM, Rhys Kidd <rhy...@gm...> wrote: > This patch is causing regression test failures on a number of systems, > including Solaris and macOS (i.e. non GNU/Linux). > > Refer to the valgrind mailing list for reports similar to: > > m_signals.c: In function 'default_action': > m_signals.c:1732:36: error: 'VKI_PT_PTRACED' undeclared (first use in this > function) > if (terminate && (tst->ptrace & VKI_PT_PTRACED) > ^ Hopefully, this is now fixed with r16275. Let me know. Thanks. Regards, Petar |
|
Re: [Valgrind-developers] Valgrind: r16273 - in /trunk: coregrind/
coregrind/m_syswrap/ include/vki/
From: Rhys K. <rhy...@gm...> - 2017-03-16 13:23:06
|
On 16 March 2017 at 09:12, Petar Jovanovic <mip...@gm...> wrote: > On Thu, Mar 16, 2017 at 6:30 AM, Rhys Kidd <rhy...@gm...> wrote: > > This patch is causing regression test failures on a number of systems, > > including Solaris and macOS (i.e. non GNU/Linux). > > > > Refer to the valgrind mailing list for reports similar to: > > > > m_signals.c: In function 'default_action': > > m_signals.c:1732:36: error: 'VKI_PT_PTRACED' undeclared (first use in > this > > function) > > if (terminate && (tst->ptrace & VKI_PT_PTRACED) > > ^ > > Hopefully, this is now fixed with r16275. > A quick build test on macOS compiles again after r16275. Thanks. > > Let me know. Thanks. > > Regards, > Petar > |