1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
probe begin
{
curr = task_current()
// Compare PIDs
pid = pid()
cast_pid = @cast(curr, "task_struct", "kernel")->tgid
if (pid == cast_pid)
println("PID OK")
else
printf("PID %d != %d\n", pid, cast_pid)
// Compare PIDs using a generated kernel module
cast_pid = @cast(curr, "task_struct", "kernel<linux/sched.h>")->tgid
if (pid == cast_pid)
println("PID2 OK")
else
printf("PID2 %d != %d\n", pid, cast_pid)
// Compare PIDs with an array access (PR11556)
cast_pid = @cast(curr, "task_struct", "kernel")[0]->tgid
if (pid == cast_pid)
println("PID3 OK")
else
printf("PID3 %d != %d\n", pid, cast_pid)
// Compare execnames
name = execname()
cast_name = kernel_string(@cast(curr, "task_struct", "kernel")->comm)
if (name == cast_name)
println("execname OK")
else
printf("execname \"%s\" != \"%s\"\n", name, cast_name)
// Compare usage counter values through a struct address
usage = @cast(curr, "task_struct", "kernel")->usage->counter
pusage = & @cast(curr, "task_struct", "kernel")->usage
cast_usage = @cast(pusage, "atomic_t", "kernel")->counter
if (usage == cast_usage)
println("usage OK")
else
printf("usage %d != %d\n", usage, cast_usage)
exit()
}
|