Debian Codegraph @

tapset/linux/sysc_ustat.stp

raw
1 # ustat ______________________________________________________
2 # long sys_ustat(unsigned dev, struct ustat __user * ubuf)
3 #
4
5 @define _SYSCALL_USTAT_NAME
6 %(
7 name = "ustat"
8 %)
9
10 @define _SYSCALL_USTAT_ARGSTR
11 %(
12 argstr = sprintf("%u, %p", dev, ubuf_uaddr)
13 %)
14
15 @define _SYSCALL_USTAT_REGARGS
16 %(
17 dev = uint_arg(1)
18 ubuf_uaddr = pointer_arg(2)
19 %)
20
21 @define _SYSCALL_USTAT_REGARGS_STORE
22 %(
23 if (@probewrite(dev))
24 set_uint_arg(1, dev)
25
26 if (@probewrite(ubuf_uaddr))
27 set_pointer_arg(2, ubuf_uaddr)
28 %)
29
30 probe syscall.ustat = dw_syscall.ustat !, nd_syscall.ustat ? {}
31 probe syscall.ustat.return = dw_syscall.ustat.return !, nd_syscall.ustat.return ? {}
32
33 # dw_ustat _____________________________________________________
34
35 probe dw_syscall.ustat = kernel.function("sys_ustat").call
36 {
37 @_SYSCALL_USTAT_NAME
38 dev = __uint32($dev)
39 ubuf_uaddr = $ubuf
40 @_SYSCALL_USTAT_ARGSTR
41 }
42 probe dw_syscall.ustat.return = kernel.function("sys_ustat").return ?
43 {
44 @_SYSCALL_USTAT_NAME
45 @SYSC_RETVALSTR($return)
46 }
47
48 # nd_ustat _____________________________________________________
49
50 probe nd_syscall.ustat = nd1_syscall.ustat!, nd2_syscall.ustat!, tp_syscall.ustat
51 { }
52
53 probe nd1_syscall.ustat = kprobe.function("sys_ustat") ?
54 {
55 @_SYSCALL_USTAT_NAME
56 asmlinkage()
57 @_SYSCALL_USTAT_REGARGS
58 @_SYSCALL_USTAT_ARGSTR
59 }
60
61 /* kernel 4.17+ */
62 probe nd2_syscall.ustat = kprobe.function(@arch_syscall_prefix "sys_ustat") ?
63 {
64 __set_syscall_pt_regs(pointer_arg(1))
65 @_SYSCALL_USTAT_NAME
66 @_SYSCALL_USTAT_REGARGS
67 @_SYSCALL_USTAT_ARGSTR
68 },
69 {
70 %( @_IS_SREG_KERNEL %? @_SYSCALL_USTAT_REGARGS_STORE %)
71 }
72
73 /* kernel 3.5+, but undesirable because it affects all syscalls */
74 probe tp_syscall.ustat = kernel.trace("sys_enter")
75 {
76 __set_syscall_pt_regs($regs)
77 @__syscall_gate(@const("__NR_ustat"))
78 @_SYSCALL_USTAT_NAME
79 @_SYSCALL_USTAT_REGARGS
80 @_SYSCALL_USTAT_ARGSTR
81 },
82 {
83 %( @_IS_SREG_KERNEL %? @_SYSCALL_USTAT_REGARGS_STORE %)
84 }
85
86 probe nd_syscall.ustat.return = nd1_syscall.ustat.return!, nd2_syscall.ustat.return!, tp_syscall.ustat.return
87 { }
88
89 probe nd1_syscall.ustat.return = kprobe.function("sys_ustat").return ?
90 {
91 @_SYSCALL_USTAT_NAME
92 @SYSC_RETVALSTR(returnval())
93 }
94
95 /* kernel 4.17+ */
96 probe nd2_syscall.ustat.return = kprobe.function(@arch_syscall_prefix "sys_ustat").return ?
97 {
98 @_SYSCALL_USTAT_NAME
99 @SYSC_RETVALSTR(returnval())
100 }
101
102 /* kernel 3.5+, but undesirable because it affects all syscalls */
103 probe tp_syscall.ustat.return = kernel.trace("sys_exit")
104 {
105 __set_syscall_pt_regs($regs)
106 @__syscall_gate(@const("__NR_ustat"))
107 @_SYSCALL_USTAT_NAME
108 @SYSC_RETVALSTR($ret)
109 }
110
111 # long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
112 # long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
113 #
114
115 probe syscall.ustat32 = dw_syscall.ustat32 !, nd_syscall.ustat32 ? {}
116 probe syscall.ustat32.return = dw_syscall.ustat32.return !,
117 nd_syscall.ustat32.return ? {}
118
119 # dw_ustat32 _____________________________________________________
120
121 probe dw_syscall.ustat32 = kernel.function("compat_sys_ustat").call ?,
122 kernel.function("sys32_ustat").call ?
123 {
124 @_SYSCALL_USTAT_NAME
125 dev = __uint32($dev)
126 ubuf_uaddr = @choose_defined($u, $u32p)
127 @_SYSCALL_USTAT_ARGSTR
128 }
129
130
131 probe dw_syscall.ustat32.return = kernel.function("sys32_ustat").return ?,
132 kernel.function("compat_sys_ustat").return ?
133 {
134 @_SYSCALL_USTAT_NAME
135 @SYSC_RETVALSTR($return)
136 }
137
138 # nd_ustat32 _____________________________________________________
139
140 probe nd_syscall.ustat32 = nd1_syscall.ustat32!, nd2_syscall.ustat32!, tp_syscall.ustat32
141 { }
142
143 probe nd1_syscall.ustat32 = __nd1_syscall.ustat32 ?, __nd1_syscall.compat_ustat ?
144 {
145 @_SYSCALL_USTAT_NAME
146 @_SYSCALL_USTAT_ARGSTR
147 }
148 probe __nd1_syscall.ustat32 = kprobe.function("sys32_ustat") ?
149 {
150 @_SYSCALL_USTAT_REGARGS
151 }
152 probe __nd1_syscall.compat_ustat = kprobe.function("compat_sys_ustat") ?
153 {
154 asmlinkage()
155 @_SYSCALL_USTAT_REGARGS
156 }
157
158 /* kernel 4.17+ */
159 probe nd2_syscall.ustat32 =
160 kprobe.function(@arch_syscall_prefix "compat_sys_ustat") ?
161 {
162 __set_syscall_pt_regs(pointer_arg(1))
163 @_SYSCALL_USTAT_NAME
164 @_SYSCALL_USTAT_REGARGS
165 @_SYSCALL_USTAT_ARGSTR
166 },
167 {
168 %( @_IS_SREG_KERNEL %? @_SYSCALL_USTAT_REGARGS_STORE %)
169 }
170
171 /* kernel 3.5+, but undesirable because it affects all syscalls */
172 probe tp_syscall.ustat32 = kernel.trace("sys_enter")
173 {
174 __set_syscall_pt_regs($regs)
175 @__compat_syscall_gate(@const("__NR_compat_ustat"))
176 @_SYSCALL_USTAT_NAME
177 @_SYSCALL_USTAT_REGARGS
178 @_SYSCALL_USTAT_ARGSTR
179 },
180 {
181 %( @_IS_SREG_KERNEL %? @_SYSCALL_USTAT_REGARGS_STORE %)
182 }
183
184 probe nd_syscall.ustat32.return = nd1_syscall.ustat32.return!, nd2_syscall.ustat32.return!, tp_syscall.ustat32.return
185 { }
186
187 probe nd1_syscall.ustat32.return = kprobe.function("sys32_ustat").return ?,
188 kprobe.function("compat_sys_ustat").return ?
189 {
190 @_SYSCALL_USTAT_NAME
191 @SYSC_RETVALSTR(returnval())
192 }
193
194 /* kernel 4.17+ */
195 probe nd2_syscall.ustat32.return =
196 kprobe.function(@arch_syscall_prefix "compat_sys_ustat").return ?
197 {
198 @_SYSCALL_USTAT_NAME
199 @SYSC_RETVALSTR(returnval())
200 }
201
202 /* kernel 3.5+, but undesirable because it affects all syscalls */
203 probe tp_syscall.ustat32.return = kernel.trace("sys_exit")
204 {
205 __set_syscall_pt_regs($regs)
206 @__compat_syscall_gate(@const("__NR_compat_ustat"))
207 @_SYSCALL_USTAT_NAME
208 @SYSC_RETVALSTR($ret)
209 }