Debian Codegraph @

tapset/linux/sysc_fstat.stp

raw
1 # fstat ______________________________________________________
2 # long sys_fstat(unsigned int fd, struct __old_kernel_stat __user * statbuf)
3 # long sys_fstat64(unsigned long fd, struct stat64 __user * statbuf)
4 # long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
5 # long sys_newfstat(unsigned int fd, struct stat __user * statbuf)
6 # long sys_oabi_fstat64(char __user * filename,
7 # struct oldabi_stat64 __user * statbuf)
8 # long compat_sys_newfstat(unsigned int fd, struct compat_stat __user * statbuf)
9 #
10
11 @define _SYSCALL_FSTAT_NAME
12 %(
13 name = "fstat"
14 %)
15
16 @define _SYSCALL_FSTAT_ARGSTR
17 %(
18 argstr = sprintf("%d, %p", filedes, buf_uaddr)
19 %)
20
21 @define _SYSCALL_FSTAT_REGARGS
22 %(
23 filedes = int_arg(1)
24 buf_uaddr = pointer_arg(2)
25 %)
26
27 @define _SYSCALL_FSTAT_REGARGS_STORE
28 %(
29 if (@probewrite(filedes))
30 set_int_arg(1, filedes)
31
32 if (@probewrite(buf_uaddr))
33 set_pointer_arg(2, buf_uaddr)
34 %)
35
36 probe syscall.fstat = dw_syscall.fstat !, nd_syscall.fstat ? {}
37 probe syscall.fstat.return = dw_syscall.fstat.return !, nd_syscall.fstat.return ? {}
38
39 # dw_fstat _____________________________________________________
40
41 probe dw_syscall.fstat = kernel.function("sys_fstat").call ?,
42 kernel.function("sys_fstat64").call ?,
43 kernel.function("sys32_fstat64").call ?,
44 kernel.function("sys_newfstat").call ?,
45 kernel.function("sys_oabi_fstat64").call ?,
46 kernel.function("sys_oabi_fstat64").call ?,
47 %( arch == "s390" %?
48 kernel.function("compat_sys_s390_fstat64").call ?,
49 %)
50 %( arch == "x86_64" %?
51 kernel.function("compat_sys_x86_fstat64").call ?,
52 %)
53 kernel.function("compat_sys_newfstat").call ?
54 {
55 @_SYSCALL_FSTAT_NAME
56 filedes = __int32($fd)
57 buf_uaddr = $statbuf
58 @_SYSCALL_FSTAT_ARGSTR
59 }
60 probe dw_syscall.fstat.return = kernel.function("sys_fstat").return ?,
61 kernel.function("sys_fstat64").return ?,
62 kernel.function("sys32_fstat64").return ?,
63 kernel.function("sys_newfstat").return ?,
64 kernel.function("sys_oabi_fstat64").return ?,
65 %( arch == "s390" %?
66 kernel.function("compat_sys_s390_fstat64").return ?,
67 %)
68 %( arch == "x86_64" %?
69 kernel.function("compat_sys_x86_fstat64").return ?,
70 %)
71 kernel.function("compat_sys_newfstat").return ?
72 {
73 @_SYSCALL_FSTAT_NAME
74 @SYSC_RETVALSTR($return)
75 }
76
77 # nd_fstat _____________________________________________________
78
79 probe nd_syscall.fstat = nd1_syscall.fstat!, nd2_syscall.fstat!, tp_syscall.fstat
80 { }
81
82 probe nd1_syscall.fstat = kprobe.function("sys_fstat") ?,
83 kprobe.function("sys_fstat64") ?,
84 kprobe.function("sys32_fstat64") ?,
85 kprobe.function("sys_newfstat") ?,
86 kprobe.function("sys_oabi_fstat64") ?,
87 %( arch == "s390" %?
88 kprobe.function("compat_sys_s390_fstat64") ?,
89 %)
90 %( arch == "x86_64" %?
91 kprobe.function("compat_sys_x86_fstat64") ?,
92 %)
93 kprobe.function("compat_sys_newfstat") ?
94 {
95 @_SYSCALL_FSTAT_NAME
96 asmlinkage()
97 @_SYSCALL_FSTAT_REGARGS
98 @_SYSCALL_FSTAT_ARGSTR
99 }
100
101 /* kernel 4.17+ */
102 probe nd2_syscall.fstat =
103 kprobe.function(@arch_syscall_prefix "sys_fstat") ?,
104 kprobe.function(@arch_syscall_prefix "sys_newfstat") ?,
105 kprobe.function(@arch_syscall_prefix "compat_sys_newfstat") ?,
106 kprobe.function(@arch_syscall_prefix "compat_sys_x86_fstat64") ?
107 {
108 __set_syscall_pt_regs(pointer_arg(1))
109 @_SYSCALL_FSTAT_NAME
110 @_SYSCALL_FSTAT_REGARGS
111 @_SYSCALL_FSTAT_ARGSTR
112 },
113 {
114 @_SYSCALL_FSTAT_REGARGS_STORE
115 }
116
117 /* kernel 3.5+, but undesirable because it affects all syscalls */
118 probe tp_syscall.fstat = __tp_syscall.fstat,
119 __tp_syscall.fstat64,
120 __tp_syscall.newfstat
121 {
122 __set_syscall_pt_regs($regs)
123 @_SYSCALL_FSTAT_NAME
124 @_SYSCALL_FSTAT_REGARGS
125 @_SYSCALL_FSTAT_ARGSTR
126 },
127 {
128 @_SYSCALL_FSTAT_REGARGS_STORE
129 }
130 probe __tp_syscall.fstat = kernel.trace("sys_enter")
131 {
132 @__syscall_compat_gate(@const("__NR_oldfstat"), @const("__NR_compat_oldfstat"))
133 }
134 probe __tp_syscall.fstat64 = kernel.trace("sys_enter")
135 {
136 @__syscall_compat_gate(@const("__NR_fstat64"), @const("__NR_compat_fstat64"))
137 }
138 probe __tp_syscall.newfstat = kernel.trace("sys_enter")
139 {
140 @__syscall_compat_gate(@const("__NR_fstat"), @const("__NR_compat_fstat"))
141 }
142
143 probe nd_syscall.fstat.return = nd1_syscall.fstat.return!, nd2_syscall.fstat.return!, tp_syscall.fstat.return
144 { }
145
146 probe nd1_syscall.fstat.return = kprobe.function("sys_fstat").return ?,
147 kprobe.function("sys_fstat64").return ?,
148 kprobe.function("sys32_fstat64").return ?,
149 kprobe.function("sys_newfstat").return ?,
150 kprobe.function("sys_oabi_fstat64").return ?,
151 %( arch == "s390" %?
152 kprobe.function("compat_sys_s390_fstat64").return ?,
153 %)
154 %( arch == "x86_64" %?
155 kprobe.function("compat_sys_x86_fstat64").return ?,
156 %)
157 kprobe.function("compat_sys_newfstat").return ?
158 {
159 @_SYSCALL_FSTAT_NAME
160 @SYSC_RETVALSTR(returnval())
161 }
162
163 /* kernel 4.17+ */
164 probe nd2_syscall.fstat.return =
165 kprobe.function(@arch_syscall_prefix "sys_fstat").return ?,
166 kprobe.function(@arch_syscall_prefix "sys_newfstat").return ?,
167 kprobe.function(@arch_syscall_prefix "compat_sys_newfstat").return ?,
168 kprobe.function(@arch_syscall_prefix "compat_sys_x86_fstat64").return ?
169 {
170 @_SYSCALL_FSTAT_NAME
171 @SYSC_RETVALSTR(returnval())
172 }
173
174 /* kernel 3.5+, but undesirable because it affects all syscalls */
175 probe tp_syscall.fstat.return = __tp_syscall.fstat.return,
176 __tp_syscall.fstat64.return,
177 __tp_syscall.newfstat.return
178 {
179 __set_syscall_pt_regs($regs)
180 @_SYSCALL_FSTAT_NAME
181 @SYSC_RETVALSTR($ret)
182 }
183 probe __tp_syscall.fstat.return = kernel.trace("sys_exit")
184 {
185 @__syscall_compat_gate(@const("__NR_oldfstat"), @const("__NR_compat_oldfstat"))
186 }
187 probe __tp_syscall.fstat64.return = kernel.trace("sys_exit")
188 {
189 @__syscall_compat_gate(@const("__NR_fstat64"), @const("__NR_compat_fstat64"))
190 }
191 probe __tp_syscall.newfstat.return = kernel.trace("sys_exit")
192 {
193 @__syscall_compat_gate(@const("__NR_fstat"), @const("__NR_compat_fstat"))
194 }