Skip to content

Commit

Permalink
test: Fix use of syscall::execve:entry args[1][?]
Browse files Browse the repository at this point in the history
Commit 8233237 ("proc: use a rawtp for the proc:::exit probe") included
some test changes.  Specifically, it sought to use syscall::execve:entry
probe arguments args[1][0] and args[1][1] to recognize "sleep 10000".
The patch recognized that the argv pointers in question were in user
space, requiring copyinstr() to access the strings.

But it's trickier than that.  The args[1][?] require two dereferencings,
both in user space.  So a copyin() is required to access args[1] and
then copyinstr() to access the args[1][?].

Fix the tests to use two layers of copyin*() to double dereference the
args[1][?] strings.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Feb 20, 2024
1 parent 474c4f0 commit 7f2b6c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions test/unittest/proc/tst.exitkilled.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ script()
{
$dtrace $dt_flags -s /dev/stdin <<EOF
syscall::execve:entry
/copyinstr((uintptr_t)args[1][0]) == "sleep" && args[1][1] &&
copyinstr((uintptr_t)args[1][1]) == "10000"/
/(this->myargs = (uintptr_t *)copyin((uintptr_t)args[1], 2 * sizeof(char *)))
&& copyinstr(this->myargs[0]) == "sleep"
&& this->myargs[1]
&& copyinstr(this->myargs[1]) == "10000"/
{
kill_pid = pid;
}
Expand Down
8 changes: 6 additions & 2 deletions test/unittest/proc/tst.signal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ script()
{
$dtrace $dt_flags -s /dev/stdin <<EOF
syscall::execve:entry
/copyinstr((uintptr_t)args[1][0]) == "sleep" && args[1][1] &&
copyinstr((uintptr_t)args[1][1]) == "10000"/
/(this->myargs = (uintptr_t *)copyin((uintptr_t)args[1], 2 * sizeof(char *)))
&& copyinstr(this->myargs[0]) == "sleep"
&& this->myargs[1]
&& copyinstr(this->myargs[1]) == "10000"/
{
sig_pid = pid;
}
Expand All @@ -23,12 +25,14 @@ script()
sig_pid == args[1]->pr_pid && args[2] != SIGUSR1/
{
/* Wrong signal being sent. */
printf("wrong signal sent: %d vs %d\n", args[2], SIGUSR1);
exit(1);
}
proc:::signal-handle
/sig_pid == pid/
{
printf("signal received %d\n", args[0]);
exit(args[0] == SIGUSR1 ? 0 : 1);
}
Expand Down

0 comments on commit 7f2b6c9

Please sign in to comment.