uretprobes: Return probe entry, prepare_uretprobe()

  When a uprobe with return probe consumer is hit, prepare_uretprobe()
function is invoked. It creates return_instance, hijacks return address
and replaces it with the trampoline.

  - Return instances are kept as stack per uprobed task.
  - Return instance is chained, when the original return address is
    trampoline's page vaddr (e.g. recursive call of the probed function).

v1 changes:
 - preserve address of the breakpoint in return_instance.
 - don't forget NULLify return_instances on free_utask.
 - simplify prepare_uretprobe().

RFCv6 changes:
 - rework prepare_uretprobe() logic in order to make further unwinding
   in handler_uretprobe() simplier.
 - introduce the 'dirty' field.

RFCv5 changes:
 - switch from hlist to simply linked list for tracking ->*return_uprobes.
 - preallocate first slot xol_area for return probes, see xol_get_area()
   changes.
 - add get_trampoline_vaddr() helper, to emphasize area->vaddr overload.

RFCv4 changes:
 - get rid of area->rp_trampoline_vaddr as it always the same as ->vaddr.
 - cleanup ->return_uprobes list in uprobe_free_utask(), because the
   task can exit from inside the ret-probe'd function(s).
 - in find_active_uprobe(): Once we inserted "int3" we must ensure that
   handle_swbp() will be called even if this uprobe goes away. We have
   the reference but it only protects uprobe itself, it can't protect
   agains delete_uprobe().
   IOW, we must ensure that uprobe_pre_sstep_notifier() can't return 0.

RFCv3 changes:
 - protected uprobe with refcounter. See atomic_inc in prepare_uretprobe()
   and put_uprobe() in a following patch in handle_uretprobe().

RFCv2 changes:
 - get rid of ->return_consumers member from struct uprobe, introduce
   ret_handler() in consumer.

Signed-off-by: Anton Arapov <anton@redhat.com>
uretprobes: Return probe exit, invoke handlers

  Uretprobe handlers are invoked when the trampoline is hit, on completion the
trampoline is replaced with the saved return address and the uretprobe instance
deleted.

v1 changes:
  - pass bp_vaddr to ret_handler()
  - simplify handle_uretprobe()

RFCv6 changes:
  - rework handle_uretprobe()

RFCv5 changes:
  - switch to simply linked list ->return_uprobes
  - rework handle_uretprobe()

RFCv4 changes:
  - check, whether utask is not NULL in handle_uretprobe()
  - get rid of area->rp_trampoline_vaddr
  - minor handle_uretprobe() fixups

RFCv3 changes:
  - protected uprobe with refcounter. See put_uprobe() in handle_uretprobe()
    that reflects increment in prepare_uretprobe()

RFCv2 changes:
  - get rid of ->return_consumers member from struct uprobe, introduce
    ret_handler() in consumer instead

Signed-off-by: Anton Arapov <anton@redhat.com>
uretprobes: Limit the depth of return probe nestedness

  Unlike the kretprobes we can't trust userspace, thus must have
protection from user space attacks, e.g. deep recursion, this patch
limits the return probes nestedness as a simple remedy for it.
User-space have the "unlimited" stack, it looks simply impossible
to handle the deep recursion correctly.

  The intention is to have KISS and bare minimum solution for the
initial implementation in order to not complicate the uretprobes
code.

  In the future we may come up with more sophisticated solution that
should remove this depth limitation, however it is not easy task
and lays beyond this patchset. It should consider things like: breakpoint
address lays outside the stack and stack growth direction, leaking
return_instance when longjmp, sigaltstack... be able to clean up
return instances.

Signed-off-by: Anton Arapov <anton@redhat.com>
uretprobes: Documentation update

  add the uretprobe syntax and update an example

Signed-off-by: Anton Arapov <anton@redhat.com>
uretprobes: Remove -ENOSYS as return probes implemented

  Enclose return probes implementation.

Signed-off-by: Anton Arapov <anton@redhat.com>