Debian Codegraph @

tapset/linux/sysc_pwritev.stp

raw
1 # pwritev ___________________________________________________
2 #
3 # sys_pwritev(unsigned long fd, const struct iovec __user * vec,
4 # unsigned long vlen, unsigned long pos_l, unsigned long pos_h)
5 # compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,
6 # unsigned long vlen, u32 pos_low, u32 pos_high)
7 #
8
9 @define _SYSCALL_PWRITEV_NAME
10 %(
11 name = "pwritev"
12 %)
13
14 @define _SYSCALL_PWRITEV_ARGSTR
15 %(
16 argstr = sprintf("%d, %p, %d, 0x%x", fd, vector_uaddr, count, offset)
17 %)
18
19 @define _SYSCALL_PWRITEV_REGARGS
20 %(
21 fd = int_arg(1)
22 vector_uaddr = pointer_arg(2)
23 count = int_arg(3)
24 offset = @__pos_from_hilo(ulong_arg(5), ulong_arg(4))
25 %)
26
27 @define _SYSCALL_PWRITEV_REGARGS_STORE
28 %(
29 if (@probewrite(fd))
30 set_int_arg(1, fd)
31
32 if (@probewrite(vector_uaddr))
33 set_pointer_arg(2, vector_uaddr)
34
35 if (@probewrite(count))
36 set_int_arg(3, count)
37
38 if (@probewrite(offset)) {
39 set_ulong_arg(4, __ulong(offset))
40 set_ulong_arg(5, __ulong(offset >> 32))
41 }
42 %)
43
44 @define _SYSCALL_COMPAT_PWRITEV_REGARGS
45 %(
46 fd = int_arg(1)
47 vector_uaddr = pointer_arg(2)
48 count = int_arg(3)
49 offset = (u32_arg(5) << 32) + u32_arg(4)
50 %)
51
52 @define _SYSCALL_COMPAT_PWRITEV_REGARGS_STORE
53 %(
54 if (@probewrite(fd))
55 set_int_arg(1, fd)
56
57 if (@probewrite(vector_uaddr))
58 set_pointer_arg(2, vector_uaddr)
59
60 if (@probewrite(count))
61 set_int_arg(3, count)
62
63 if (@probewrite(offset)) {
64 set_u32_arg(4, offset & 0xffffffff)
65 set_u32_arg(5, offset >> 32)
66 }
67 %)
68
69 probe syscall.pwritev = dw_syscall.pwritev !, nd_syscall.pwritev ? {}
70 probe syscall.pwritev.return = dw_syscall.pwritev.return !,
71 nd_syscall.pwritev.return ? {}
72
73 # dw_pwritev _____________________________________________________
74
75 probe dw_syscall.pwritev = __syscall.pwritev ?, __syscall.compat_pwritev ?
76 {
77 @_SYSCALL_PWRITEV_NAME
78 }
79 probe __syscall.pwritev = kernel.function("sys_pwritev").call
80 {
81 fd = __int32($fd)
82 vector_uaddr = $vec
83 count = __int32($vlen)
84 offset = @__pos_from_hilo($pos_h, $pos_l)
85 @_SYSCALL_PWRITEV_ARGSTR
86 }
87 probe __syscall.compat_pwritev = kernel.function("compat_sys_pwritev").call
88 {
89 fd = __int32($fd)
90 vector_uaddr = $vec
91 count = __int32($vlen)
92 offset = ($pos_high << 32) + __uint32($pos_low)
93 @_SYSCALL_PWRITEV_ARGSTR
94 }
95 probe dw_syscall.pwritev.return = kernel.function("sys_pwritev").return ?,
96 kernel.function("compat_sys_pwritev").return ?
97 {
98 @_SYSCALL_PWRITEV_NAME
99 @SYSC_RETVALSTR($return)
100 }
101
102 # nd_pwritev _____________________________________________________
103
104 probe nd_syscall.pwritev = nd1_syscall.pwritev!, nd2_syscall.pwritev!, tp_syscall.pwritev
105 { }
106
107 probe nd1_syscall.pwritev = __nd1_syscall.pwritev ?,
108 __nd1_syscall.compat_pwritev ?
109 {
110 @_SYSCALL_PWRITEV_NAME
111 }
112 probe __nd1_syscall.pwritev = kprobe.function("sys_pwritev").call
113 {
114 asmlinkage()
115 @_SYSCALL_PWRITEV_REGARGS
116 @_SYSCALL_PWRITEV_ARGSTR
117 }
118 probe __nd1_syscall.compat_pwritev = kprobe.function("compat_sys_pwritev").call
119 {
120 asmlinkage()
121 @_SYSCALL_COMPAT_PWRITEV_REGARGS
122 @_SYSCALL_PWRITEV_ARGSTR
123 }
124
125 /* kernel 4.17+ */
126 probe nd2_syscall.pwritev = __nd2_syscall.pwritev ?,
127 __nd2_syscall.compat_pwritev ?
128 {
129 @_SYSCALL_PWRITEV_NAME
130 }
131 probe __nd2_syscall.pwritev = kprobe.function(@arch_syscall_prefix "sys_pwritev").call
132 {
133 __set_syscall_pt_regs(pointer_arg(1))
134 @_SYSCALL_PWRITEV_REGARGS
135 @_SYSCALL_PWRITEV_ARGSTR
136 },
137 {
138 %( @_IS_SREG_KERNEL %? @_SYSCALL_PWRITEV_REGARGS_STORE %)
139 }
140 probe __nd2_syscall.compat_pwritev = kprobe.function(@arch_syscall_prefix "compat_sys_pwritev").call
141 {
142 __set_syscall_pt_regs(pointer_arg(1))
143 @_SYSCALL_COMPAT_PWRITEV_REGARGS
144 @_SYSCALL_PWRITEV_ARGSTR
145 },
146 {
147 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_PWRITEV_REGARGS_STORE %)
148 }
149
150 /* kernel 3.5+, but undesirable because it affects all syscalls */
151 probe tp_syscall.pwritev = __tp_syscall.pwritev ?,
152 __tp_syscall.compat_pwritev ?
153 {
154 @_SYSCALL_PWRITEV_NAME
155 }
156 probe __tp_syscall.pwritev = kernel.trace("sys_enter")
157 {
158 __set_syscall_pt_regs($regs)
159 @__syscall_gate(@const("__NR_pwritev"))
160 @_SYSCALL_PWRITEV_REGARGS
161 @_SYSCALL_PWRITEV_ARGSTR
162 },
163 {
164 %( @_IS_SREG_KERNEL %? @_SYSCALL_PWRITEV_REGARGS_STORE %)
165 }
166 probe __tp_syscall.compat_pwritev = kernel.trace("sys_enter")
167 {
168 __set_syscall_pt_regs($regs)
169 @__compat_syscall_gate(@const("__NR_compat_pwritev"))
170 @_SYSCALL_COMPAT_PWRITEV_REGARGS
171 @_SYSCALL_PWRITEV_ARGSTR
172 },
173 {
174 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_PWRITEV_REGARGS_STORE %)
175 }
176
177 probe nd_syscall.pwritev.return = nd1_syscall.pwritev.return!, nd2_syscall.pwritev.return!, tp_syscall.pwritev.return
178 { }
179
180 probe nd1_syscall.pwritev.return =
181 kprobe.function("sys_pwritev").return ?,
182 kprobe.function("compat_sys_pwritev").return ?
183 {
184 @_SYSCALL_PWRITEV_NAME
185 @SYSC_RETVALSTR(returnval())
186 }
187
188 /* kernel 4.17+ */
189 probe nd2_syscall.pwritev.return =
190 kprobe.function(@arch_syscall_prefix "sys_pwritev").return ?,
191 kprobe.function(@arch_syscall_prefix "compat_sys_pwritev").return ?
192 {
193 @_SYSCALL_PWRITEV_NAME
194 @SYSC_RETVALSTR(returnval())
195 }
196
197 /* kernel 3.5+, but undesirable because it affects all syscalls */
198 probe tp_syscall.pwritev.return = kernel.trace("sys_exit")
199 {
200 __set_syscall_pt_regs($regs)
201 @__syscall_compat_gate(@const("__NR_pwritev"), @const("__NR_compat_pwritev"))
202 @_SYSCALL_PWRITEV_NAME
203 @SYSC_RETVALSTR($ret)
204 }