diff mbox

Add Linux PTRACE_EVENT_STOP

Message ID 20170207080605.563-1-kir@openvz.org
State New, archived
Headers show

Commit Message

Kir Kolyshkin Feb. 7, 2017, 8:06 a.m. UTC
Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
comments accordingly.

This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
"ptrace: implement PTRACE_SEIZE") but its value has changed later
in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
PTRACE_EVENT_STOP so that future new options and events can match").

The comment is also taken from the above commit.

This constant is used by e.g. strace, CRIU, Mozilla RR.

2017-02-06  Kir Kolyshkin  <kir@openvz.org>

	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Add PTRACE_EVENT_STOP.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
---
 sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h | 6 ++++--
 sysdeps/unix/sysv/linux/ia64/sys/ptrace.h    | 6 ++++--
 sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h | 6 ++++--
 sysdeps/unix/sysv/linux/s390/sys/ptrace.h    | 6 ++++--
 sysdeps/unix/sysv/linux/sparc/sys/ptrace.h   | 6 ++++--
 sysdeps/unix/sysv/linux/sys/ptrace.h         | 6 ++++--
 sysdeps/unix/sysv/linux/tile/sys/ptrace.h    | 6 ++++--
 7 files changed, 28 insertions(+), 14 deletions(-)

Comments

Dmitry V. Levin Feb. 7, 2017, 8:32 a.m. UTC | #1
On Tue, Feb 07, 2017 at 12:06:05AM -0800, Kir Kolyshkin wrote:
> Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
> comments accordingly.
> 
> This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
> "ptrace: implement PTRACE_SEIZE") but its value has changed later
> in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
> PTRACE_EVENT_STOP so that future new options and events can match").
> 
> The comment is also taken from the above commit.
> 
> This constant is used by e.g. strace, CRIU, Mozilla RR.

JFTR, strace has a workaround for this early PTRACE_EVENT_STOP bug:

#ifdef PTRACE_EVENT_STOP
/* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
# if PTRACE_EVENT_STOP == 7
#  undef PTRACE_EVENT_STOP
# endif
#endif
#ifndef PTRACE_EVENT_STOP
# define PTRACE_EVENT_STOP      128
#endif

> 2017-02-06  Kir Kolyshkin  <kir@openvz.org>
> 
> 	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Add PTRACE_EVENT_STOP.

It should rather be

	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
	Add PTRACE_EVENT_STOP.

> 	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
> 	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.

The whole change LGTM.
Adhemerval Zanella Feb. 7, 2017, 12:17 p.m. UTC | #2
On 07/02/2017 06:32, Dmitry V. Levin wrote:
> On Tue, Feb 07, 2017 at 12:06:05AM -0800, Kir Kolyshkin wrote:
>> Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
>> comments accordingly.
>>
>> This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
>> "ptrace: implement PTRACE_SEIZE") but its value has changed later
>> in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
>> PTRACE_EVENT_STOP so that future new options and events can match").
>>
>> The comment is also taken from the above commit.
>>
>> This constant is used by e.g. strace, CRIU, Mozilla RR.
> 
> JFTR, strace has a workaround for this early PTRACE_EVENT_STOP bug:
> 
> #ifdef PTRACE_EVENT_STOP
> /* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
> # if PTRACE_EVENT_STOP == 7
> #  undef PTRACE_EVENT_STOP
> # endif
> #endif
> #ifndef PTRACE_EVENT_STOP
> # define PTRACE_EVENT_STOP      128
> #endif

For initial patch (3544d72a) it seems that at least for kernel 3.1 and 3.2
the PTRACE_EVENT_STOP for kabi matter is indeed the old value.  However I do
not see a safe way to actually get the expected value without some runtime
check and this is not meant for an glibc abi.

> 
>> 2017-02-06  Kir Kolyshkin  <kir@openvz.org>
>>
>> 	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Add PTRACE_EVENT_STOP.
> 
> It should rather be
> 
> 	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
> 	Add PTRACE_EVENT_STOP.
> 
>> 	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
> 
> The whole change LGTM.

Ack.
Kir Kolyshkin Feb. 8, 2017, 4:32 a.m. UTC | #3
On 02/07/2017 12:32 AM, Dmitry V. Levin wrote:
> On Tue, Feb 07, 2017 at 12:06:05AM -0800, Kir Kolyshkin wrote:
>> Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
>> comments accordingly.
>>
>> This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
>> "ptrace: implement PTRACE_SEIZE") but its value has changed later
>> in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
>> PTRACE_EVENT_STOP so that future new options and events can match").
>>
>> The comment is also taken from the above commit.
>>
>> This constant is used by e.g. strace, CRIU, Mozilla RR.
> JFTR, strace has a workaround for this early PTRACE_EVENT_STOP bug:
>
> #ifdef PTRACE_EVENT_STOP
> /* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
> # if PTRACE_EVENT_STOP == 7
> #  undef PTRACE_EVENT_STOP
> # endif
> #endif
> #ifndef PTRACE_EVENT_STOP
> # define PTRACE_EVENT_STOP      128
> #endif

In CRIU, we just define it to a correct value (and do not include 
linux/ptrace.h
as there can be conflicts between sys/ptrace.h and kernel/ptrace.h; in fact
there is one in musl libc).

Would be good for glibc headers to provide the value though.

>
>> 2017-02-06  Kir Kolyshkin  <kir@openvz.org>
>>
>> 	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Add PTRACE_EVENT_STOP.
> It should rather be
>
> 	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
> 	Add PTRACE_EVENT_STOP.

Thanks! I can send v2, but am not sure if I should, as it is minor
and the patch is already ack'ed.

>
>> 	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
> The whole change LGTM.
>
>
Dmitry V. Levin Feb. 8, 2017, 7:40 a.m. UTC | #4
On Tue, Feb 07, 2017 at 08:32:55PM -0800, Kir Kolyshkin wrote:
> On 02/07/2017 12:32 AM, Dmitry V. Levin wrote:
> >On Tue, Feb 07, 2017 at 12:06:05AM -0800, Kir Kolyshkin wrote:
> >>Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
> >>comments accordingly.
> >>
> >>This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
> >>"ptrace: implement PTRACE_SEIZE") but its value has changed later
> >>in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
> >>PTRACE_EVENT_STOP so that future new options and events can match").
> >>
> >>The comment is also taken from the above commit.
> >>
> >>This constant is used by e.g. strace, CRIU, Mozilla RR.
> >JFTR, strace has a workaround for this early PTRACE_EVENT_STOP bug:
> >
> >#ifdef PTRACE_EVENT_STOP
> >/* Linux 3.1 - 3.3 releases had a broken value.  It was fixed in 3.4.  */
> ># if PTRACE_EVENT_STOP == 7
> >#  undef PTRACE_EVENT_STOP
> ># endif
> >#endif
> >#ifndef PTRACE_EVENT_STOP
> ># define PTRACE_EVENT_STOP      128
> >#endif
> 
> In CRIU, we just define it to a correct value (and do not include 
> linux/ptrace.h
> as there can be conflicts between sys/ptrace.h and kernel/ptrace.h; in fact
> there is one in musl libc).

