Debian Codegraph @

tapset/linux/sysc_pipe.stp

raw
1 # pipe _______________________________________________________
2 #
3 # asmlinkage int sys_pipe(unsigned long __user * fildes)
4 # asmlinkage long sys_ia64_pipe (void)
5 # SYSCALL_DEFINE2(pipe2, int __user *, fildes, int, flags)
6 # pipe2() was added to Linux in version 2.6.27.
7
8 probe syscall.pipe = dw_syscall.pipe !, nd_syscall.pipe ? {}
9 probe syscall.pipe.return = dw_syscall.pipe.return !, nd_syscall.pipe.return ? {}
10
11 # dw_pipe _____________________________________________________
12
13 probe dw_syscall.pipe = __syscall.pipe2 ?, __syscall.ia64_pipe ?, __syscall.pipe
14 {
15 }
16 probe __syscall.pipe2 = kernel.function("sys_pipe2").call ?
17 {
18 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
19 name = "pipe2"
20 flags = __int32($flags)
21 flag_str = _sys_pipe2_flag_str(flags);
22 fildes_uaddr = $fildes
23 if (fildes_uaddr == 0) {
24 pipe0 = 0;
25 pipe1 = 0;
26 argstr = "NULL"
27 } else {
28 /*
29 * Why use @cast here? Why not just:
30 *
31 * pipe0 = user_int(&$fildes[0]);
32 * pipe1 = user_int(&$fildes[1]);
33 *
34 * The answer is syscall wrappers
35 * (CONFIG_SYSCALL_WRAPPERS). On ppc (for example),
36 * SyS_foo has all "long" arguments, and then the
37 * inline SYSC_foo has the real argument types. The
38 * @cast makes sure we're dealing with the "final"
39 * type.
40 */
41 pipe0 = user_int(&@cast($fildes, "int")[0])
42 pipe1 = user_int(&@cast($fildes, "int")[1])
43 argstr = sprintf("[%d, %d], %s", pipe0, pipe1, flag_str);
44 }
45 }
46 probe __syscall.ia64_pipe = kernel.function("sys_ia64_pipe").call ?
47 {
48 name = "pipe"
49 flags = 0
50 flag_str = ""
51 fildes_uaddr = 0
52 pipe0 = 0;
53 pipe1 = 0;
54 argstr = "[0, 0]";
55 }
56 probe __syscall.pipe = kernel.function("sys_pipe").call
57 {
58 name = "pipe"
59 flags = 0
60 flag_str = ""
61 fildes_uaddr = $fildes
62 if (fildes_uaddr == 0) {
63 pipe0 = 0;
64 pipe1 = 0;
65 argstr = "NULL"
66 } else {
67 /*
68 * Why use @cast here? Why not just:
69 *
70 * pipe0 = user_int(&$fildes[0]);
71 * pipe1 = user_int(&$fildes[1]);
72 *
73 * The answer is syscall wrappers
74 * (CONFIG_SYSCALL_WRAPPERS). On ppc (for example),
75 * SyS_foo has all "long" arguments, and then the
76 * inline SYSC_foo has the real argument types. The
77 * @cast makes sure we're dealing with the "final"
78 * type.
79 */
80 pipe0 = user_int(&@cast($fildes, "int")[0])
81 pipe1 = user_int(&@cast($fildes, "int")[1])
82 argstr = sprintf("[%d, %d]", pipe0, pipe1);
83 }
84 }
85 probe dw_syscall.pipe.return = __syscall.pipe2.return ?,
86 __syscall.ia64_pipe.return ?,
87 __syscall.pipe.return
88 {
89 }
90 probe __syscall.pipe2.return = kernel.function("sys_pipe2").return ?
91 {
92 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
93 name = "pipe2"
94 fildes_uaddr = @entry($fildes)
95 if (fildes_uaddr == 0) {
96 pipe0 = 0;
97 pipe1 = 0;
98 } else {
99 /*
100 * See comment in dw_syscall.pipe about why @cast is used
101 * here.
102 */
103 pipe0 = user_int(&@cast(@entry($fildes), "int")[0])
104 pipe1 = user_int(&@cast(@entry($fildes), "int")[1])
105 }
106 @SYSC_RETVALSTR($return)
107 }
108 probe __syscall.ia64_pipe.return = kernel.function("sys_ia64_pipe").return ?
109 {
110 name = "pipe"
111 fildes_uaddr = 0;
112 pipe0 = _ia64_pipe0();
113 pipe1 = _ia64_pipe1();
114
115 @SYSC_RETVALSTR($return)
116 if (pipe0 >= 0) { retstr = "0" }
117 }
118 probe __syscall.pipe.return = kernel.function("sys_pipe").return
119 {
120 name = "pipe"
121 fildes_uaddr = @entry($fildes)
122 if (fildes_uaddr == 0) {
123 pipe0 = 0;
124 pipe1 = 0;
125 } else {
126 /*
127 * See comment in dw_syscall.pipe about why @cast is used
128 * here.
129 */
130 pipe0 = user_int(&@cast(@entry($fildes), "int")[0])
131 pipe1 = user_int(&@cast(@entry($fildes), "int")[1])
132 }
133 @SYSC_RETVALSTR($return)
134 }
135
136 # nd_pipe _____________________________________________________
137
138 probe nd_syscall.pipe = nd1_syscall.pipe!, nd2_syscall.pipe!, tp_syscall.pipe
139 { }
140
141 probe nd1_syscall.pipe = __nd1_syscall.pipe2 ?, __nd1_syscall.ia64_pipe ?,
142 __nd1_syscall.pipe
143 {
144 }
145 probe __nd1_syscall.pipe2 = kprobe.function("sys_pipe2") ?
146 {
147 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
148 %( arch != "powerpc" %? asmlinkage() %)
149 name = "pipe2";
150 flags = int_arg(2)
151 flag_str = _sys_pipe2_flag_str(flags);
152 fildes_uaddr = pointer_arg(1)
153 if (fildes_uaddr == 0) {
154 pipe0 = 0;
155 pipe1 = 0;
156 argstr = "NULL"
157 } else {
158 pipe0 = _fildes_index_u(fildes_uaddr, 0)
159 pipe1 = _fildes_index_u(fildes_uaddr, 1)
160 argstr = sprintf("[%d, %d], %s", pipe0, pipe1, flag_str);
161 }
162 }
163 probe __nd1_syscall.ia64_pipe = kprobe.function("sys_ia64_pipe").call ?
164 {
165 name = "pipe"
166 flags = 0
167 flag_str = ""
168 fildes_uaddr = 0
169 pipe0 = 0;
170 pipe1 = 0;
171 argstr = "[0, 0]";
172 }
173 probe __nd1_syscall.pipe = kprobe.function("sys_pipe")
174 {
175 name = "pipe"
176 flags = 0
177 flag_str = ""
178 %( arch != "powerpc" %? asmlinkage() %)
179 fildes_uaddr = pointer_arg(1)
180 if (fildes_uaddr == 0) {
181 pipe0 = 0;
182 pipe1 = 0;
183 argstr = "NULL"
184 } else {
185 pipe0 = _fildes_index_u(fildes_uaddr, 0)
186 pipe1 = _fildes_index_u(fildes_uaddr, 1)
187 argstr = sprintf("[%d, %d]", pipe0, pipe1);
188 }
189 }
190
191 /* kernel 4.17+ */
192 probe nd2_syscall.pipe = __nd2_syscall.pipe2 ?, __nd2_syscall.pipe
193 {
194 }
195 probe __nd2_syscall.pipe2 = kprobe.function(@arch_syscall_prefix "sys_pipe2") ?
196 {
197 __set_syscall_pt_regs(pointer_arg(1))
198 name = "pipe2";
199 flags = int_arg(2)
200 flag_str = _sys_pipe2_flag_str(flags);
201 fildes_uaddr = pointer_arg(1)
202 if (fildes_uaddr == 0) {
203 pipe0 = 0;
204 pipe1 = 0;
205 argstr = "NULL"
206 } else {
207 pipe0 = _fildes_index_u(fildes_uaddr, 0)
208 pipe1 = _fildes_index_u(fildes_uaddr, 1)
209 argstr = sprintf("[%d, %d], %s", pipe0, pipe1, flag_str);
210 }
211 },
212 {
213 %( @_IS_SREG_KERNEL %?
214 if (@probewrite(fildes_uaddr))
215 set_pointer_arg(1, fildes_uaddr)
216
217 if (@probewrite(flags))
218 set_int_arg(2, flags)
219 %)
220 }
221 probe __nd2_syscall.pipe = kprobe.function(@arch_syscall_prefix "sys_pipe")
222 {
223 __set_syscall_pt_regs(pointer_arg(1))
224 name = "pipe"
225 flags = 0
226 flag_str = ""
227 fildes_uaddr = pointer_arg(1)
228 if (fildes_uaddr == 0) {
229 pipe0 = 0;
230 pipe1 = 0;
231 argstr = "NULL"
232 } else {
233 pipe0 = _fildes_index_u(fildes_uaddr, 0)
234 pipe1 = _fildes_index_u(fildes_uaddr, 1)
235 argstr = sprintf("[%d, %d]", pipe0, pipe1);
236 }
237 },
238 {
239 %( @_IS_SREG_KERNEL %?
240 if (@probewrite(fildes_uaddr))
241 set_pointer_arg(1, fildes_uaddr)
242 %)
243 }
244
245 /* kernel 3.5+, but undesirable because it affects all syscalls */
246 probe tp_syscall.pipe = __tp_syscall.pipe2 ?, __tp_syscall.pipe
247 {
248 }
249 probe __tp_syscall.pipe2 = kernel.trace("sys_enter")
250 {
251 __set_syscall_pt_regs($regs)
252 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
253 name = "pipe2";
254 flags = int_arg(2)
255 flag_str = _sys_pipe2_flag_str(flags);
256 fildes_uaddr = pointer_arg(1)
257 if (fildes_uaddr == 0) {
258 pipe0 = 0;
259 pipe1 = 0;
260 argstr = "NULL"
261 } else {
262 pipe0 = _fildes_index_u(fildes_uaddr, 0)
263 pipe1 = _fildes_index_u(fildes_uaddr, 1)
264 argstr = sprintf("[%d, %d], %s", pipe0, pipe1, flag_str);
265 }
266 },
267 {
268 %( @_IS_SREG_KERNEL %?
269 if (@probewrite(fildes_uaddr))
270 set_pointer_arg(1, fildes_uaddr)
271
272 if (@probewrite(flags))
273 set_int_arg(2, flags)
274 %)
275 }
276
277 probe __tp_syscall.pipe = kernel.trace("sys_enter")
278 {
279 __set_syscall_pt_regs($regs)
280 @__syscall_compat_gate(@const("__NR_pipe"), @const("__NR_compat_pipe"))
281 name = "pipe"
282 flags = 0
283 flag_str = ""
284 fildes_uaddr = pointer_arg(1)
285 if (fildes_uaddr == 0) {
286 pipe0 = 0;
287 pipe1 = 0;
288 argstr = "NULL"
289 } else {
290 pipe0 = _fildes_index_u(fildes_uaddr, 0)
291 pipe1 = _fildes_index_u(fildes_uaddr, 1)
292 argstr = sprintf("[%d, %d]", pipe0, pipe1);
293 }
294 },
295 {
296 %( @_IS_SREG_KERNEL %?
297 if (@probewrite(fildes_uaddr))
298 set_pointer_arg(1, fildes_uaddr)
299 %)
300 }
301
302 probe nd_syscall.pipe.return = nd1_syscall.pipe.return!, nd2_syscall.pipe.return!, tp_syscall.pipe.return
303 { }
304
305 probe nd1_syscall.pipe.return = __nd1_syscall.pipe2.return ?,
306 __nd1_syscall.ia64_pipe.return ?,
307 __nd1_syscall.pipe.return
308 {
309 }
310 probe __nd1_syscall.pipe2.return = kprobe.function("sys_pipe2").return ?
311 {
312 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
313 name = "pipe2";
314 fildes_uaddr = @entry(pointer_arg(1))
315 if (fildes_uaddr == 0) {
316 pipe0 = 0;
317 pipe1 = 0;
318 } else {
319 pipe0 = _fildes_index_u(fildes_uaddr, 0)
320 pipe1 = _fildes_index_u(fildes_uaddr, 1)
321 }
322 @SYSC_RETVALSTR(returnval())
323 }
324 probe __nd1_syscall.ia64_pipe.return = kprobe.function("sys_ia64_pipe").return ?
325 {
326 name = "pipe"
327 fildes_uaddr = 0;
328 pipe0 = _ia64_pipe0();
329 pipe1 = _ia64_pipe1();
330 @SYSC_RETVALSTR(returnval())
331 if (pipe0 >= 0) { retstr = "0" }
332 }
333 probe __nd1_syscall.pipe.return = kprobe.function("sys_pipe").return
334 {
335 name = "pipe"
336 fildes_uaddr = @entry(%( arch != "powerpc" %? __asmlinkage_int_arg(1)
337 %: int_arg(1) %))
338 if (fildes_uaddr == 0) {
339 pipe0 = 0;
340 pipe1 = 0;
341 } else {
342 pipe0 = _fildes_index_u(fildes_uaddr, 0)
343 pipe1 = _fildes_index_u(fildes_uaddr, 1)
344 }
345 @SYSC_RETVALSTR(returnval())
346 }
347
348 /* kernel 4.17+ */
349 probe nd2_syscall.pipe.return = __nd2_syscall.pipe2.return ?,
350 __nd2_syscall.pipe.return
351 {
352 }
353 probe __nd2_syscall.pipe2.return = kprobe.function(@arch_syscall_prefix "sys_pipe2").return ?
354 {
355 name = "pipe2";
356 __set_syscall_pt_regs(@entry(pointer_arg(1)))
357 fildes_uaddr = pointer_arg(1)
358 if (fildes_uaddr == 0) {
359 pipe0 = 0;
360 pipe1 = 0;
361 } else {
362 pipe0 = _fildes_index_u(fildes_uaddr, 0)
363 pipe1 = _fildes_index_u(fildes_uaddr, 1)
364 }
365 @SYSC_RETVALSTR(returnval())
366 }
367 probe __nd2_syscall.pipe.return = kprobe.function(@arch_syscall_prefix "sys_pipe").return
368 {
369 name = "pipe"
370 __set_syscall_pt_regs(@entry(pointer_arg(1)))
371 fildes_uaddr = int_arg(1)
372 if (fildes_uaddr == 0) {
373 pipe0 = 0;
374 pipe1 = 0;
375 } else {
376 pipe0 = _fildes_index_u(fildes_uaddr, 0)
377 pipe1 = _fildes_index_u(fildes_uaddr, 1)
378 }
379 @SYSC_RETVALSTR(returnval())
380 }
381
382 /* kernel 3.5+, but undesirable because it affects all syscalls */
383 probe tp_syscall.pipe.return = __tp_syscall.pipe2.return ?,
384 __tp_syscall.pipe.return
385 {
386 }
387 probe __tp_syscall.pipe2.return = kernel.trace("sys_exit")
388 {
389 __set_syscall_pt_regs($regs)
390 @__syscall_compat_gate(@const("__NR_pipe2"), @const("__NR_compat_pipe2"))
391 name = "pipe2";
392 fildes_uaddr = pointer_arg(1)
393 if (fildes_uaddr == 0) {
394 pipe0 = 0;
395 pipe1 = 0;
396 } else {
397 pipe0 = _fildes_index_u(fildes_uaddr, 0)
398 pipe1 = _fildes_index_u(fildes_uaddr, 1)
399 }
400 @SYSC_RETVALSTR($ret)
401 }
402 probe __tp_syscall.pipe.return = kernel.trace("sys_exit")
403 {
404 __set_syscall_pt_regs($regs)
405 @__syscall_compat_gate(@const("__NR_pipe"), @const("__NR_compat_pipe"))
406 name = "pipe"
407 fildes_uaddr = int_arg(1)
408 if (fildes_uaddr == 0) {
409 pipe0 = 0;
410 pipe1 = 0;
411 } else {
412 pipe0 = _fildes_index_u(fildes_uaddr, 0)
413 pipe1 = _fildes_index_u(fildes_uaddr, 1)
414 }
415 @SYSC_RETVALSTR($ret)
416 }