Skip to contentSkip to conversation

ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO

PATCH In review Fotios Valasiadis 4 participants 13 messages Feb 24, 2023 – Feb 25, 2023 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

---
 man2/ptrace.2 | 5 +++++
 1 file changed, 5 insertions(+)
man2/ptrace.2 +5 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
 specified by the
 .I addr
 argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
 .IP
 The
 .I ptrace_syscall_info
Signature · 1 line
2.39.2
#1 lore raw
Quoted 11 lines · Fotios Valasiadis

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Cc'ed Nate just in case.

Quoted 11 lines
---
 man2/ptrace.2 | 5 +++++
 1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
 specified by the

man2/ptrace.2 If the size of the data to be written by the kernel exceeds the size · line 1043

Quoted 10 lines
man2/ptrace.2 +5 -0
 .I addr
 argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
 .IP
 The
 .I ptrace_syscall_info

I suggest the following wording:

man2/ptrace.2 +9 -0
index 55d9fd36d..496d8fae0 100644
@@ -1111,6 +1111,15 @@ stop.
 .B PTRACE_SYSCALL_INFO_NONE
 No component of the union contains relevant information.
 .RE
+.IP
+Note that the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B
+PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
 .\"
 .SS Death under ptrace
 When a (possibly multithreaded) process receives a killing signal

As written in the manual page, using the PTRACE_O_TRACESYSGOOD option is the recommended method to distinguish syscall-stops from other kinds of ptrace-stops, since it is reliable and does not incur a performance penalty. In other words, if you use ptrace(2) at all, please consider using PTRACE_O_TRACESYSGOOD option.

Signature · 1 line
ldv
#2 lore raw

This was during the early days of the program I was implementing, I later found out I needed PTRACE_O_TRACESYSGOOD anyways as the manual suggests. Still it's something that should be documented! Caused a lot of frustration.

Regarding your suggestion, it's great but I have something to point out. In the case of PTRACE_EVENT_SECCOMP the union is filled normally, without any need for the PTRACE_O_TRACESYSGOOD option to be set. So unless I am missing something, please consider including that!

Quoted 65 lines · Dmitry V. Levin
Quoted 11 lines · Fotios Valasiadis

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Cc'ed Nate just in case.

Quoted 11 lines
---
  man2/ptrace.2 | 5 +++++
  1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
  specified by the

man2/ptrace.2 If the size of the data to be written by the kernel exceeds the size · line 1043

Quoted 10 lines
man2/ptrace.2 +5 -0
  .I addr
  argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
  .IP
  The
  .I ptrace_syscall_info

I suggest the following wording:

man2/ptrace.2 +9 -0
index 55d9fd36d..496d8fae0 100644
@@ -1111,6 +1111,15 @@ stop.
  .B PTRACE_SYSCALL_INFO_NONE
  No component of the union contains relevant information.
  .RE
+.IP
+Note that the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B
+PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
  .\"
  .SS Death under ptrace
  When a (possibly multithreaded) process receives a killing signal

As written in the manual page, using the PTRACE_O_TRACESYSGOOD option is the recommended method to distinguish syscall-stops from other kinds of ptrace-stops, since it is reliable and does not incur a performance penalty. In other words, if you use ptrace(2) at all, please consider using PTRACE_O_TRACESYSGOOD option.

#3 lore raw
Quoted 9 lines · Φώτης Βαλασιάδης

This was during the early days of the program I was implementing, I later found out I needed PTRACE_O_TRACESYSGOOD anyways as the manual suggests. Still it's something that should be documented! Caused a lot of frustration.

Regarding your suggestion, it's great but I have something to point out. In the case of PTRACE_EVENT_SECCOMP the union is filled normally, without any need for the PTRACE_O_TRACESYSGOOD option to be set. So unless I am missing something, please consider including that!

Correct, to get PTRACE_SYSCALL_INFO_SECCOMP one has to set PTRACE_O_TRACESECCOMP option, and to get PTRACE_SYSCALL_INFO_ENTRY/PTRACE_SYSCALL_INFO_EXIT one has to set PTRACE_O_TRACESYSGOOD option.

Quoted 66 lines · Dmitry V. Levin
Quoted 65 lines · Fotios Valasiadis
Quoted 11 lines

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Cc'ed Nate just in case.

Quoted 11 lines
---
  man2/ptrace.2 | 5 +++++
  1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
  specified by the

man2/ptrace.2 If the size of the data to be written by the kernel exceeds the size · line 1043

Quoted 10 lines
man2/ptrace.2 +5 -0
  .I addr
  argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
  .IP
  The
  .I ptrace_syscall_info

I suggest the following wording:

man2/ptrace.2 +9 -0
index 55d9fd36d..496d8fae0 100644
@@ -1111,6 +1111,15 @@ stop.
  .B PTRACE_SYSCALL_INFO_NONE
  No component of the union contains relevant information.
  .RE
+.IP
+Note that the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B
+PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
  .\"
  .SS Death under ptrace
  When a (possibly multithreaded) process receives a killing signal

As written in the manual page, using the PTRACE_O_TRACESYSGOOD option is the recommended method to distinguish syscall-stops from other kinds of ptrace-stops, since it is reliable and does not incur a performance penalty. In other words, if you use ptrace(2) at all, please consider using PTRACE_O_TRACESYSGOOD option.

Signature · 1 line
ldv
#4 lore raw

So, what about this?

man2/ptrace.2 +0 -0
index 55d9fd36d..e5f49c289 100644
@@ -1111,6 +1111,16 @@ stop.

 .B PTRACE_SYSCALL_INFO_NONE
 No component of the union contains relevant information. .RE
+.IP
+Note that in case of
+.B PTRACE_SYSCALL
+syscall entry or exit stops, the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred. .\"
 .SS Death under ptrace
 When a (possibly multithreaded) process receives a killing signal

Quoted 81 lines · Dmitry V. Levin
Quoted 9 lines · Φώτης Βαλασιάδης

This was during the early days of the program I was implementing, I later found out I needed PTRACE_O_TRACESYSGOOD anyways as the manual suggests. Still it's something that should be documented! Caused a lot of frustration.

Regarding your suggestion, it's great but I have something to point out. In the case of PTRACE_EVENT_SECCOMP the union is filled normally, without any need for the PTRACE_O_TRACESYSGOOD option to be set. So unless I am missing something, please consider including that!

Correct, to get PTRACE_SYSCALL_INFO_SECCOMP one has to set PTRACE_O_TRACESECCOMP option, and to get PTRACE_SYSCALL_INFO_ENTRY/PTRACE_SYSCALL_INFO_EXIT one has to set PTRACE_O_TRACESYSGOOD option.

Quoted 66 lines · Dmitry V. Levin
Quoted 65 lines · Fotios Valasiadis
Quoted 11 lines

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Cc'ed Nate just in case.

Quoted 11 lines
---
   man2/ptrace.2 | 5 +++++
   1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
   specified by the

man2/ptrace.2 If the size of the data to be written by the kernel exceeds the size · line 1043

Quoted 10 lines
man2/ptrace.2 +5 -0
   .I addr
   argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
   .IP
   The
   .I ptrace_syscall_info

I suggest the following wording:

man2/ptrace.2 +9 -0
index 55d9fd36d..496d8fae0 100644
@@ -1111,6 +1111,15 @@ stop.
   .B PTRACE_SYSCALL_INFO_NONE
   No component of the union contains relevant information.
   .RE
+.IP
+Note that the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B
+PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
   .\"
   .SS Death under ptrace
   When a (possibly multithreaded) process receives a killing signal

As written in the manual page, using the PTRACE_O_TRACESYSGOOD option is the recommended method to distinguish syscall-stops from other kinds of ptrace-stops, since it is reliable and does not incur a performance penalty. In other words, if you use ptrace(2) at all, please consider using PTRACE_O_TRACESYSGOOD option.

#5 lore raw
Quoted 7 lines · Φώτης Βαλασιάδης

So, what about this?

man2/ptrace.2 +0 -0
index 55d9fd36d..e5f49c289 100644

man2/ptrace.2 stop. · line 1117

Quoted 7 lines
man2/ptrace.2 +4 -0
@@ -1111,6 +1111,16 @@ stop.
  .B PTRACE_SYSCALL_INFO_NONE
  No component of the union contains relevant information.
  .RE
+.IP
+Note that in case of
+.B PTRACE_SYSCALL
+syscall entry or exit stops, the data returned by

I'm not sure about mentioning PTRACE_SYSCALL in this context as it's not the only way to have the tracee stopped at a syscall stop.

Quoted 9 lines
man2/ptrace.2 +6 -0
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
  .\"
  .SS Death under ptrace
  When a (possibly multithreaded) process receives a killing signal
Signature · 1 line
ldv
#6 lore raw

Better?

man2/ptrace.2 +0 -0
index 55d9fd36d..ad0543b0b 100644
@@ -1111,6 +1111,15 @@ stop.

 .B PTRACE_SYSCALL_INFO_NONE
 No component of the union contains relevant information. .RE
+.IP
+Note that in case of
+syscall entry or exit stops, the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred. .\"
 .SS Death under ptrace
 When a (possibly multithreaded) process receives a killing signal

Quoted 27 lines · Dmitry V. Levin
Quoted 7 lines · Φώτης Βαλασιάδης

So, what about this?

man2/ptrace.2 +0 -0
index 55d9fd36d..e5f49c289 100644

man2/ptrace.2 stop. · line 1117

Quoted 7 lines
man2/ptrace.2 +4 -0
@@ -1111,6 +1111,16 @@ stop.
   .B PTRACE_SYSCALL_INFO_NONE
   No component of the union contains relevant information.
   .RE
+.IP
+Note that in case of
+.B PTRACE_SYSCALL
+syscall entry or exit stops, the data returned by

I'm not sure about mentioning PTRACE_SYSCALL in this context as it's not the only way to have the tracee stopped at a syscall stop.

Quoted 9 lines
man2/ptrace.2 +6 -0
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
   .\"
   .SS Death under ptrace
   When a (possibly multithreaded) process receives a killing signal
#7 lore raw
Quoted 12 lines · Φώτης Βαλασιάδης

Better?

man2/ptrace.2 +2 -0
index 55d9fd36d..ad0543b0b 100644
@@ -1111,6 +1111,15 @@ stop.
  .B PTRACE_SYSCALL_INFO_NONE
  No component of the union contains relevant information.
  .RE
+.IP
+Note that in case of

man2/ptrace.2 stop. · line 1125

Quoted 10 lines
man2/ptrace.2 +7 -0
+syscall entry or exit stops, the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
  .\"
  .SS Death under ptrace
  When a (possibly multithreaded) process receives a killing signal

LGTM, thanks.

Signature · 1 line
ldv
#8 lore raw

Hi Dmitry!

Quoted 17 lines · Dmitry V. Levin
Quoted 16 lines · Φώτης Βαλασιάδης

Better?

man2/ptrace.2 +6 -0
index 55d9fd36d..ad0543b0b 100644
@@ -1111,6 +1111,15 @@ stop.
   .B PTRACE_SYSCALL_INFO_NONE
   No component of the union contains relevant information.
   .RE
+.IP
+Note that in case of
+syscall entry or exit stops, the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
Quoted 8 lines

man2/ptrace.2 stop. · line 1125

Quoted 6 lines
man2/ptrace.2 +3 -0
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
   .\"
   .SS Death under ptrace
   When a (possibly multithreaded) process receives a killing signal

LGTM, thanks.

Ahh, I see you already CCd Nate. Thanks!

Thanks for the review! I should take that as an Acked-by?

Cheers,

Alex

Quoted 2 lines
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
Reviewed-by
#9 lore raw

Hi Alex,

Quoted 29 lines · Alex Colomar

Hi Dmitry!

Quoted 17 lines · Dmitry V. Levin
Quoted 16 lines · Φώτης Βαλασιάδης

Better?

man2/ptrace.2 +6 -0
index 55d9fd36d..ad0543b0b 100644
@@ -1111,6 +1111,15 @@ stop.
   .B PTRACE_SYSCALL_INFO_NONE
   No component of the union contains relevant information.
   .RE
+.IP
+Note that in case of
+syscall entry or exit stops, the data returned by
+.B PTRACE_GET_SYSCALL_INFO
+is limited to type
+.B PTRACE_SYSCALL_INFO_NONE
Quoted 8 lines