In strace where both headers are included, there are some workarounds
for conflicting definitions of three structures.

> Would be good for glibc headers to provide the value though.
> 
> >>2017-02-06  Kir Kolyshkin  <kir@openvz.org>
> >>
> >>	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Add 
> >>	PTRACE_EVENT_STOP.
> >It should rather be
> >
> >	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
> >	Add PTRACE_EVENT_STOP.
> 
> Thanks! I can send v2, but am not sure if I should, as it is minor
> and the patch is already ack'ed.

In glibc, ChangeLog file is still maintained manually and the correction
is indeed very minor, so no need for v2.

> >>	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
> >>	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
> >>	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
> >>	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
> >>	* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
> >>	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
> >The whole change LGTM.

Applied, thanks.
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h b/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
index 922346c..c8ca9e3 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
@@ -163,16 +163,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h b/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
index 47f1aad..c77e6dc 100644
--- a/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
@@ -183,16 +183,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
index cf32fa3..ed1ed63 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
@@ -155,16 +155,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/s390/sys/ptrace.h b/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
index 60e8cec..7caf101 100644
--- a/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
@@ -194,16 +194,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h b/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
index 1c07f36..f605494 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
@@ -237,16 +237,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/sys/ptrace.h b/sysdeps/unix/sysv/linux/sys/ptrace.h
index 6900eef..1daadd1 100644
--- a/sysdeps/unix/sysv/linux/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/sys/ptrace.h
@@ -185,16 +185,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */
diff --git a/sysdeps/unix/sysv/linux/tile/sys/ptrace.h b/sysdeps/unix/sysv/linux/tile/sys/ptrace.h
index a710ee9..6287e42 100644
--- a/sysdeps/unix/sysv/linux/tile/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/tile/sys/ptrace.h
@@ -152,16 +152,18 @@  enum __ptrace_setoptions
   PTRACE_O_MASK		= 0x003000ff
 };
 
-/* Wait extended result codes for the above trace options.  */
 enum __ptrace_eventcodes
 {
+/* Wait extended result codes for the above trace options.  */
   PTRACE_EVENT_FORK	= 1,
   PTRACE_EVENT_VFORK	= 2,
   PTRACE_EVENT_CLONE	= 3,
   PTRACE_EVENT_EXEC	= 4,
   PTRACE_EVENT_VFORK_DONE = 5,
   PTRACE_EVENT_EXIT	= 6,
-  PTRACE_EVENT_SECCOMP  = 7
+  PTRACE_EVENT_SECCOMP  = 7,
+/* Extended result codes enabled by means other than options.  */
+  PTRACE_EVENT_STOP	= 128
 };
 
 /* Arguments for PTRACE_PEEKSIGINFO.  */