| 1 |
# time _______________________________________________________ |
| 2 |
# |
| 3 |
# long sys_time(time_t __user * tloc) |
| 4 |
# long sys_time64(long __user * tloc) |
| 5 |
# long sys32_time(compat_time_t __user * tloc) |
| 6 |
# long compat_sys_time(compat_time_t __user * tloc) |
| 7 |
# |
| 8 |
|
| 9 |
@define _SYSCALL_TIME_NAME |
| 10 |
%( |
| 11 |
name = "time" |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_TIME_ARGSTR |
| 15 |
%( |
| 16 |
argstr = sprintf("%p", t_uaddr) |
| 17 |
%) |
| 18 |
|
| 19 |
@define _SYSCALL_TIME_REGARGS |
| 20 |
%( |
| 21 |
t_uaddr = pointer_arg(1) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_TIME_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(t_uaddr)) |
| 27 |
set_pointer_arg(1, t_uaddr) |
| 28 |
%) |
| 29 |
|
| 30 |
probe syscall.time = dw_syscall.time !, nd_syscall.time ? {} |
| 31 |
probe syscall.time.return = dw_syscall.time.return !, nd_syscall.time.return ? {} |
| 32 |
|
| 33 |
# dw_time _____________________________________________________ |
| 34 |
|
| 35 |
probe dw_syscall.time = kernel.function("sys32_time").call ?, |
| 36 |
kernel.function("sys_time64").call ?, |
| 37 |
kernel.function("compat_sys_time").call ?, |
| 38 |
kernel.function("sys_time").call ? |
| 39 |
{ |
| 40 |
@_SYSCALL_TIME_NAME |
| 41 |
t_uaddr = $tloc |
| 42 |
@_SYSCALL_TIME_ARGSTR |
| 43 |
} |
| 44 |
probe dw_syscall.time.return = kernel.function("sys32_time").return ?, |
| 45 |
kernel.function("sys_time64").return ?, |
| 46 |
kernel.function("compat_sys_time").return ?, |
| 47 |
kernel.function("sys_time").return ? |
| 48 |
{ |
| 49 |
@_SYSCALL_TIME_NAME |
| 50 |
@SYSC_RETVALSTR($return) |
| 51 |
} |
| 52 |
|
| 53 |
# nd_time _____________________________________________________ |
| 54 |
|
| 55 |
probe nd_syscall.time = nd1_syscall.time!, nd2_syscall.time!, tp_syscall.time |
| 56 |
{ } |
| 57 |
|
| 58 |
probe nd1_syscall.time = kprobe.function("sys32_time") ?, |
| 59 |
kprobe.function("sys_time64") ?, |
| 60 |
kprobe.function("compat_sys_time") ?, |
| 61 |
kprobe.function("sys_time") ? |
| 62 |
{ |
| 63 |
@_SYSCALL_TIME_NAME |
| 64 |
asmlinkage() |
| 65 |
@_SYSCALL_TIME_REGARGS |
| 66 |
@_SYSCALL_TIME_ARGSTR |
| 67 |
} |
| 68 |
|
| 69 |
/* kernel 4.17+ */ |
| 70 |
probe nd2_syscall.time = kprobe.function(@arch_syscall_prefix "sys_time") ?, |
| 71 |
kprobe.function(@arch_syscall_prefix "compat_sys_time") ? |
| 72 |
{ |
| 73 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 74 |
@_SYSCALL_TIME_NAME |
| 75 |
@_SYSCALL_TIME_REGARGS |
| 76 |
@_SYSCALL_TIME_ARGSTR |
| 77 |
}, |
| 78 |
{ |
| 79 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_TIME_REGARGS_STORE %) |
| 80 |
} |
| 81 |
|
| 82 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 83 |
probe tp_syscall.time = kernel.trace("sys_enter") |
| 84 |
{ |
| 85 |
__set_syscall_pt_regs($regs) |
| 86 |
@__syscall_compat_gate(@const("__NR_time"), @const("__NR_compat_time")) |
| 87 |
@_SYSCALL_TIME_NAME |
| 88 |
@_SYSCALL_TIME_REGARGS |
| 89 |
@_SYSCALL_TIME_ARGSTR |
| 90 |
}, |
| 91 |
{ |
| 92 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_TIME_REGARGS_STORE %) |
| 93 |
} |
| 94 |
|
| 95 |
probe nd_syscall.time.return = nd1_syscall.time.return!, nd2_syscall.time.return!, tp_syscall.time.return |
| 96 |
{ } |
| 97 |
|
| 98 |
probe nd1_syscall.time.return = kprobe.function("sys32_time").return ?, |
| 99 |
kprobe.function("sys_time64").return ?, |
| 100 |
kprobe.function("compat_sys_time").return ?, |
| 101 |
kprobe.function("sys_time").return ? |
| 102 |
{ |
| 103 |
@_SYSCALL_TIME_NAME |
| 104 |
@SYSC_RETVALSTR(returnval()) |
| 105 |
} |
| 106 |
|
| 107 |
/* kernel 4.17+ */ |
| 108 |
probe nd2_syscall.time.return = kprobe.function(@arch_syscall_prefix "sys_time").return ?, |
| 109 |
kprobe.function(@arch_syscall_prefix "compat_sys_time") ? |
| 110 |
{ |
| 111 |
@_SYSCALL_TIME_NAME |
| 112 |
@SYSC_RETVALSTR(returnval()) |
| 113 |
} |
| 114 |
|
| 115 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 116 |
probe tp_syscall.time.return = kernel.trace("sys_exit") |
| 117 |
{ |
| 118 |
__set_syscall_pt_regs($regs) |
| 119 |
@__syscall_compat_gate(@const("__NR_time"), @const("__NR_compat_time")) |
| 120 |
@_SYSCALL_TIME_NAME |
| 121 |
@SYSC_RETVALSTR($ret) |
| 122 |
} |