| 1 |
# getpid _____________________________________________________ |
| 2 |
# long sys_getpid(void) |
| 3 |
|
| 4 |
@define _SYSCALL_GETPID_NAME |
| 5 |
%( |
| 6 |
name = "getpid" |
| 7 |
%) |
| 8 |
|
| 9 |
@define _SYSCALL_GETPID_ARGSTR |
| 10 |
%( |
| 11 |
argstr = "" |
| 12 |
%) |
| 13 |
|
| 14 |
probe syscall.getpid = dw_syscall.getpid !, nd_syscall.getpid ? {} |
| 15 |
probe syscall.getpid.return = dw_syscall.getpid.return !, nd_syscall.getpid.return ? {} |
| 16 |
|
| 17 |
# dw_getpid _____________________________________________________ |
| 18 |
|
| 19 |
probe dw_syscall.getpid = kernel.function("sys_getpid").call |
| 20 |
{ |
| 21 |
@_SYSCALL_GETPID_NAME |
| 22 |
@_SYSCALL_GETPID_ARGSTR |
| 23 |
} |
| 24 |
probe dw_syscall.getpid.return = kernel.function("sys_getpid").return |
| 25 |
{ |
| 26 |
@_SYSCALL_GETPID_NAME |
| 27 |
@SYSC_RETVALSTR($return) |
| 28 |
} |
| 29 |
|
| 30 |
# nd_getpid _____________________________________________________ |
| 31 |
|
| 32 |
probe nd_syscall.getpid = nd1_syscall.getpid!, nd2_syscall.getpid!, tp_syscall.getpid |
| 33 |
{ } |
| 34 |
|
| 35 |
probe nd1_syscall.getpid = kprobe.function("sys_getpid") |
| 36 |
{ |
| 37 |
@_SYSCALL_GETPID_NAME |
| 38 |
@_SYSCALL_GETPID_ARGSTR |
| 39 |
} |
| 40 |
|
| 41 |
/* kernel 4.17+ */ |
| 42 |
probe nd2_syscall.getpid = kprobe.function(@arch_syscall0_prefix "sys_getpid") ? |
| 43 |
{ |
| 44 |
@_SYSCALL_GETPID_NAME |
| 45 |
@_SYSCALL_GETPID_ARGSTR |
| 46 |
} |
| 47 |
|
| 48 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 49 |
probe tp_syscall.getpid = kernel.trace("sys_enter") |
| 50 |
{ |
| 51 |
@__syscall_compat_gate(@const("__NR_getpid"), @const("__NR_compat_getpid")) |
| 52 |
@_SYSCALL_GETPID_NAME |
| 53 |
@_SYSCALL_GETPID_ARGSTR |
| 54 |
} |
| 55 |
|
| 56 |
probe nd_syscall.getpid.return = nd1_syscall.getpid.return!, nd2_syscall.getpid.return!, tp_syscall.getpid.return |
| 57 |
{ } |
| 58 |
|
| 59 |
probe nd1_syscall.getpid.return = kprobe.function("sys_getpid").return |
| 60 |
{ |
| 61 |
@_SYSCALL_GETPID_NAME |
| 62 |
@SYSC_RETVALSTR(returnval()) |
| 63 |
} |
| 64 |
|
| 65 |
/* kernel 4.17+ */ |
| 66 |
probe nd2_syscall.getpid.return = kprobe.function(@arch_syscall0_prefix "sys_getpid").return ? |
| 67 |
{ |
| 68 |
@_SYSCALL_GETPID_NAME |
| 69 |
@SYSC_RETVALSTR(returnval()) |
| 70 |
} |
| 71 |
|
| 72 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 73 |
probe tp_syscall.getpid.return = kernel.trace("sys_exit") |
| 74 |
{ |
| 75 |
__set_syscall_pt_regs($regs) |
| 76 |
@__syscall_compat_gate(@const("__NR_getpid"), @const("__NR_compat_getpid")) |
| 77 |
@_SYSCALL_GETPID_NAME |
| 78 |
@SYSC_RETVALSTR($ret) |
| 79 |
} |