]> sourceware.org Git - systemtap.git/commitdiff
tapsets.cxx: validate PID for process(PID)*
authorAbegail Jakop <ajakop@redhat.com>
Mon, 7 Jul 2014 19:56:09 +0000 (15:56 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Mon, 7 Jul 2014 19:56:09 +0000 (15:56 -0400)
tapsets: validate PID for process(PID).{function, plt, mark} probes

tapsets.cxx

index d090e987f5507265d5d6762056a996a1446dcd20..37f772b94b87b85ff854951a8ca9b42efe3dd9c9 100644 (file)
@@ -7592,6 +7592,18 @@ dwarf_builder::build(systemtap_session & sess,
 
       else if (get_param (parameters, TOK_PROCESS, proc_pid))
         {
+          // check that the pid given corresponds to a running process
+          if (proc_pid < 1 || kill(proc_pid, 0) == -1)
+              switch (errno) // ignore EINVAL: invalid signal
+              {
+                case ESRCH:
+                  throw SEMANTIC_ERROR(_("pid given does not correspond to a running process"));
+                case EPERM:
+                  throw SEMANTIC_ERROR(_("invalid permissions for signalling given pid"));
+                default:
+                  throw SEMANTIC_ERROR(_("invalid pid"));
+              }
+
           string pid_path = string("/proc/") + lex_cast(proc_pid) + "/exe";
           module_name = sess.sysroot + pid_path;
           // change it so it is mapped by the executable path and not the PID
This page took 0.045856 seconds and 5 git commands to generate.