[PATCH] Use pid2task when passing pid to task_execname

Josh Stone jistone@redhat.com
Fri Apr 11 16:22:00 GMT 2014


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



More information about the Systemtap mailing list