This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH] Use pid2task when passing pid to task_execname
- From: Josh Stone <jistone at redhat dot com>
- To: Masatake YAMATO <yamato at redhat dot com>, systemtap at sourceware dot org
- Date: Fri, 11 Apr 2014 09:22:07 -0700
- Subject: Re: [PATCH] Use pid2task when passing pid to task_execname
- Authentication-results: sourceware.org; auth=none
- References: <1397200528-11738-1-git-send-email-yamato at redhat dot com>
On 04/11/2014 12:15 AM, Masatake YAMATO wrote:
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> ---
> tapset/linux/signal.stp | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tapset/linux/signal.stp b/tapset/linux/signal.stp
> index 48b7f5f..0a7747e 100644
> --- a/tapset/linux/signal.stp
> +++ b/tapset/linux/signal.stp
> @@ -470,7 +470,7 @@ probe signal.syskill = syscall.kill
> name = "syskill"
> sig_name = _signal_name($sig)
> sig_pid = $pid
> - pid_name = task_execname($pid)
> + pid_name = task_execname(pid2task($pid))
Good catch!
However, this should nicely handle the case when pid2task returns NULL
for any missing $pid, because task_execname will try to dereference it.
Our built-in protection will avoid crashing, but will terminate the
script, which we only want for truly bad behavior. I'd leave pid_name
empty in this case.
The $pid in syscall.kill can be 0 or negative, for instance, which is
perfectly fine but won't pass pid2task. Or any user may have tried to
kill the wrong $pid, accidentally or deliberately.
You can either check the result of pid2task manually, or just put a
try-catch around this assignment.
Thanks,
Josh