]> sourceware.org Git - systemtap.git/commitdiff
_stp_current_pt_regs() helper, explicitly checks current->mm.
authorMark Wielaard <mjw@redhat.com>
Fri, 23 Sep 2011 11:07:07 +0000 (13:07 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 23 Sep 2011 11:30:49 +0000 (13:30 +0200)
task_pt_regs(current) is only valid when current->mm has been setup.

runtime/compatdefs.h
runtime/stack.c
tapset/context.stp
tapset/s390/syscalls.stp
tapset/syscalls2.stp

index 23850be3eac82810f2c556596aef8021038789aa..7fac064a129892743d37ef47e7945e2f88bbb8fb 100644 (file)
@@ -63,6 +63,10 @@ static inline int _stp_is_compat_task(void)
 #endif
 #endif
 
+/* Always use _stp_current_pt_regs() in tapset/runtime code to make sure
+   the returned user pt_regs are sane. */
+#define _stp_current_pt_regs() (current->mm ? task_pt_regs(current) : NULL)
+
 /* Whether all user registers are valid. If not the pt_regs needs,
  * architecture specific, scrubbing before usage (in the unwinder).
  * XXX Currently very simple heuristics, just check arch. Should
index e52b4f4f467d8b47853cc68f48ccdee08994837c..6f6f2eb8242ac1b6031c25fbb9824c44ec0434cb 100644 (file)
@@ -159,8 +159,8 @@ static struct pt_regs *_stp_get_uregs(struct context *c)
     {
       /* First try simple recovery through task_pt_regs,
         on some platforms that already provides complete uregs. */
-      c->uregs = task_pt_regs (current);
-      if (_stp_task_pt_regs_valid(current, c->uregs))
+      c->uregs = _stp_current_pt_regs();
+      if (c->uregs && _stp_task_pt_regs_valid(current, c->uregs))
        c->probe_flags |= _STP_PROBE_STATE_FULL_UREGS;
     }
   return c->uregs;
index 2ae32d28920d12ac4ca978d36ca8928cc5a767c8..1665f75485e2d22b0c886ca21a93c17e6abc355b 100644 (file)
@@ -376,10 +376,8 @@ function uaddr:long ()
 
   if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
     uregs = CONTEXT->uregs;
-  else if (current->mm)
-    uregs = task_pt_regs(current);
   else
-    uregs = NULL;
+    uregs = _stp_current_pt_regs();
 
   if (uregs)
     THIS->__retvalue = (int64_t) REG_IP(uregs);
index b9d9aa0c0ec58f84b7c676c3e8d4f075b5dacb8d..37baefbfe2e5062458173711a3e9d9948854989c 100644 (file)
@@ -148,7 +148,7 @@ probe syscall.sigaltstack = kernel.function("sys_sigaltstack")
        name = "sigaltstack"
        uss_uaddr = $uss
        uoss_uaddr = $uoss
-       regs = %{ task_pt_regs(current) %}
+       regs = %{ _stp_current_pt_regs() %}
        argstr = sprintf("%p, %p", $uss, $uoss)
 }
 probe syscall.sigaltstack.return = kernel.function("sys_sigaltstack").return
index 09503493b4745696dade80ad24083c5eda6a93c3..828077be649c06e0e229cd4f13bb7ef214c6d263 100644 (file)
@@ -285,7 +285,7 @@ function _ia64_pipe0:long() %{
        THIS->__retvalue = CONTEXT->kregs ? CONTEXT->kregs->r8 : 0;
 %}
 function _ia64_pipe1:long() %{
-       THIS->__retvalue = task_pt_regs(current)->r9;
+       THIS->__retvalue = _stp_current_pt_regs()->r9;
 %}
 %)
 # pipe _______________________________________________________
This page took 0.03691 seconds and 5 git commands to generate.