[DTrace-devel] [PATCH] test: Fix use of syscall::execve:entry args[1][?]
eugene.loh at oracle.com
eugene.loh at oracle.com
Thu Feb 15 22:42:42 UTC 2024
From: Eugene Loh <eugene.loh at oracle.com>
Commit 82332371 ("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 at oracle.com>
---
test/unittest/proc/tst.exitkilled.sh | 6 ++++--
test/unittest/proc/tst.signal.sh | 8 ++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/test/unittest/proc/tst.exitkilled.sh b/test/unittest/proc/tst.exitkilled.sh
index be9fc651..723dff88 100755
--- a/test/unittest/proc/tst.exitkilled.sh
+++ b/test/unittest/proc/tst.exitkilled.sh
@@ -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;
}
diff --git a/test/unittest/proc/tst.signal.sh b/test/unittest/proc/tst.signal.sh
index 3f885759..1db10042 100755
--- a/test/unittest/proc/tst.signal.sh
+++ b/test/unittest/proc/tst.signal.sh
@@ -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;
}
@@ -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);
}
--
2.18.4
More information about the DTrace-devel
mailing list