Debian Codegraph @

tapset/linux/sysc_shutdown.stp

raw
1 # shutdown ___________________________________________________
2 #
3 # long sys_shutdown(int fd, int how)
4 #
5
6 @define _SYSCALL_SHUTDOWN_NAME
7 %(
8 name = "shutdown"
9 %)
10
11 @define _SYSCALL_SHUTDOWN_ARGSTR
12 %(
13 argstr = sprintf("%d, %s", s, how_str)
14 %)
15
16 @define _SYSCALL_SHUTDOWN_REGARGS
17 %(
18 s = int_arg(1)
19 how = int_arg(2)
20 %)
21
22 @define _SYSCALL_SHUTDOWN_REGARGS_STORE
23 %(
24 if (@probewrite(s))
25 set_int_arg(1, s)
26
27 if (@probewrite(how))
28 set_int_arg(2, how)
29 %)
30
31 @define _SYSCALL_SOCKETCALL_SHUTDOWN_REGARGS
32 %(
33 __args = &@ulong_cast(pointer_arg(2))
34 s = __int32(user_ulong(&@ulong_cast(__args)[0]))
35 how = __int32(user_ulong(&@ulong_cast(__args)[1]))
36 %)
37
38 @define _SYSCALL_COMPAT_SOCKETCALL_SHUTDOWN_REGARGS
39 %(
40 __args = &@uint_cast(pointer_arg(2))
41 s = user_int(&@uint_cast(__args)[0])
42 how = user_int(&@uint_cast(__args)[1])
43 %)
44
45 probe syscall.shutdown = dw_syscall.shutdown !, nd_syscall.shutdown ? {}
46 probe syscall.shutdown.return = dw_syscall.shutdown.return !,
47 nd_syscall.shutdown.return ? {}
48
49 # dw_shutdown _____________________________________________________
50
51 probe dw_syscall.shutdown = __syscall.shutdown ?, __syscall.socketcall.shutdown ?,
52 __syscall.compat_socketcall.shutdown ?
53 {
54 @_SYSCALL_SHUTDOWN_NAME
55 how_str = _shutdown_how_str(how)
56 @_SYSCALL_SHUTDOWN_ARGSTR
57 }
58 probe __syscall.shutdown = kernel.function("sys_shutdown").call ?
59 {
60 @__syscall_gate(@const("__NR_shutdown"))
61 s = __int32($fd)
62 how = __int32($how)
63 }
64 probe __syscall.socketcall.shutdown = kernel.function("sys_socketcall").call ?
65 {
66 if (__int32($call) != @const("SYS_SHUTDOWN")) next;
67 s = __int32(user_ulong(&@ulong_cast($args)[0]))
68 how = __int32(user_ulong(&@ulong_cast($args)[1]))
69 }
70 probe __syscall.compat_socketcall.shutdown =
71 kernel.function("compat_sys_socketcall").call ?
72 {
73 if (__int32($call) != @const("SYS_SHUTDOWN")) next;
74 s = user_int(&@uint_cast($args)[0])
75 how = user_int(&@uint_cast($args)[1])
76 }
77 probe dw_syscall.shutdown.return = __syscall.shutdown.return ?,
78 __syscall.socketcall.shutdown.return ?
79 {
80 @_SYSCALL_SHUTDOWN_NAME
81 @SYSC_RETVALSTR($return)
82 }
83 probe __syscall.shutdown.return = kernel.function("sys_shutdown").return ?
84 {
85 @__syscall_gate(@const("__NR_shutdown"))
86 }
87 probe __syscall.socketcall.shutdown.return =
88 kernel.function("sys_socketcall").return ?,
89 kernel.function("compat_sys_socketcall").return ?
90 {
91 if (__int32(@entry($call)) != @const("SYS_SHUTDOWN")) next;
92 }
93
94 # nd_shutdown _____________________________________________________
95
96 probe nd_syscall.shutdown = nd1_syscall.shutdown!, nd2_syscall.shutdown!, tp_syscall.shutdown
97 { }
98
99 probe nd1_syscall.shutdown = __nd1_syscall.shutdown ?,
100 __nd1_syscall.socketcall.shutdown ?,
101 __nd1_syscall.compat_socketcall.shutdown ?
102 {
103 @_SYSCALL_SHUTDOWN_NAME
104 how_str = _shutdown_how_str(how)
105 @_SYSCALL_SHUTDOWN_ARGSTR
106 }
107 probe __nd1_syscall.shutdown = kprobe.function("sys_shutdown") ?
108 {
109 @__syscall_gate(@const("__NR_shutdown"))
110 asmlinkage()
111 @_SYSCALL_SHUTDOWN_REGARGS
112 }
113 probe __nd1_syscall.socketcall.shutdown = kprobe.function("sys_socketcall").call ?
114 {
115 asmlinkage()
116 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
117 @_SYSCALL_SOCKETCALL_SHUTDOWN_REGARGS
118 }
119 probe __nd1_syscall.compat_socketcall.shutdown =
120 kprobe.function("compat_sys_socketcall").call ?
121 {
122 asmlinkage()
123 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
124 @_SYSCALL_COMPAT_SOCKETCALL_SHUTDOWN_REGARGS
125 }
126
127 /* kernel 4.17+ */
128 probe nd2_syscall.shutdown = __nd2_syscall.shutdown ?,
129 __nd2_syscall.socketcall.shutdown ?,
130 __nd2_syscall.compat_socketcall.shutdown ?
131 {
132 @_SYSCALL_SHUTDOWN_NAME
133 how_str = _shutdown_how_str(how)
134 @_SYSCALL_SHUTDOWN_ARGSTR
135 }
136 probe __nd2_syscall.shutdown = kprobe.function(@arch_syscall_prefix "sys_shutdown") ?
137 {
138 __set_syscall_pt_regs(pointer_arg(1))
139 @_SYSCALL_SHUTDOWN_REGARGS
140 },
141 {
142 %( @_IS_SREG_KERNEL %? @_SYSCALL_SHUTDOWN_REGARGS_STORE %)
143 }
144 probe __nd2_syscall.socketcall.shutdown = kprobe.function(@arch_syscall_prefix "sys_socketcall").call ?
145 {
146 __set_syscall_pt_regs(pointer_arg(1))
147 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
148 @_SYSCALL_SOCKETCALL_SHUTDOWN_REGARGS
149 }
150 probe __nd2_syscall.compat_socketcall.shutdown =
151 kprobe.function(@arch_syscall_prefix "compat_sys_socketcall").call ?
152 {
153 __set_syscall_pt_regs(pointer_arg(1))
154 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
155 @_SYSCALL_COMPAT_SOCKETCALL_SHUTDOWN_REGARGS
156 }
157
158 /* kernel 3.5+, but undesirable because it affects all syscalls */
159 probe tp_syscall.shutdown = __tp_syscall.shutdown ?,
160 __tp_syscall.socketcall.shutdown ?
161 {
162 @_SYSCALL_SHUTDOWN_NAME
163 how_str = _shutdown_how_str(how)
164 @_SYSCALL_SHUTDOWN_ARGSTR
165 }
166 probe __tp_syscall.shutdown = kernel.trace("sys_enter")
167 {
168 __set_syscall_pt_regs($regs)
169 @__syscall_gate(@const("__NR_shutdown"))
170 @_SYSCALL_SHUTDOWN_REGARGS
171 },
172 {
173 %( @_IS_SREG_KERNEL %? @_SYSCALL_SHUTDOWN_REGARGS_STORE %)
174 }
175 probe __tp_syscall.socketcall.shutdown = kernel.trace("sys_enter")
176 {
177 __set_syscall_pt_regs($regs)
178 @__syscall_compat_gate(@const("__NR_socketcall"), @const("__NR_compat_socketcall"))
179 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
180 if (@__compat_task) {
181 @_SYSCALL_COMPAT_SOCKETCALL_SHUTDOWN_REGARGS
182 }
183 else {
184 @_SYSCALL_SOCKETCALL_SHUTDOWN_REGARGS
185 }
186 }
187
188 probe nd_syscall.shutdown.return = nd1_syscall.shutdown.return!, nd2_syscall.shutdown.return!, tp_syscall.shutdown.return
189 { }
190
191 probe nd1_syscall.shutdown.return = __nd1_syscall.shutdown.return ?,
192 __nd1_syscall.socketcall.shutdown.return ?
193 {
194 @_SYSCALL_SHUTDOWN_NAME
195 @SYSC_RETVALSTR(returnval())
196 }
197 probe __nd1_syscall.shutdown.return = kprobe.function("sys_shutdown").return ?
198 {
199 @__syscall_gate(@const("__NR_shutdown"))
200 }
201 probe __nd1_syscall.socketcall.shutdown.return =
202 kprobe.function("sys_socketcall").return ?,
203 kprobe.function("compat_sys_socketcall").return ?
204 {
205 if (@entry(__asmlinkage_int_arg(1)) != @const("SYS_SHUTDOWN")) next;
206 }
207
208 /* kernel 4.17+ */
209 probe nd2_syscall.shutdown.return =
210 kprobe.function(@arch_syscall_prefix "sys_shutdown").return ?,
211 __nd2_syscall.socketcall.shutdown.return ?
212 {
213 @_SYSCALL_SHUTDOWN_NAME
214 @SYSC_RETVALSTR(returnval())
215 }
216 probe __nd2_syscall.socketcall.shutdown.return =
217 kprobe.function(@arch_syscall_prefix "sys_socketcall").return ?,
218 kprobe.function(@arch_syscall_prefix "compat_sys_socketcall").return ?
219 {
220 __set_syscall_pt_regs(@entry(pointer_arg(1)))
221 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
222 }
223
224 /* kernel 3.5+, but undesirable because it affects all syscalls */
225 probe tp_syscall.shutdown.return = __tp_syscall.shutdown.return ?,
226 __tp_syscall.socketcall.shutdown.return ?
227 {
228 @_SYSCALL_SHUTDOWN_NAME
229 @SYSC_RETVALSTR($ret)
230 }
231 probe __tp_syscall.shutdown.return = kernel.trace("sys_exit")
232 {
233 @__syscall_gate(@const("__NR_shutdown"))
234 }
235 probe __tp_syscall.socketcall.shutdown.return = kernel.trace("sys_exit")
236 {
237 __set_syscall_pt_regs($regs)
238 @__syscall_compat_gate(@const("__NR_socketcall"), @const("__NR_compat_socketcall"))
239 if (int_arg(1) != @const("SYS_SHUTDOWN")) next;
240 }