From: Pierre Morel <pmorel@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, oleg@tv-sign.ru, roland@redhat.com,
heicars2@linux.vnet.ibm.com, sameske@linux.vnet.ibm.com,
schwidefsky@de.ibm.com, mingo@elte.hu, gregkh@suse.de,
user-mode-linux-devel@lists.sourceforge.net,
dave@linux.vnet.ibm.com, clg@fr.ibm.com, dlezcano@fr.ibm.com,
Michael Kerrisk <mtk.manpages@googlemail.com>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/1] system call notification with self_ptrace
Date: Wed, 10 Sep 2008 16:17:31 +0200 [thread overview]
Message-ID: <48C7D6FB.3050207@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080908170427.c8bf38f5.akpm@linux-foundation.org>
Hi,
Andrew Morton wrote:
> On Mon, 08 Sep 2008 14:02:01 +0200
> Pierre Morel <pmorel@linux.vnet.ibm.com> wrote:
>
>
>> Subject: [PATCH] system call notification with self_ptrace
>>
>> From: Pierre Morel <pmorel@fr.ibm.com>
>>
>>
>> PTRACE SELF
>>
>> This patch adds a new functionality to ptrace: system call notification to
>> the current process.
>> When a process requests self ptrace, with the new request PTRACE_SELF_ON:
>>
>> 1. the next system call performed by the process will not be executed
>> 2. self ptrace will be disabled for the process
>> 3. a SIGSYS signal will be sent to the process.
>>
>> With an appropriate SIGSYS signal handler, the process can access its own
>> data structures to
>>
>> 1. get the system call number from the siginfo structure
>> 2. get the system call arguments from the stack
>> 3. instrument the system call with other system calls
>> 4. emulate the system call with other system calls
>> 5. change the arguments of the system call
>> 6. perform the system call for good
>> 7. change the return value of the system call
>> 8. request self ptrace again before returning.
>>
>> The new request PTRACE_SELF_OFF disables self ptrace.
>>
>>
>
> It sounds like it might be useful.
>
Thanks, yes I am sure it might.
> Are there any userspace tools available with which people can utilise
> this new functionality? Or plans to release them?
>
Yes, we plan to release a tool to trace an application soon.
>
>> arch/s390/kernel/ptrace.c | 16 ++++++++++++++++
>> arch/s390/kernel/signal.c | 5 +++++
>> arch/x86/kernel/ptrace.c | 29 +++++++++++++++++++++++++++++
>> arch/x86/kernel/signal_32.c | 5 +++++
>> arch/x86/kernel/signal_64.c | 5 +++++
>>
>
> Maintainers of the other 30-odd architectures would appreciate a test
> application which they can use to develop and test their ports, please.
>
Yes, of course I have one for x86 and one for s390.
I am cleaning them to make them available.
> Michael Kerrisk will no doubt be looking for manpage assistance.
> Please cc him on this material.
>
OK, I will prepare this.
> It would be good to get suitable testcases integrated into LTP (if LTP
> has ptrace tests).
>
Yes, I will prepare this too.
> The patch title uses the term "self_ptrace", but the patch itself uses
> the term "ptrace_self". Let's get it consistent everywhere.
>
Right. It should be self_ptrace.
> The patch adds a
>
> + u64 instrumentation;
>
> to the task_struct but no explanation is provided as to why this was
> added, why it is a 64-bit field, what its locking rules are, etc.
> Please fix this.
>
I used to steal one bit in the ptrace bit-field of the task_struct but
Oleg pointed out that the ptrace bit-field is used in a lot of places
without any bit mask, so I chose another way to remember that I (the
thread) am instrumenting myself.
Alternatively, I could also use the ptrace bit-field and modify every
reference to use a mask for any test, set or reset of the bit-field.
I provision a 64 bit wide bit-field for future extensions of the
instrumentation. I could of course use a smaller bit-field as only 1
bit is really useful for now. I used 64 bit to be memory aligned with
most of the architectures.
There is no lock for the instrumentation bit-field because it is used
for self tracing only, and only current ever accesses the flag.
--
=============
Pierre Morel
RTOS and Embedded Linux
WARNING: multiple messages have this Message-ID (diff)
From: Pierre Morel <pmorel@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-arch@vger.kernel.org, sameske@linux.vnet.ibm.com,
Michael Kerrisk <mtk.manpages@googlemail.com>,
user-mode-linux-devel@lists.sourceforge.net, gregkh@suse.de,
heicars2@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
dave@linux.vnet.ibm.com, dlezcano@fr.ibm.com, clg@fr.ibm.com,
schwidefsky@de.ibm.com, mingo@elte.hu, oleg@tv-sign.ru,
roland@redhat.com
Subject: Re: [uml-devel] [PATCH 1/1] system call notification with self_ptrace
Date: Wed, 10 Sep 2008 16:17:31 +0200 [thread overview]
Message-ID: <48C7D6FB.3050207@linux.vnet.ibm.com> (raw)
In-Reply-To: <20080908170427.c8bf38f5.akpm@linux-foundation.org>
Hi,
Andrew Morton wrote:
> On Mon, 08 Sep 2008 14:02:01 +0200
> Pierre Morel <pmorel@linux.vnet.ibm.com> wrote:
>
>
>> Subject: [PATCH] system call notification with self_ptrace
>>
>> From: Pierre Morel <pmorel@fr.ibm.com>
>>
>>
>> PTRACE SELF
>>
>> This patch adds a new functionality to ptrace: system call notification to
>> the current process.
>> When a process requests self ptrace, with the new request PTRACE_SELF_ON:
>>
>> 1. the next system call performed by the process will not be executed
>> 2. self ptrace will be disabled for the process
>> 3. a SIGSYS signal will be sent to the process.
>>
>> With an appropriate SIGSYS signal handler, the process can access its own
>> data structures to
>>
>> 1. get the system call number from the siginfo structure
>> 2. get the system call arguments from the stack
>> 3. instrument the system call with other system calls
>> 4. emulate the system call with other system calls
>> 5. change the arguments of the system call
>> 6. perform the system call for good
>> 7. change the return value of the system call
>> 8. request self ptrace again before returning.
>>
>> The new request PTRACE_SELF_OFF disables self ptrace.
>>
>>
>
> It sounds like it might be useful.
>
Thanks, yes I am sure it might.
> Are there any userspace tools available with which people can utilise
> this new functionality? Or plans to release them?
>
Yes, we plan to release a tool to trace an application soon.
>
>> arch/s390/kernel/ptrace.c | 16 ++++++++++++++++
>> arch/s390/kernel/signal.c | 5 +++++
>> arch/x86/kernel/ptrace.c | 29 +++++++++++++++++++++++++++++
>> arch/x86/kernel/signal_32.c | 5 +++++
>> arch/x86/kernel/signal_64.c | 5 +++++
>>
>
> Maintainers of the other 30-odd architectures would appreciate a test
> application which they can use to develop and test their ports, please.
>
Yes, of course I have one for x86 and one for s390.
I am cleaning them to make them available.
> Michael Kerrisk will no doubt be looking for manpage assistance.
> Please cc him on this material.
>
OK, I will prepare this.
> It would be good to get suitable testcases integrated into LTP (if LTP
> has ptrace tests).
>
Yes, I will prepare this too.
> The patch title uses the term "self_ptrace", but the patch itself uses
> the term "ptrace_self". Let's get it consistent everywhere.
>
Right. It should be self_ptrace.
> The patch adds a
>
> + u64 instrumentation;
>
> to the task_struct but no explanation is provided as to why this was
> added, why it is a 64-bit field, what its locking rules are, etc.
> Please fix this.
>
I used to steal one bit in the ptrace bit-field of the task_struct but
Oleg pointed out that the ptrace bit-field is used in a lot of places
without any bit mask, so I chose another way to remember that I (the
thread) am instrumenting myself.
Alternatively, I could also use the ptrace bit-field and modify every
reference to use a mask for any test, set or reset of the bit-field.
I provision a 64 bit wide bit-field for future extensions of the
instrumentation. I could of course use a smaller bit-field as only 1
bit is really useful for now. I used 64 bit to be memory aligned with
most of the architectures.
There is no lock for the instrumentation bit-field because it is used
for self tracing only, and only current ever accesses the flag.
--
=============
Pierre Morel
RTOS and Embedded Linux
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2008-09-10 14:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-08 12:02 [uml-devel] [PATCH 1/1] system call notification with self_ptrace Pierre Morel
2008-09-08 12:02 ` Pierre Morel
2008-09-09 0:04 ` Andrew Morton
2008-09-09 0:04 ` [uml-devel] " Andrew Morton
2008-09-10 14:17 ` Pierre Morel [this message]
2008-09-10 14:17 ` Pierre Morel
2008-09-09 12:43 ` Oleg Nesterov
2008-09-09 12:43 ` Oleg Nesterov
2008-09-10 15:11 ` [uml-devel] " Pierre Morel
2008-09-10 15:11 ` Pierre Morel
2008-09-10 16:20 ` [uml-devel] " Oleg Nesterov
2008-09-10 16:20 ` Oleg Nesterov
2008-09-10 16:23 ` [uml-devel] " Dave Hansen
2008-09-10 16:23 ` Dave Hansen
2008-09-12 12:22 ` [uml-devel] " Pierre Morel
2008-09-12 12:22 ` Pierre Morel
2008-09-12 12:19 ` [uml-devel] " Pierre Morel
2008-09-12 12:19 ` Pierre Morel
2008-09-12 14:32 ` [uml-devel] " Oleg Nesterov
2008-09-12 14:32 ` Oleg Nesterov
2008-09-10 16:19 ` [uml-devel] " Dave Hansen
2008-09-10 16:19 ` Dave Hansen
2008-09-12 12:30 ` [uml-devel] " Pierre Morel
2008-09-12 12:30 ` Pierre Morel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48C7D6FB.3050207@linux.vnet.ibm.com \
--to=pmorel@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=clg@fr.ibm.com \
--cc=dave@linux.vnet.ibm.com \
--cc=dlezcano@fr.ibm.com \
--cc=gregkh@suse.de \
--cc=heicars2@linux.vnet.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtk.manpages@googlemail.com \
--cc=oleg@tv-sign.ru \
--cc=roland@redhat.com \
--cc=sameske@linux.vnet.ibm.com \
--cc=schwidefsky@de.ibm.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.