man2/ptrace.2 stop. · line 1125

Quoted 6 lines
man2/ptrace.2 +3 -0
+unless
+.B PTRACE_O_TRACESYSGOOD
+option is set before the corresponding ptrace stop has occurred.
   .\"
   .SS Death under ptrace
   When a (possibly multithreaded) process receives a killing signal

LGTM, thanks.

Quoted 3 lines

Ahh, I see you already CCd Nate. Thanks!

Thanks for the review! I should take that as an Acked-by?

Sure, feel free to add:

Signature · 1 line
ldv
#10 lore raw
In reply to Fotios Valasiadis
Quoted 11 lines · Fotios Valasiadis

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Hello Fotios,

I found his address in a kernel commit:

Nate Eldredge <[email protected]>

I'm CCing him in case he wants to review.

Thanks for the patch!

Alex

Quoted 22 lines
---
  man2/ptrace.2 | 5 +++++
  1 file changed, 5 insertions(+)
man2/ptrace.2 +5 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel exceeds the size
  specified by the
  .I addr
  argument, the output data is truncated.
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
  .IP
  The
  .I ptrace_syscall_info
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
#11 lore raw

Hello Alex!

Good! I will wait a day or two before submitting a new patch the way we agreed with Dmitry! In case Nate responds!

Quoted 49 lines · Alex Colomar
Quoted 11 lines · Fotios Valasiadis

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Hello Fotios,

I found his address in a kernel commit:

Nate Eldredge <[email protected]>

I'm CCing him in case he wants to review.

Thanks for the patch!

Alex

Quoted 23 lines

---
  man2/ptrace.2 | 5 +++++

  1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the 

kernel exceeds the size
  specified by the
  .I addr
  argument, the output data is truncated.

man2/ptrace.2 +5 -0
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.

  .IP
  The
  .I ptrace_syscall_info

#12 lore raw
In reply to Alex Colomar
Quoted 13 lines · Alex Colomar
Quoted 11 lines · Fotios Valasiadis

From: Fotios Valasiadis <[email protected]>

Fixed incomplete doc. PTRACE_GET_SYSCALL_INFO's description wouldn't inform the user that they need to enable PTRACE_O_TRACESYSGOOD to get detailed information from said operation.

Came upon this bug after writing a test program using PTRACE_O_TRACESYSGOOD. After failing to find what's wrong I posted a stackoverflow question which you can find right here: https://stackoverflow.com/questions/72410182/ptrace-get-syscall-info-always-returns-info-op-as-ptrace-syscall-info-none

Nate Eldredge found out what's wrong by looking into the kernel's source code, here is a link to the relevant part https://github.com/torvalds/linux/blob/8291eaafed36f575f23951f3ce18407f480e9ecf/kernel/ptrace.c#L1018

In the code it can be seen that the union is filled if and only if the signal matches "SIGTRAP | 0x80", a signal which is only sent if the PTRACE_O_TRACESYSGOOD option is set. You can read about that in the PTRACE_O_TRACESYSGOOD section of ptrace.2 's manual.

I am unaware if Nate wants to be included as a co-author of this commit, nor am I aware of any way to contact him.

Quoted 7 lines

Hello Fotios,

I found his address in a kernel commit:

Nate Eldredge <[email protected]>

I'm CCing him in case he wants to review.

Hi everyone, I think it's a good clear explanation. Thanks for taking the time to write the patch! No need to include me as coauthor.

Quoted 33 lines

Thanks for the patch!

Alex

Quoted 23 lines
---
  man2/ptrace.2 | 5 +++++
  1 file changed, 5 insertions(+)
man2/ptrace.2 +0 -0
index 55d9fd36d..b437b4f44 100644
@@ -1033,6 +1033,11 @@ If the size of the data to be written by the kernel 

exceeds the size
specified by the
.I addr
argument, the output data is truncated.

man2/ptrace.2 +5 -0
+To obtain complete information during system call entry or exit stops,
+you should enable the
+.B PTRACE_O_TRACESYSGOOD
+option using
+.B PTRACE_SETOPTIONS.
  .IP
  The
  .I ptrace_syscall_info
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
Signature · 2 lines
Nate Eldredge
[email protected]