Debian Codegraph @

tapset/linux/sysc_times.stp

raw
1 # times ______________________________________________________
2 #
3 # long sys_times(struct tms __user * tbuf)
4 # long compat_sys_times(struct compat_tms __user *tbuf)
5
6 @define _SYSCALL_TIMES_NAME
7 %(
8 name = "times"
9 %)
10
11 @define _SYSCALL_TIMES_ARGSTR
12 %(
13 argstr = sprintf("%s", buf_str)
14 %)
15
16 @define _SYSCALL_TIMES_REGARGS
17 %(
18 buf_uaddr = pointer_arg(1)
19 buf_str = _struct_tms_u(buf_uaddr)
20 %)
21
22 @define _SYSCALL_TIMES_REGARGS_STORE
23 %(
24 if (@probewrite(buf_uaddr))
25 set_pointer_arg(1, buf_uaddr)
26 %)
27
28 probe syscall.times = dw_syscall.times !, nd_syscall.times ? {}
29 probe syscall.times.return = dw_syscall.times.return !,
30 nd_syscall.times.return ? {}
31
32 # dw_times _____________________________________________________
33
34 probe dw_syscall.times = kernel.function("compat_sys_times").call ?,
35 kernel.function("sys_times").call ?
36 {
37 @_SYSCALL_TIMES_NAME
38 buf_uaddr = @__pointer($tbuf)
39 buf_str = _struct_tms_u(buf_uaddr)
40 @_SYSCALL_TIMES_ARGSTR
41 }
42 probe dw_syscall.times.return = kernel.function("compat_sys_times").return ?,
43 kernel.function("sys_times").return ?
44 {
45 @_SYSCALL_TIMES_NAME
46 @SYSC_RETVALSTR($return)
47 }
48
49 # nd_times _____________________________________________________
50
51 probe nd_syscall.times = nd1_syscall.times!, nd2_syscall.times!, tp_syscall.times
52 { }
53
54 probe nd1_syscall.times = kprobe.function("compat_sys_times") ?,
55 kprobe.function("sys_times") ?
56 {
57 @_SYSCALL_TIMES_NAME
58 asmlinkage()
59 @_SYSCALL_TIMES_REGARGS
60 @_SYSCALL_TIMES_ARGSTR
61 }
62
63 /* kernel 4.17+ */
64 probe nd2_syscall.times = kprobe.function(@arch_syscall_prefix "compat_sys_times") ?,
65 kprobe.function(@arch_syscall_prefix "sys_times") ?
66 {
67 __set_syscall_pt_regs(pointer_arg(1))
68 @_SYSCALL_TIMES_NAME
69 @_SYSCALL_TIMES_REGARGS
70 @_SYSCALL_TIMES_ARGSTR
71 },
72 {
73 %( @_IS_SREG_KERNEL %? @_SYSCALL_TIMES_REGARGS_STORE %)
74 }
75
76 /* kernel 3.5+, but undesirable because it affects all syscalls */
77 probe tp_syscall.times = kernel.trace("sys_enter")
78 {
79 __set_syscall_pt_regs($regs)
80 @__syscall_compat_gate(@const("__NR_times"), @const("__NR_compat_times"))
81 @_SYSCALL_TIMES_NAME
82 @_SYSCALL_TIMES_REGARGS
83 @_SYSCALL_TIMES_ARGSTR
84 },
85 {
86 %( @_IS_SREG_KERNEL %? @_SYSCALL_TIMES_REGARGS_STORE %)
87 }
88
89 probe nd_syscall.times.return = nd1_syscall.times.return!, nd2_syscall.times.return!, tp_syscall.times.return
90 { }
91
92 probe nd1_syscall.times.return = kprobe.function("compat_sys_times").return ?,
93 kprobe.function("sys_times").return ?
94 {
95 @_SYSCALL_TIMES_NAME
96 @SYSC_RETVALSTR(returnval())
97 }
98
99 /* kernel 4.17+ */
100 probe nd2_syscall.times.return = kprobe.function(@arch_syscall_prefix "compat_sys_times").return ?,
101 kprobe.function(@arch_syscall_prefix "sys_times").return ?
102 {
103 @_SYSCALL_TIMES_NAME
104 @SYSC_RETVALSTR(returnval())
105 }
106
107 /* kernel 3.5+, but undesirable because it affects all syscalls */
108 probe tp_syscall.times.return = kernel.trace("sys_exit")
109 {
110 __set_syscall_pt_regs($regs)
111 @__syscall_compat_gate(@const("__NR_times"), @const("__NR_compat_times"))
112 @_SYSCALL_TIMES_NAME
113 @SYSC_RETVALSTR($ret)
114 }