From: Abegail Jakop Date: Mon, 7 Jul 2014 19:56:09 +0000 (-0400) Subject: tapsets.cxx: validate PID for process(PID)* X-Git-Tag: release-2.6~91^2~20^2~4 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=6c4842771aed009633adec84d9b1c71ed2675146;p=systemtap.git tapsets.cxx: validate PID for process(PID)* tapsets: validate PID for process(PID).{function, plt, mark} probes --- diff --git a/tapsets.cxx b/tapsets.cxx index d090e987f..37f772b94 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -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