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