public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO
@ 2023-02-24 16:31 Fotios Valasiadis
  2023-02-24 18:53 ` Dmitry V. Levin
  2023-02-25  1:18 ` Alex Colomar
  0 siblings, 2 replies; 35+ messages in thread
From: Fotios Valasiadis @ 2023-02-24 16:31 UTC (permalink / raw)
  To: linux-man
  Cc: alx.manpages, mtk.manpages, Fotios Valasiadis, Fotios Valasiadis

From: Fotios Valasiadis <fvalasiad@csd.auth.gr>

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.

Signed-off-by: Fotios Valasiadis <fvalasiad@gmail.com>
---
 man2/ptrace.2 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/man2/ptrace.2 b/man2/ptrace.2
index 55d9fd36d..b437b4f44 100644
--- a/man2/ptrace.2
+++ b/man2/ptrace.2
@@ -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
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread
* [PATCH] ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO
@ 2023-02-25  2:42 Fotios Valasiadis
  2023-02-25 10:10 ` Dmitry V . Levin
  0 siblings, 1 reply; 35+ messages in thread
From: Fotios Valasiadis @ 2023-02-25  2:42 UTC (permalink / raw)
  To: linux-man; +Cc: alx.manpages, mtk.manpages, Fotios Valasiadis, Dmitry V . Levin

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

Signed-off-by: Fotios Valasiadis <fvalasiad@gmail.com>
Cowritten-by: Dmitry V. Levin <ldv@strace.io>
---
 man2/ptrace.2 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/man2/ptrace.2 b/man2/ptrace.2
index 55d9fd36d..ad0543b0b 100644
--- a/man2/ptrace.2
+++ b/man2/ptrace.2
@@ -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
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread
* [PATCH] ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO
@ 2023-02-25 10:56 Fotios Valasiadis
  2023-02-26 21:58 ` Alejandro Colomar
  2023-02-26 23:22 ` Fotios Valasiadis
  0 siblings, 2 replies; 35+ messages in thread
From: Fotios Valasiadis @ 2023-02-25 10:56 UTC (permalink / raw)
  To: linux-man
  Cc: alx.manpages, mtk.manpages, lineprinter0, Fotios Valasiadis,
	Dmitry V . Levin

Document the role of PTRACE_O_TRACESYSGOOD option in connection with PTRACE_GET_SYSCALL_INFO.

Signed-off-by: Fotios Valasiadis <fvalasiad@gmail.com>
Cowritten-by: Dmitry V. Levin <ldv@strace.io>
Complements: fc91449cb "ptrace.2: Document PTRACE_GET_SYSCALL_INFO"
---
 man2/ptrace.2 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/man2/ptrace.2 b/man2/ptrace.2
index 55d9fd36d..ad0543b0b 100644
--- a/man2/ptrace.2
+++ b/man2/ptrace.2
@@ -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
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2023-03-01 21:00 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 16:31 [PATCH] ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO Fotios Valasiadis
2023-02-24 18:53 ` Dmitry V. Levin
2023-02-24 19:11   ` Φώτης Βαλασιάδης
2023-02-24 22:05     ` Dmitry V. Levin
2023-02-24 23:05       ` Φώτης Βαλασιάδης
2023-02-24 23:31         ` Dmitry V. Levin
2023-02-24 23:43           ` Φώτης Βαλασιάδης
2023-02-25  0:08             ` Dmitry V. Levin
2023-02-25  1:21               ` Alex Colomar
2023-02-25  9:39                 ` Dmitry V. Levin
2023-02-25  1:18 ` Alex Colomar
2023-02-25  1:36   ` Φώτης Βαλασιάδης
2023-02-25  2:07   ` Nate Eldredge
  -- strict thread matches above, loose matches on Subject: below --
2023-02-25  2:42 Fotios Valasiadis
2023-02-25 10:10 ` Dmitry V . Levin
2023-02-25 10:33   ` Φώτης Βαλασιάδης
2023-02-25 10:42     ` Dmitry V . Levin
2023-02-25 10:56 Fotios Valasiadis
2023-02-26 21:58 ` Alejandro Colomar
2023-02-26 22:03   ` Dmitry V . Levin
2023-02-26 22:05     ` Alejandro Colomar
2023-02-26 22:14       ` Φώτης Βαλασιάδης
2023-02-26 22:42         ` Alejandro Colomar
2023-02-26 23:30           ` Φώτης Βαλασιάδης
2023-02-26 23:22 ` Fotios Valasiadis
2023-02-27  0:19   ` Alejandro Colomar
2023-02-27  0:41     ` Φώτης Βαλασιάδης
2023-02-27 13:28       ` Alejandro Colomar
2023-02-27 15:33         ` Dmitry V. Levin
2023-02-27 15:35           ` Alejandro Colomar
     [not found]             ` <b57591a9-5ba1-5192-f376-f2de812a9086@gmail.com>
2023-02-27 18:48               ` Alejandro Colomar
2023-02-27 19:17                 ` Fotios Valasiadis
2023-02-27 19:19                   ` Φώτης Βαλασιάδης
2023-03-01 19:28                     ` Φώτης Βαλασιάδης
2023-03-01 21:00                   ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox