Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-27 Thread Peter Zijlstra
On Wed, 2010-01-27 at 07:53 +0100, Peter Zijlstra wrote:
 On Fri, 2010-01-22 at 12:54 +0530, Ananth N Mavinakayanahalli wrote:
  On Fri, Jan 22, 2010 at 12:32:32PM +0530, Srikar Dronamraju wrote:
   Here is a summary of the Comments and actions that need to be taken for
   the current uprobes patchset. Please let me know if I missed or
   misunderstood any of your comments.  
   
   1. Uprobes depends on trap signal.
 Uprobes depends on trap signal rather than hooking to the global
   die notifier. It was suggested that we hook to the global die notifier.
   
 In the next version of patches, Uprobes will use the global die
 notifier and look at the per-task count of the probes in use to
 see if it has to be consumed.
   
 However this would reduce the ability of uprobe handlers to
 sleep. Since we are dealing with userspace, sleeping in handlers
 would have been a good feature. We are looking at ways to get
 around this limitation.
  
  We could set a TIF_ flag in the notifier to indicate a breakpoint hit
  and process it in task context before the task heads into userspace.
 
 OK, so we can go play stack games in the INT3 interrupt handler by
 moving to a non IST stack when it comes from userspace, or move kprobes
 over to INT1 or something.

Right, it just got pointed out that INT1 doesn't have a single byte
encoding, only INT0 and INT3 :/



Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-22 Thread Peter Zijlstra
On Fri, 2010-01-22 at 12:54 +0530, Ananth N Mavinakayanahalli wrote:
 On Fri, Jan 22, 2010 at 12:32:32PM +0530, Srikar Dronamraju wrote:
  Here is a summary of the Comments and actions that need to be taken for
  the current uprobes patchset. Please let me know if I missed or
  misunderstood any of your comments.  
  
  1. Uprobes depends on trap signal.
  Uprobes depends on trap signal rather than hooking to the global
  die notifier. It was suggested that we hook to the global die notifier.
  
  In the next version of patches, Uprobes will use the global die
  notifier and look at the per-task count of the probes in use to
  see if it has to be consumed.
  
  However this would reduce the ability of uprobe handlers to
  sleep. Since we are dealing with userspace, sleeping in handlers
  would have been a good feature. We are looking at ways to get
  around this limitation.
 
 We could set a TIF_ flag in the notifier to indicate a breakpoint hit
 and process it in task context before the task heads into userspace.

Make that optional, not everybody might want that. Either provide a
simple trampoline or use a flag to indicate the callback be called from
process context on registration.



Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-22 Thread Masami Hiramatsu
Peter Zijlstra wrote:
 On Fri, 2010-01-22 at 12:32 +0530, Srikar Dronamraju wrote:
 
 2. XOL vma vs Emulation vs Single Stepping Inline vs using Protection
 Rings.
  XOL VMA is an additional process address vma.  This is
  opposition to add an additional vma without user actually
  requesting for the same.

  XOL vma and single stepping inline are the two architecture
  independent implementations. While other implementations are
  more architecture specific. Single stepping inline wouldnt go
  well with multithreaded process.

  Even though XOL vma has its own issues, we will go with it since
  other implementations seem to have more complications.

  we would look forward to implementing boosters later. 
  Later on, if we come across another techniques with lesser
  side-effects than the XOL vma, we would switch to using them.
 
 How about modifying glibc to reserve like 64 bytes on the TLS structure
 it has and storing the ins and possible boost jmp there? Since each
 thread can only have a single trap at any one time that should be
 enough.

Hmm, it is a good idea. Well, we'll have a copy of original insn
in kernel, but it could be simpler than managing XOL vma. :-)

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhira...@redhat.com



Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-22 Thread Jim Keniston

On Fri, 2010-01-22 at 19:06 +0100, Peter Zijlstra wrote:
 On Fri, 2010-01-22 at 12:32 +0530, Srikar Dronamraju wrote:
 
  2. XOL vma vs Emulation vs Single Stepping Inline vs using Protection
  Rings.
  XOL VMA is an additional process address vma.  This is
  opposition to add an additional vma without user actually
  requesting for the same.
  
  XOL vma and single stepping inline are the two architecture
  independent implementations. While other implementations are
  more architecture specific. Single stepping inline wouldnt go
  well with multithreaded process.
  
  Even though XOL vma has its own issues, we will go with it since
  other implementations seem to have more complications.
  
  we would look forward to implementing boosters later. 
  Later on, if we come across another techniques with lesser
  side-effects than the XOL vma, we would switch to using them.
 
 How about modifying glibc to reserve like 64 bytes on the TLS structure
 it has and storing the ins and possible boost jmp there? Since each
 thread can only have a single trap at any one time that should be
 enough.

We once implemented something similar, but using an area just beyond the
top of the stack instead of TLS.  We figured it would never pass muster
because we have to temporarily map the page executable (and undo it
after the single-step), and this felt like a big security hole.  I'd
think we'd have the same concern with TLS.

Jim



Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-21 Thread Srikar Dronamraju
Here is a summary of the Comments and actions that need to be taken for
the current uprobes patchset. Please let me know if I missed or
misunderstood any of your comments.  

1. Uprobes depends on trap signal.
Uprobes depends on trap signal rather than hooking to the global
die notifier. It was suggested that we hook to the global die notifier.

In the next version of patches, Uprobes will use the global die
notifier and look at the per-task count of the probes in use to
see if it has to be consumed.

However this would reduce the ability of uprobe handlers to
sleep. Since we are dealing with userspace, sleeping in handlers
would have been a good feature. We are looking at ways to get
around this limitation.


2. XOL vma vs Emulation vs Single Stepping Inline vs using Protection
Rings.
XOL VMA is an additional process address vma.  This is
opposition to add an additional vma without user actually
requesting for the same.

XOL vma and single stepping inline are the two architecture
independent implementations. While other implementations are
more architecture specific. Single stepping inline wouldnt go
well with multithreaded process.

Even though XOL vma has its own issues, we will go with it since
other implementations seem to have more complications.

we would look forward to implementing boosters later. 
Later on, if we come across another techniques with lesser
side-effects than the XOL vma, we would switch to using them.


3. Current Uprobes looks at process life times and not vma lifetimes. 
Also it needs threads to quiesce when inserting and removing
breakpoints.

Current uprobes was quiesing threads of a process before
insertion and deletion. This resulted in uprobes having to track
process lifetimes. An alternative method to track vma lifetimes
was suggested.

Next version would update the copy of the page and flip the
pagetables as suggested by Peter. Hence it would no more depend on
threads quiescing.

However this would need hooks in munmap/rmap so that uprobes can
remove breakpoints that are placed in that vma.

This would also mean removing the rcu_deference we were using.

4. Move the ftrace plugin to use trace events.

Since ftrace plugins are relegated to obsolescence, it was
suggested we use trace events which would have much wider scope.

Next version will use trace events.

5. rename UBP to user_bkpt

6. updating the authors for all files that are getting added.

I shall work towards v2 of uprobes and send across the patches at the
earliest.

--
Thanks and Regards
Srikar



Re: [RFC] [PATCH 0/7] UBP, XOL and Uprobes [ Summary of Comments and actions to be taken ]

2010-01-21 Thread Ananth N Mavinakayanahalli
On Fri, Jan 22, 2010 at 12:32:32PM +0530, Srikar Dronamraju wrote:
 Here is a summary of the Comments and actions that need to be taken for
 the current uprobes patchset. Please let me know if I missed or
 misunderstood any of your comments.  
 
 1. Uprobes depends on trap signal.
   Uprobes depends on trap signal rather than hooking to the global
 die notifier. It was suggested that we hook to the global die notifier.
 
   In the next version of patches, Uprobes will use the global die
   notifier and look at the per-task count of the probes in use to
   see if it has to be consumed.
 
   However this would reduce the ability of uprobe handlers to
   sleep. Since we are dealing with userspace, sleeping in handlers
   would have been a good feature. We are looking at ways to get
   around this limitation.

We could set a TIF_ flag in the notifier to indicate a breakpoint hit
and process it in task context before the task heads into userspace.

Ananth