Debian Codegraph @

tapset/linux/sysc_dup3.stp

raw
1 # dup3 _______________________________________________________
2 # SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
3
4 @define _SYSCALL_DUP3_NAME
5 %(
6 name = "dup3";
7 %)
8
9 @define _SYSCALL_DUP3_ARGSTR
10 %(
11 argstr = sprintf("%d, %d, %s", oldfd, newfd, flags_str)
12 %)
13
14 @define _SYSCALL_DUP3_REGARGS
15 %(
16 oldfd = int_arg(1)
17 newfd = int_arg(2)
18 flags = int_arg(3)
19 flags_str = _dup3_flag_str(flags)
20 %)
21
22 @define _SYSCALL_DUP3_REGARGS_STORE
23 %(
24 if (@probewrite(oldfd))
25 set_int_arg(1, oldfd)
26
27 if (@probewrite(newfd))
28 set_int_arg(2, newfd)
29
30 if (@probewrite(flags))
31 set_int_arg(3, flags)
32 %)
33
34 probe syscall.dup3 = dw_syscall.dup3 !, nd_syscall.dup3 ? {}
35 probe syscall.dup3.return = dw_syscall.dup3.return !, nd_syscall.dup3.return ? {}
36
37 # dw_dup3 _____________________________________________________
38
39 probe dw_syscall.dup3 = kernel.function("sys_dup3").call ?
40 {
41 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
42 @_SYSCALL_DUP3_NAME
43 oldfd = __int32($oldfd)
44 newfd = __int32($newfd)
45 flags = __int32($flags)
46 flags_str = _dup3_flag_str(flags)
47 @_SYSCALL_DUP3_ARGSTR
48 }
49 probe dw_syscall.dup3.return = kernel.function("sys_dup3").return ?
50 {
51 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
52 @_SYSCALL_DUP3_NAME
53 @SYSC_RETVALSTR($return)
54 }
55
56 # nd_dup3 _____________________________________________________
57
58 probe nd_syscall.dup3 = nd1_syscall.dup3!, nd2_syscall.dup3!, tp_syscall.dup3
59 { }
60
61 probe nd1_syscall.dup3 = kprobe.function("sys_dup3") ?
62 {
63 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
64 @_SYSCALL_DUP3_NAME
65 asmlinkage()
66 @_SYSCALL_DUP3_REGARGS
67 @_SYSCALL_DUP3_ARGSTR
68 }
69
70 /* kernel 4.17+ */
71 probe nd2_syscall.dup3 = kprobe.function(@arch_syscall_prefix "sys_dup3") ?
72 {
73 __set_syscall_pt_regs(pointer_arg(1))
74 @_SYSCALL_DUP3_NAME
75 @_SYSCALL_DUP3_REGARGS
76 @_SYSCALL_DUP3_ARGSTR
77 },
78 {
79 %( @_IS_SREG_KERNEL %? @_SYSCALL_DUP3_REGARGS_STORE %)
80 }
81
82 /* kernel 3.5+, but undesirable because it affects all syscalls */
83 probe tp_syscall.dup3 = kernel.trace("sys_enter")
84 {
85 __set_syscall_pt_regs($regs)
86 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
87 @_SYSCALL_DUP3_NAME
88 @_SYSCALL_DUP3_REGARGS
89 @_SYSCALL_DUP3_ARGSTR
90 },
91 {
92 %( @_IS_SREG_KERNEL %? @_SYSCALL_DUP3_REGARGS_STORE %)
93 }
94
95 probe nd_syscall.dup3.return = nd1_syscall.dup3.return!, nd2_syscall.dup3.return!, tp_syscall.dup3.return
96 { }
97
98 probe nd1_syscall.dup3.return = kprobe.function("sys_dup3").return ?
99 {
100 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
101 @_SYSCALL_DUP3_NAME
102 @SYSC_RETVALSTR(returnval())
103 }
104
105 /* kernel 4.17+ */
106 probe nd2_syscall.dup3.return = kprobe.function(@arch_syscall_prefix "sys_dup3").return ?
107 {
108 @_SYSCALL_DUP3_NAME
109 @SYSC_RETVALSTR(returnval())
110 }
111
112 /* kernel 3.5+, but undesirable because it affects all syscalls */
113 probe tp_syscall.dup3.return = kernel.trace("sys_exit")
114 {
115 __set_syscall_pt_regs($regs)
116 @__syscall_compat_gate(@const("__NR_dup3"), @const("__NR_compat_dup3"))
117 @_SYSCALL_DUP3_NAME
118 @SYSC_RETVALSTR($ret)
119 }