public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use pid2task when passing pid to task_execname
@ 2014-04-11  7:15 Masatake YAMATO
  2014-04-11 16:22 ` Josh Stone
  0 siblings, 1 reply; 2+ messages in thread
From: Masatake YAMATO @ 2014-04-11  7:15 UTC (permalink / raw)
  To: systemtap; +Cc: yamato

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))
 }
 
 /**
@@ -499,7 +499,7 @@ probe signal.systkill = syscall.tkill
     name = "systkill"
     sig_name = _signal_name($sig)
     sig_pid = $pid
-    pid_name = task_execname($pid)
+    pid_name = task_execname(pid2task($pid))
 }
 
 /**
@@ -530,7 +530,7 @@ probe signal.systgkill = syscall.tgkill
     name = "systgkill"
     sig_name = _signal_name($sig)
     sig_pid = $pid
-    pid_name = task_execname($pid)
+    pid_name = task_execname(pid2task($pid))
 }
 
 /**
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use pid2task when passing pid to task_execname
  2014-04-11  7:15 [PATCH] Use pid2task when passing pid to task_execname Masatake YAMATO
@ 2014-04-11 16:22 ` Josh Stone
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Stone @ 2014-04-11 16:22 UTC (permalink / raw)
  To: Masatake YAMATO, systemtap

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-11 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11  7:15 [PATCH] Use pid2task when passing pid to task_execname Masatake YAMATO
2014-04-11 16:22 ` Josh Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).