Re: [PATCH] ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Βαλασιάδης Φώτιος,

(did I write your name correctly?
I've seen it previously in the reverse order)

On 2/27/23 00:22, Fotios Valasiadis wrote:
> Document the role of PTRACE_O_TRACESYSGOOD option in connection with PTRACE_GET_SYSCALL_INFO.
> 
> Signed-off-by: Fotios Valasiadis <fvalasiad@xxxxxxxxx>
> Cowritten-by: Dmitry V. Levin <ldv@xxxxxxxxx>
> Complements: fc91449cb "ptrace.2: Document PTRACE_GET_SYSCALL_INFO"

Patch applied.  Thanks!

I tweaked the commit message to include the original one,
which was great.  I forgot to mention this, but please
keep the commit message for revisions of patches; it's
always easier to discard some information later if it's
unnecessary, but usually it's best to keep as much as
possible in the commit message.

> ---
>  man2/ptrace.2 | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/man2/ptrace.2 b/man2/ptrace.2
> index 55d9fd36d..9737b3825 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
> +In case of system call 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 system call stop has occurred.
>  .\"
>  .SS Death under ptrace
>  When a (possibly multithreaded) process receives a killing signal

On 2/27/23 00:30, Φώτης Βαλασιάδης wrote:
> Tried my best, hope I did it right!
> 
> Thanks for the assist!
> 
> And yes, it's Greek!

:-)

> Signing off with my github username most of the time.

Okay.

> 
> Thanks again, here you go!
> 
> Βαλασιάδης Φώτιος

The applied patch is below:

$ git show
commit f04064d73b9f60f189c490e7ef5c3b9fa5498920 (HEAD -> master)
Author: Fotios Valasiadis <fvalasiad@xxxxxxxxx>
Date:   Mon Feb 27 01:22:01 2023 +0200

    ptrace.2: Add details about usage of PTRACE_GET_SYSCALL_INFO
    
    Document the role of PTRACE_O_TRACESYSGOOD option in connection with
    PTRACE_GET_SYSCALL_INFO.
    
    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.
    
    Complements: fc91449cb "ptrace.2: Document PTRACE_GET_SYSCALL_INFO"
    Cowritten-by: Dmitry V. Levin <ldv@xxxxxxxxx>
    Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxx>
    Signed-off-by: Fotios Valasiadis <fvalasiad@xxxxxxxxx>
    Acked-by: Nate Eldredge <nate@xxxxxxxxxxxxxxxxxxxx>
    Cc: Elvira Khabirova <lineprinter0@xxxxxxxxx>
    Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>

diff --git a/man2/ptrace.2 b/man2/ptrace.2
index 55d9fd36d..9737b3825 100644
--- a/man2/ptrace.2
+++ b/man2/ptrace.2
@@ -1111,6 +1111,15 @@ .SH DESCRIPTION
 .B PTRACE_SYSCALL_INFO_NONE
 No component of the union contains relevant information.
 .RE
+.IP
+In case of system call 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 system call stop has occurred.
 .\"
 .SS Death under ptrace
 When a (possibly multithreaded) process receives a killing signal



Please confirm if you want me to push it like that, or if there's anything
you'd like to tweak.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux