]>
Commit | Line | Data |
---|---|---|
ef1b3fda KS |
1 | //===-- sanitizer_common_syscalls.inc ---------------------------*- C++ -*-===// |
2 | // | |
b667dd70 ML |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. | |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
ef1b3fda KS |
6 | // |
7 | //===----------------------------------------------------------------------===// | |
8 | // | |
9 | // Common syscalls handlers for tools like AddressSanitizer, | |
10 | // ThreadSanitizer, MemorySanitizer, etc. | |
11 | // | |
12 | // This file should be included into the tool's interceptor file, | |
13 | // which has to define it's own macros: | |
14 | // COMMON_SYSCALL_PRE_READ_RANGE | |
15 | // Called in prehook for regions that will be read by the kernel and | |
16 | // must be initialized. | |
17 | // COMMON_SYSCALL_PRE_WRITE_RANGE | |
18 | // Called in prehook for regions that will be written to by the kernel | |
19 | // and must be addressable. The actual write range may be smaller than | |
20 | // reported in the prehook. See POST_WRITE_RANGE. | |
21 | // COMMON_SYSCALL_POST_READ_RANGE | |
22 | // Called in posthook for regions that were read by the kernel. Does | |
23 | // not make much sense. | |
24 | // COMMON_SYSCALL_POST_WRITE_RANGE | |
25 | // Called in posthook for regions that were written to by the kernel | |
26 | // and are now initialized. | |
df77f0e4 KS |
27 | // COMMON_SYSCALL_ACQUIRE(addr) |
28 | // Acquire memory visibility from addr. | |
29 | // COMMON_SYSCALL_RELEASE(addr) | |
30 | // Release memory visibility to addr. | |
ef1b3fda KS |
31 | // COMMON_SYSCALL_FD_CLOSE(fd) |
32 | // Called before closing file descriptor fd. | |
df77f0e4 KS |
33 | // COMMON_SYSCALL_FD_ACQUIRE(fd) |
34 | // Acquire memory visibility from fd. | |
35 | // COMMON_SYSCALL_FD_RELEASE(fd) | |
36 | // Release memory visibility to fd. | |
ef1b3fda KS |
37 | // COMMON_SYSCALL_PRE_FORK() |
38 | // Called before fork syscall. | |
39 | // COMMON_SYSCALL_POST_FORK(long res) | |
40 | // Called after fork syscall. | |
41 | //===----------------------------------------------------------------------===// | |
42 | ||
43 | #include "sanitizer_platform.h" | |
44 | #if SANITIZER_LINUX | |
45 | ||
46 | #include "sanitizer_libc.h" | |
47 | ||
48 | #define PRE_SYSCALL(name) \ | |
49 | SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name | |
50 | #define PRE_READ(p, s) COMMON_SYSCALL_PRE_READ_RANGE(p, s) | |
51 | #define PRE_WRITE(p, s) COMMON_SYSCALL_PRE_WRITE_RANGE(p, s) | |
52 | ||
53 | #define POST_SYSCALL(name) \ | |
54 | SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_post_impl_##name | |
55 | #define POST_READ(p, s) COMMON_SYSCALL_POST_READ_RANGE(p, s) | |
56 | #define POST_WRITE(p, s) COMMON_SYSCALL_POST_WRITE_RANGE(p, s) | |
57 | ||
df77f0e4 KS |
58 | #ifndef COMMON_SYSCALL_ACQUIRE |
59 | # define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr)) | |
60 | #endif | |
61 | ||
62 | #ifndef COMMON_SYSCALL_RELEASE | |
63 | # define COMMON_SYSCALL_RELEASE(addr) ((void)(addr)) | |
64 | #endif | |
65 | ||
ef1b3fda | 66 | #ifndef COMMON_SYSCALL_FD_CLOSE |
df77f0e4 KS |
67 | # define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd)) |
68 | #endif | |
69 | ||
70 | #ifndef COMMON_SYSCALL_FD_ACQUIRE | |
71 | # define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd)) | |
72 | #endif | |
73 | ||
74 | #ifndef COMMON_SYSCALL_FD_RELEASE | |
75 | # define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd)) | |
ef1b3fda KS |
76 | #endif |
77 | ||
78 | #ifndef COMMON_SYSCALL_PRE_FORK | |
df77f0e4 | 79 | # define COMMON_SYSCALL_PRE_FORK() {} |
ef1b3fda KS |
80 | #endif |
81 | ||
82 | #ifndef COMMON_SYSCALL_POST_FORK | |
df77f0e4 | 83 | # define COMMON_SYSCALL_POST_FORK(res) {} |
ef1b3fda KS |
84 | #endif |
85 | ||
86 | // FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such). | |
87 | ||
88 | extern "C" { | |
89 | struct sanitizer_kernel_iovec { | |
90 | void *iov_base; | |
91 | unsigned long iov_len; | |
92 | }; | |
93 | ||
94 | struct sanitizer_kernel_msghdr { | |
95 | void *msg_name; | |
96 | int msg_namelen; | |
97 | struct sanitizer_kernel_iovec *msg_iov; | |
98 | unsigned long msg_iovlen; | |
99 | void *msg_control; | |
100 | unsigned long msg_controllen; | |
101 | unsigned msg_flags; | |
102 | }; | |
103 | ||
104 | struct sanitizer_kernel_mmsghdr { | |
105 | struct sanitizer_kernel_msghdr msg_hdr; | |
106 | unsigned msg_len; | |
107 | }; | |
108 | ||
109 | struct sanitizer_kernel_timespec { | |
110 | long tv_sec; | |
111 | long tv_nsec; | |
112 | }; | |
113 | ||
114 | struct sanitizer_kernel_timeval { | |
115 | long tv_sec; | |
116 | long tv_usec; | |
117 | }; | |
118 | ||
119 | struct sanitizer_kernel_rusage { | |
120 | struct sanitizer_kernel_timeval ru_timeval[2]; | |
121 | long ru_long[14]; | |
122 | }; | |
123 | ||
124 | struct sanitizer_kernel_sockaddr { | |
125 | unsigned short sa_family; | |
126 | char sa_data[14]; | |
127 | }; | |
128 | ||
129 | // Real sigset size is always passed as a syscall argument. | |
130 | // Declare it "void" to catch sizeof(kernel_sigset_t). | |
131 | typedef void kernel_sigset_t; | |
132 | ||
133 | static void kernel_write_iovec(const __sanitizer_iovec *iovec, | |
134 | SIZE_T iovlen, SIZE_T maxlen) { | |
135 | for (SIZE_T i = 0; i < iovlen && maxlen; ++i) { | |
136 | SSIZE_T sz = Min(iovec[i].iov_len, maxlen); | |
137 | POST_WRITE(iovec[i].iov_base, sz); | |
138 | maxlen -= sz; | |
139 | } | |
140 | } | |
141 | ||
142 | // This functions uses POST_READ, because it needs to run after syscall to know | |
143 | // the real read range. | |
144 | static void kernel_read_iovec(const __sanitizer_iovec *iovec, | |
145 | SIZE_T iovlen, SIZE_T maxlen) { | |
146 | POST_READ(iovec, sizeof(*iovec) * iovlen); | |
147 | for (SIZE_T i = 0; i < iovlen && maxlen; ++i) { | |
148 | SSIZE_T sz = Min(iovec[i].iov_len, maxlen); | |
149 | POST_READ(iovec[i].iov_base, sz); | |
150 | maxlen -= sz; | |
151 | } | |
152 | } | |
153 | ||
154 | PRE_SYSCALL(recvmsg)(long sockfd, sanitizer_kernel_msghdr *msg, long flags) { | |
155 | PRE_READ(msg, sizeof(*msg)); | |
156 | } | |
157 | ||
158 | POST_SYSCALL(recvmsg)(long res, long sockfd, sanitizer_kernel_msghdr *msg, | |
159 | long flags) { | |
160 | if (res >= 0) { | |
161 | if (msg) { | |
162 | for (unsigned long i = 0; i < msg->msg_iovlen; ++i) { | |
163 | POST_WRITE(msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len); | |
164 | } | |
165 | POST_WRITE(msg->msg_control, msg->msg_controllen); | |
166 | } | |
167 | } | |
168 | } | |
169 | ||
170 | PRE_SYSCALL(recvmmsg)(long fd, sanitizer_kernel_mmsghdr *msg, long vlen, | |
171 | long flags, void *timeout) { | |
172 | PRE_READ(msg, vlen * sizeof(*msg)); | |
173 | } | |
174 | ||
175 | POST_SYSCALL(recvmmsg)(long res, long fd, sanitizer_kernel_mmsghdr *msg, | |
176 | long vlen, long flags, void *timeout) { | |
177 | if (res >= 0) { | |
178 | if (msg) { | |
179 | for (unsigned long i = 0; i < msg->msg_hdr.msg_iovlen; ++i) { | |
180 | POST_WRITE(msg->msg_hdr.msg_iov[i].iov_base, | |
181 | msg->msg_hdr.msg_iov[i].iov_len); | |
182 | } | |
183 | POST_WRITE(msg->msg_hdr.msg_control, msg->msg_hdr.msg_controllen); | |
184 | POST_WRITE(&msg->msg_len, sizeof(msg->msg_len)); | |
185 | } | |
186 | if (timeout) POST_WRITE(timeout, struct_timespec_sz); | |
187 | } | |
188 | } | |
189 | ||
190 | PRE_SYSCALL(read)(long fd, void *buf, uptr count) { | |
191 | if (buf) { | |
192 | PRE_WRITE(buf, count); | |
193 | } | |
194 | } | |
195 | ||
196 | POST_SYSCALL(read)(long res, long fd, void *buf, uptr count) { | |
197 | if (res > 0 && buf) { | |
198 | POST_WRITE(buf, res); | |
199 | } | |
200 | } | |
201 | ||
202 | PRE_SYSCALL(time)(void *tloc) {} | |
203 | ||
204 | POST_SYSCALL(time)(long res, void *tloc) { | |
205 | if (res >= 0) { | |
206 | if (tloc) POST_WRITE(tloc, sizeof(long)); | |
207 | } | |
208 | } | |
209 | ||
210 | PRE_SYSCALL(stime)(void *tptr) {} | |
211 | ||
212 | POST_SYSCALL(stime)(long res, void *tptr) { | |
213 | if (res >= 0) { | |
214 | if (tptr) POST_WRITE(tptr, sizeof(long)); | |
215 | } | |
216 | } | |
217 | ||
218 | PRE_SYSCALL(gettimeofday)(void *tv, void *tz) {} | |
219 | ||
220 | POST_SYSCALL(gettimeofday)(long res, void *tv, void *tz) { | |
221 | if (res >= 0) { | |
222 | if (tv) POST_WRITE(tv, timeval_sz); | |
223 | if (tz) POST_WRITE(tz, struct_timezone_sz); | |
224 | } | |
225 | } | |
226 | ||
227 | PRE_SYSCALL(settimeofday)(void *tv, void *tz) {} | |
228 | ||
229 | POST_SYSCALL(settimeofday)(long res, void *tv, void *tz) { | |
230 | if (res >= 0) { | |
231 | if (tv) POST_WRITE(tv, timeval_sz); | |
232 | if (tz) POST_WRITE(tz, struct_timezone_sz); | |
233 | } | |
234 | } | |
235 | ||
dee5ea7a | 236 | #if !SANITIZER_ANDROID |
ef1b3fda KS |
237 | PRE_SYSCALL(adjtimex)(void *txc_p) {} |
238 | ||
239 | POST_SYSCALL(adjtimex)(long res, void *txc_p) { | |
240 | if (res >= 0) { | |
241 | if (txc_p) POST_WRITE(txc_p, struct_timex_sz); | |
242 | } | |
243 | } | |
dee5ea7a | 244 | #endif |
ef1b3fda KS |
245 | |
246 | PRE_SYSCALL(times)(void *tbuf) {} | |
247 | ||
248 | POST_SYSCALL(times)(long res, void *tbuf) { | |
249 | if (res >= 0) { | |
250 | if (tbuf) POST_WRITE(tbuf, struct_tms_sz); | |
251 | } | |
252 | } | |
253 | ||
254 | PRE_SYSCALL(gettid)() {} | |
255 | ||
256 | POST_SYSCALL(gettid)(long res) {} | |
257 | ||
258 | PRE_SYSCALL(nanosleep)(void *rqtp, void *rmtp) {} | |
259 | ||
260 | POST_SYSCALL(nanosleep)(long res, void *rqtp, void *rmtp) { | |
261 | if (res >= 0) { | |
262 | if (rqtp) POST_WRITE(rqtp, struct_timespec_sz); | |
263 | if (rmtp) POST_WRITE(rmtp, struct_timespec_sz); | |
264 | } | |
265 | } | |
266 | ||
267 | PRE_SYSCALL(alarm)(long seconds) {} | |
268 | ||
269 | POST_SYSCALL(alarm)(long res, long seconds) {} | |
270 | ||
271 | PRE_SYSCALL(getpid)() {} | |
272 | ||
273 | POST_SYSCALL(getpid)(long res) {} | |
274 | ||
275 | PRE_SYSCALL(getppid)() {} | |
276 | ||
277 | POST_SYSCALL(getppid)(long res) {} | |
278 | ||
279 | PRE_SYSCALL(getuid)() {} | |
280 | ||
281 | POST_SYSCALL(getuid)(long res) {} | |
282 | ||
283 | PRE_SYSCALL(geteuid)() {} | |
284 | ||
285 | POST_SYSCALL(geteuid)(long res) {} | |
286 | ||
287 | PRE_SYSCALL(getgid)() {} | |
288 | ||
289 | POST_SYSCALL(getgid)(long res) {} | |
290 | ||
291 | PRE_SYSCALL(getegid)() {} | |
292 | ||
293 | POST_SYSCALL(getegid)(long res) {} | |
294 | ||
295 | PRE_SYSCALL(getresuid)(void *ruid, void *euid, void *suid) {} | |
296 | ||
297 | POST_SYSCALL(getresuid)(long res, void *ruid, void *euid, void *suid) { | |
298 | if (res >= 0) { | |
299 | if (ruid) POST_WRITE(ruid, sizeof(unsigned)); | |
300 | if (euid) POST_WRITE(euid, sizeof(unsigned)); | |
301 | if (suid) POST_WRITE(suid, sizeof(unsigned)); | |
302 | } | |
303 | } | |
304 | ||
305 | PRE_SYSCALL(getresgid)(void *rgid, void *egid, void *sgid) {} | |
306 | ||
307 | POST_SYSCALL(getresgid)(long res, void *rgid, void *egid, void *sgid) { | |
308 | if (res >= 0) { | |
309 | if (rgid) POST_WRITE(rgid, sizeof(unsigned)); | |
310 | if (egid) POST_WRITE(egid, sizeof(unsigned)); | |
311 | if (sgid) POST_WRITE(sgid, sizeof(unsigned)); | |
312 | } | |
313 | } | |
314 | ||
315 | PRE_SYSCALL(getpgid)(long pid) {} | |
316 | ||
317 | POST_SYSCALL(getpgid)(long res, long pid) {} | |
318 | ||
319 | PRE_SYSCALL(getpgrp)() {} | |
320 | ||
321 | POST_SYSCALL(getpgrp)(long res) {} | |
322 | ||
323 | PRE_SYSCALL(getsid)(long pid) {} | |
324 | ||
325 | POST_SYSCALL(getsid)(long res, long pid) {} | |
326 | ||
327 | PRE_SYSCALL(getgroups)(long gidsetsize, void *grouplist) {} | |
328 | ||
329 | POST_SYSCALL(getgroups)(long res, long gidsetsize, | |
330 | __sanitizer___kernel_gid_t *grouplist) { | |
331 | if (res >= 0) { | |
332 | if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist)); | |
333 | } | |
334 | } | |
335 | ||
336 | PRE_SYSCALL(setregid)(long rgid, long egid) {} | |
337 | ||
338 | POST_SYSCALL(setregid)(long res, long rgid, long egid) {} | |
339 | ||
340 | PRE_SYSCALL(setgid)(long gid) {} | |
341 | ||
342 | POST_SYSCALL(setgid)(long res, long gid) {} | |
343 | ||
344 | PRE_SYSCALL(setreuid)(long ruid, long euid) {} | |
345 | ||
346 | POST_SYSCALL(setreuid)(long res, long ruid, long euid) {} | |
347 | ||
348 | PRE_SYSCALL(setuid)(long uid) {} | |
349 | ||
350 | POST_SYSCALL(setuid)(long res, long uid) {} | |
351 | ||
352 | PRE_SYSCALL(setresuid)(long ruid, long euid, long suid) {} | |
353 | ||
354 | POST_SYSCALL(setresuid)(long res, long ruid, long euid, long suid) {} | |
355 | ||
356 | PRE_SYSCALL(setresgid)(long rgid, long egid, long sgid) {} | |
357 | ||
358 | POST_SYSCALL(setresgid)(long res, long rgid, long egid, long sgid) {} | |
359 | ||
360 | PRE_SYSCALL(setfsuid)(long uid) {} | |
361 | ||
362 | POST_SYSCALL(setfsuid)(long res, long uid) {} | |
363 | ||
364 | PRE_SYSCALL(setfsgid)(long gid) {} | |
365 | ||
366 | POST_SYSCALL(setfsgid)(long res, long gid) {} | |
367 | ||
368 | PRE_SYSCALL(setpgid)(long pid, long pgid) {} | |
369 | ||
370 | POST_SYSCALL(setpgid)(long res, long pid, long pgid) {} | |
371 | ||
372 | PRE_SYSCALL(setsid)() {} | |
373 | ||
374 | POST_SYSCALL(setsid)(long res) {} | |
375 | ||
376 | PRE_SYSCALL(setgroups)(long gidsetsize, __sanitizer___kernel_gid_t *grouplist) { | |
377 | if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist)); | |
378 | } | |
379 | ||
380 | POST_SYSCALL(setgroups)(long res, long gidsetsize, | |
381 | __sanitizer___kernel_gid_t *grouplist) {} | |
382 | ||
383 | PRE_SYSCALL(acct)(const void *name) { | |
384 | if (name) | |
385 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
386 | } | |
387 | ||
388 | POST_SYSCALL(acct)(long res, const void *name) {} | |
389 | ||
dee5ea7a KS |
390 | PRE_SYSCALL(capget)(void *header, void *dataptr) { |
391 | if (header) PRE_READ(header, __user_cap_header_struct_sz); | |
392 | } | |
ef1b3fda KS |
393 | |
394 | POST_SYSCALL(capget)(long res, void *header, void *dataptr) { | |
dee5ea7a | 395 | if (res >= 0) |
ef1b3fda | 396 | if (dataptr) POST_WRITE(dataptr, __user_cap_data_struct_sz); |
ef1b3fda KS |
397 | } |
398 | ||
399 | PRE_SYSCALL(capset)(void *header, const void *data) { | |
dee5ea7a | 400 | if (header) PRE_READ(header, __user_cap_header_struct_sz); |
ef1b3fda KS |
401 | if (data) PRE_READ(data, __user_cap_data_struct_sz); |
402 | } | |
403 | ||
dee5ea7a | 404 | POST_SYSCALL(capset)(long res, void *header, const void *data) {} |
ef1b3fda KS |
405 | |
406 | PRE_SYSCALL(personality)(long personality) {} | |
407 | ||
408 | POST_SYSCALL(personality)(long res, long personality) {} | |
409 | ||
410 | PRE_SYSCALL(sigpending)(void *set) {} | |
411 | ||
412 | POST_SYSCALL(sigpending)(long res, void *set) { | |
413 | if (res >= 0) { | |
414 | if (set) POST_WRITE(set, old_sigset_t_sz); | |
415 | } | |
416 | } | |
417 | ||
418 | PRE_SYSCALL(sigprocmask)(long how, void *set, void *oset) {} | |
419 | ||
420 | POST_SYSCALL(sigprocmask)(long res, long how, void *set, void *oset) { | |
421 | if (res >= 0) { | |
422 | if (set) POST_WRITE(set, old_sigset_t_sz); | |
423 | if (oset) POST_WRITE(oset, old_sigset_t_sz); | |
424 | } | |
425 | } | |
426 | ||
427 | PRE_SYSCALL(getitimer)(long which, void *value) {} | |
428 | ||
429 | POST_SYSCALL(getitimer)(long res, long which, void *value) { | |
430 | if (res >= 0) { | |
431 | if (value) POST_WRITE(value, struct_itimerval_sz); | |
432 | } | |
433 | } | |
434 | ||
435 | PRE_SYSCALL(setitimer)(long which, void *value, void *ovalue) {} | |
436 | ||
437 | POST_SYSCALL(setitimer)(long res, long which, void *value, void *ovalue) { | |
438 | if (res >= 0) { | |
439 | if (value) POST_WRITE(value, struct_itimerval_sz); | |
440 | if (ovalue) POST_WRITE(ovalue, struct_itimerval_sz); | |
441 | } | |
442 | } | |
443 | ||
444 | PRE_SYSCALL(timer_create)(long which_clock, void *timer_event_spec, | |
445 | void *created_timer_id) {} | |
446 | ||
447 | POST_SYSCALL(timer_create)(long res, long which_clock, void *timer_event_spec, | |
448 | void *created_timer_id) { | |
449 | if (res >= 0) { | |
450 | if (timer_event_spec) POST_WRITE(timer_event_spec, struct_sigevent_sz); | |
451 | if (created_timer_id) POST_WRITE(created_timer_id, sizeof(long)); | |
452 | } | |
453 | } | |
454 | ||
455 | PRE_SYSCALL(timer_gettime)(long timer_id, void *setting) {} | |
456 | ||
457 | POST_SYSCALL(timer_gettime)(long res, long timer_id, void *setting) { | |
458 | if (res >= 0) { | |
459 | if (setting) POST_WRITE(setting, struct_itimerspec_sz); | |
460 | } | |
461 | } | |
462 | ||
463 | PRE_SYSCALL(timer_getoverrun)(long timer_id) {} | |
464 | ||
465 | POST_SYSCALL(timer_getoverrun)(long res, long timer_id) {} | |
466 | ||
467 | PRE_SYSCALL(timer_settime)(long timer_id, long flags, const void *new_setting, | |
468 | void *old_setting) { | |
469 | if (new_setting) PRE_READ(new_setting, struct_itimerspec_sz); | |
470 | } | |
471 | ||
472 | POST_SYSCALL(timer_settime)(long res, long timer_id, long flags, | |
473 | const void *new_setting, void *old_setting) { | |
474 | if (res >= 0) { | |
475 | if (old_setting) POST_WRITE(old_setting, struct_itimerspec_sz); | |
476 | } | |
477 | } | |
478 | ||
479 | PRE_SYSCALL(timer_delete)(long timer_id) {} | |
480 | ||
481 | POST_SYSCALL(timer_delete)(long res, long timer_id) {} | |
482 | ||
483 | PRE_SYSCALL(clock_settime)(long which_clock, const void *tp) { | |
484 | if (tp) PRE_READ(tp, struct_timespec_sz); | |
485 | } | |
486 | ||
487 | POST_SYSCALL(clock_settime)(long res, long which_clock, const void *tp) {} | |
488 | ||
489 | PRE_SYSCALL(clock_gettime)(long which_clock, void *tp) {} | |
490 | ||
491 | POST_SYSCALL(clock_gettime)(long res, long which_clock, void *tp) { | |
492 | if (res >= 0) { | |
493 | if (tp) POST_WRITE(tp, struct_timespec_sz); | |
494 | } | |
495 | } | |
496 | ||
dee5ea7a | 497 | #if !SANITIZER_ANDROID |
ef1b3fda KS |
498 | PRE_SYSCALL(clock_adjtime)(long which_clock, void *tx) {} |
499 | ||
500 | POST_SYSCALL(clock_adjtime)(long res, long which_clock, void *tx) { | |
501 | if (res >= 0) { | |
502 | if (tx) POST_WRITE(tx, struct_timex_sz); | |
503 | } | |
504 | } | |
dee5ea7a | 505 | #endif |
ef1b3fda KS |
506 | |
507 | PRE_SYSCALL(clock_getres)(long which_clock, void *tp) {} | |
508 | ||
509 | POST_SYSCALL(clock_getres)(long res, long which_clock, void *tp) { | |
510 | if (res >= 0) { | |
511 | if (tp) POST_WRITE(tp, struct_timespec_sz); | |
512 | } | |
513 | } | |
514 | ||
515 | PRE_SYSCALL(clock_nanosleep)(long which_clock, long flags, const void *rqtp, | |
516 | void *rmtp) { | |
517 | if (rqtp) PRE_READ(rqtp, struct_timespec_sz); | |
518 | } | |
519 | ||
520 | POST_SYSCALL(clock_nanosleep)(long res, long which_clock, long flags, | |
521 | const void *rqtp, void *rmtp) { | |
522 | if (res >= 0) { | |
523 | if (rmtp) POST_WRITE(rmtp, struct_timespec_sz); | |
524 | } | |
525 | } | |
526 | ||
527 | PRE_SYSCALL(nice)(long increment) {} | |
528 | ||
529 | POST_SYSCALL(nice)(long res, long increment) {} | |
530 | ||
531 | PRE_SYSCALL(sched_setscheduler)(long pid, long policy, void *param) {} | |
532 | ||
533 | POST_SYSCALL(sched_setscheduler)(long res, long pid, long policy, void *param) { | |
534 | if (res >= 0) { | |
535 | if (param) POST_WRITE(param, struct_sched_param_sz); | |
536 | } | |
537 | } | |
538 | ||
539 | PRE_SYSCALL(sched_setparam)(long pid, void *param) { | |
540 | if (param) PRE_READ(param, struct_sched_param_sz); | |
541 | } | |
542 | ||
543 | POST_SYSCALL(sched_setparam)(long res, long pid, void *param) {} | |
544 | ||
545 | PRE_SYSCALL(sched_getscheduler)(long pid) {} | |
546 | ||
547 | POST_SYSCALL(sched_getscheduler)(long res, long pid) {} | |
548 | ||
549 | PRE_SYSCALL(sched_getparam)(long pid, void *param) {} | |
550 | ||
551 | POST_SYSCALL(sched_getparam)(long res, long pid, void *param) { | |
552 | if (res >= 0) { | |
553 | if (param) POST_WRITE(param, struct_sched_param_sz); | |
554 | } | |
555 | } | |
556 | ||
557 | PRE_SYSCALL(sched_setaffinity)(long pid, long len, void *user_mask_ptr) { | |
558 | if (user_mask_ptr) PRE_READ(user_mask_ptr, len); | |
559 | } | |
560 | ||
561 | POST_SYSCALL(sched_setaffinity)(long res, long pid, long len, | |
562 | void *user_mask_ptr) {} | |
563 | ||
564 | PRE_SYSCALL(sched_getaffinity)(long pid, long len, void *user_mask_ptr) {} | |
565 | ||
566 | POST_SYSCALL(sched_getaffinity)(long res, long pid, long len, | |
567 | void *user_mask_ptr) { | |
568 | if (res >= 0) { | |
569 | if (user_mask_ptr) POST_WRITE(user_mask_ptr, len); | |
570 | } | |
571 | } | |
572 | ||
573 | PRE_SYSCALL(sched_yield)() {} | |
574 | ||
575 | POST_SYSCALL(sched_yield)(long res) {} | |
576 | ||
577 | PRE_SYSCALL(sched_get_priority_max)(long policy) {} | |
578 | ||
579 | POST_SYSCALL(sched_get_priority_max)(long res, long policy) {} | |
580 | ||
581 | PRE_SYSCALL(sched_get_priority_min)(long policy) {} | |
582 | ||
583 | POST_SYSCALL(sched_get_priority_min)(long res, long policy) {} | |
584 | ||
585 | PRE_SYSCALL(sched_rr_get_interval)(long pid, void *interval) {} | |
586 | ||
587 | POST_SYSCALL(sched_rr_get_interval)(long res, long pid, void *interval) { | |
588 | if (res >= 0) { | |
589 | if (interval) POST_WRITE(interval, struct_timespec_sz); | |
590 | } | |
591 | } | |
592 | ||
593 | PRE_SYSCALL(setpriority)(long which, long who, long niceval) {} | |
594 | ||
595 | POST_SYSCALL(setpriority)(long res, long which, long who, long niceval) {} | |
596 | ||
597 | PRE_SYSCALL(getpriority)(long which, long who) {} | |
598 | ||
599 | POST_SYSCALL(getpriority)(long res, long which, long who) {} | |
600 | ||
601 | PRE_SYSCALL(shutdown)(long arg0, long arg1) {} | |
602 | ||
603 | POST_SYSCALL(shutdown)(long res, long arg0, long arg1) {} | |
604 | ||
605 | PRE_SYSCALL(reboot)(long magic1, long magic2, long cmd, void *arg) {} | |
606 | ||
607 | POST_SYSCALL(reboot)(long res, long magic1, long magic2, long cmd, void *arg) {} | |
608 | ||
609 | PRE_SYSCALL(restart_syscall)() {} | |
610 | ||
611 | POST_SYSCALL(restart_syscall)(long res) {} | |
612 | ||
613 | PRE_SYSCALL(kexec_load)(long entry, long nr_segments, void *segments, | |
614 | long flags) {} | |
615 | ||
616 | POST_SYSCALL(kexec_load)(long res, long entry, long nr_segments, void *segments, | |
617 | long flags) { | |
618 | if (res >= 0) { | |
619 | if (segments) POST_WRITE(segments, struct_kexec_segment_sz); | |
620 | } | |
621 | } | |
622 | ||
623 | PRE_SYSCALL(exit)(long error_code) {} | |
624 | ||
625 | POST_SYSCALL(exit)(long res, long error_code) {} | |
626 | ||
627 | PRE_SYSCALL(exit_group)(long error_code) {} | |
628 | ||
629 | POST_SYSCALL(exit_group)(long res, long error_code) {} | |
630 | ||
631 | PRE_SYSCALL(wait4)(long pid, void *stat_addr, long options, void *ru) {} | |
632 | ||
633 | POST_SYSCALL(wait4)(long res, long pid, void *stat_addr, long options, | |
634 | void *ru) { | |
635 | if (res >= 0) { | |
636 | if (stat_addr) POST_WRITE(stat_addr, sizeof(int)); | |
637 | if (ru) POST_WRITE(ru, struct_rusage_sz); | |
638 | } | |
639 | } | |
640 | ||
641 | PRE_SYSCALL(waitid)(long which, long pid, void *infop, long options, void *ru) { | |
642 | } | |
643 | ||
644 | POST_SYSCALL(waitid)(long res, long which, long pid, void *infop, long options, | |
645 | void *ru) { | |
646 | if (res >= 0) { | |
647 | if (infop) POST_WRITE(infop, siginfo_t_sz); | |
648 | if (ru) POST_WRITE(ru, struct_rusage_sz); | |
649 | } | |
650 | } | |
651 | ||
652 | PRE_SYSCALL(waitpid)(long pid, void *stat_addr, long options) {} | |
653 | ||
654 | POST_SYSCALL(waitpid)(long res, long pid, void *stat_addr, long options) { | |
655 | if (res >= 0) { | |
656 | if (stat_addr) POST_WRITE(stat_addr, sizeof(int)); | |
657 | } | |
658 | } | |
659 | ||
660 | PRE_SYSCALL(set_tid_address)(void *tidptr) {} | |
661 | ||
662 | POST_SYSCALL(set_tid_address)(long res, void *tidptr) { | |
663 | if (res >= 0) { | |
664 | if (tidptr) POST_WRITE(tidptr, sizeof(int)); | |
665 | } | |
666 | } | |
667 | ||
668 | PRE_SYSCALL(init_module)(void *umod, long len, const void *uargs) { | |
669 | if (uargs) | |
670 | PRE_READ(uargs, __sanitizer::internal_strlen((const char *)uargs) + 1); | |
671 | } | |
672 | ||
673 | POST_SYSCALL(init_module)(long res, void *umod, long len, const void *uargs) {} | |
674 | ||
675 | PRE_SYSCALL(delete_module)(const void *name_user, long flags) { | |
676 | if (name_user) | |
677 | PRE_READ(name_user, | |
678 | __sanitizer::internal_strlen((const char *)name_user) + 1); | |
679 | } | |
680 | ||
681 | POST_SYSCALL(delete_module)(long res, const void *name_user, long flags) {} | |
682 | ||
683 | PRE_SYSCALL(rt_sigprocmask)(long how, void *set, void *oset, long sigsetsize) {} | |
684 | ||
685 | POST_SYSCALL(rt_sigprocmask)(long res, long how, kernel_sigset_t *set, | |
686 | kernel_sigset_t *oset, long sigsetsize) { | |
687 | if (res >= 0) { | |
688 | if (set) POST_WRITE(set, sigsetsize); | |
689 | if (oset) POST_WRITE(oset, sigsetsize); | |
690 | } | |
691 | } | |
692 | ||
693 | PRE_SYSCALL(rt_sigpending)(void *set, long sigsetsize) {} | |
694 | ||
695 | POST_SYSCALL(rt_sigpending)(long res, kernel_sigset_t *set, long sigsetsize) { | |
696 | if (res >= 0) { | |
697 | if (set) POST_WRITE(set, sigsetsize); | |
698 | } | |
699 | } | |
700 | ||
701 | PRE_SYSCALL(rt_sigtimedwait)(const kernel_sigset_t *uthese, void *uinfo, | |
702 | const void *uts, long sigsetsize) { | |
703 | if (uthese) PRE_READ(uthese, sigsetsize); | |
704 | if (uts) PRE_READ(uts, struct_timespec_sz); | |
705 | } | |
706 | ||
707 | POST_SYSCALL(rt_sigtimedwait)(long res, const void *uthese, void *uinfo, | |
708 | const void *uts, long sigsetsize) { | |
709 | if (res >= 0) { | |
710 | if (uinfo) POST_WRITE(uinfo, siginfo_t_sz); | |
711 | } | |
712 | } | |
713 | ||
714 | PRE_SYSCALL(rt_tgsigqueueinfo)(long tgid, long pid, long sig, void *uinfo) {} | |
715 | ||
716 | POST_SYSCALL(rt_tgsigqueueinfo)(long res, long tgid, long pid, long sig, | |
717 | void *uinfo) { | |
718 | if (res >= 0) { | |
719 | if (uinfo) POST_WRITE(uinfo, siginfo_t_sz); | |
720 | } | |
721 | } | |
722 | ||
723 | PRE_SYSCALL(kill)(long pid, long sig) {} | |
724 | ||
725 | POST_SYSCALL(kill)(long res, long pid, long sig) {} | |
726 | ||
727 | PRE_SYSCALL(tgkill)(long tgid, long pid, long sig) {} | |
728 | ||
729 | POST_SYSCALL(tgkill)(long res, long tgid, long pid, long sig) {} | |
730 | ||
731 | PRE_SYSCALL(tkill)(long pid, long sig) {} | |
732 | ||
733 | POST_SYSCALL(tkill)(long res, long pid, long sig) {} | |
734 | ||
735 | PRE_SYSCALL(rt_sigqueueinfo)(long pid, long sig, void *uinfo) {} | |
736 | ||
737 | POST_SYSCALL(rt_sigqueueinfo)(long res, long pid, long sig, void *uinfo) { | |
738 | if (res >= 0) { | |
739 | if (uinfo) POST_WRITE(uinfo, siginfo_t_sz); | |
740 | } | |
741 | } | |
742 | ||
743 | PRE_SYSCALL(sgetmask)() {} | |
744 | ||
745 | POST_SYSCALL(sgetmask)(long res) {} | |
746 | ||
747 | PRE_SYSCALL(ssetmask)(long newmask) {} | |
748 | ||
749 | POST_SYSCALL(ssetmask)(long res, long newmask) {} | |
750 | ||
751 | PRE_SYSCALL(signal)(long sig, long handler) {} | |
752 | ||
753 | POST_SYSCALL(signal)(long res, long sig, long handler) {} | |
754 | ||
755 | PRE_SYSCALL(pause)() {} | |
756 | ||
757 | POST_SYSCALL(pause)(long res) {} | |
758 | ||
759 | PRE_SYSCALL(sync)() {} | |
760 | ||
761 | POST_SYSCALL(sync)(long res) {} | |
762 | ||
763 | PRE_SYSCALL(fsync)(long fd) {} | |
764 | ||
765 | POST_SYSCALL(fsync)(long res, long fd) {} | |
766 | ||
767 | PRE_SYSCALL(fdatasync)(long fd) {} | |
768 | ||
769 | POST_SYSCALL(fdatasync)(long res, long fd) {} | |
770 | ||
771 | PRE_SYSCALL(bdflush)(long func, long data) {} | |
772 | ||
773 | POST_SYSCALL(bdflush)(long res, long func, long data) {} | |
774 | ||
775 | PRE_SYSCALL(mount)(void *dev_name, void *dir_name, void *type, long flags, | |
776 | void *data) {} | |
777 | ||
778 | POST_SYSCALL(mount)(long res, void *dev_name, void *dir_name, void *type, | |
779 | long flags, void *data) { | |
780 | if (res >= 0) { | |
781 | if (dev_name) | |
782 | POST_WRITE(dev_name, | |
783 | __sanitizer::internal_strlen((const char *)dev_name) + 1); | |
784 | if (dir_name) | |
785 | POST_WRITE(dir_name, | |
786 | __sanitizer::internal_strlen((const char *)dir_name) + 1); | |
787 | if (type) | |
788 | POST_WRITE(type, __sanitizer::internal_strlen((const char *)type) + 1); | |
789 | } | |
790 | } | |
791 | ||
792 | PRE_SYSCALL(umount)(void *name, long flags) {} | |
793 | ||
794 | POST_SYSCALL(umount)(long res, void *name, long flags) { | |
795 | if (res >= 0) { | |
796 | if (name) | |
797 | POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
798 | } | |
799 | } | |
800 | ||
801 | PRE_SYSCALL(oldumount)(void *name) {} | |
802 | ||
803 | POST_SYSCALL(oldumount)(long res, void *name) { | |
804 | if (res >= 0) { | |
805 | if (name) | |
806 | POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
807 | } | |
808 | } | |
809 | ||
810 | PRE_SYSCALL(truncate)(const void *path, long length) { | |
811 | if (path) | |
812 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
813 | } | |
814 | ||
815 | POST_SYSCALL(truncate)(long res, const void *path, long length) {} | |
816 | ||
817 | PRE_SYSCALL(ftruncate)(long fd, long length) {} | |
818 | ||
819 | POST_SYSCALL(ftruncate)(long res, long fd, long length) {} | |
820 | ||
821 | PRE_SYSCALL(stat)(const void *filename, void *statbuf) { | |
822 | if (filename) | |
823 | PRE_READ(filename, | |
824 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
825 | } | |
826 | ||
827 | POST_SYSCALL(stat)(long res, const void *filename, void *statbuf) { | |
828 | if (res >= 0) { | |
829 | if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz); | |
830 | } | |
831 | } | |
832 | ||
866e32ad | 833 | #if !SANITIZER_ANDROID |
ef1b3fda KS |
834 | PRE_SYSCALL(statfs)(const void *path, void *buf) { |
835 | if (path) | |
836 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
837 | } | |
838 | ||
839 | POST_SYSCALL(statfs)(long res, const void *path, void *buf) { | |
840 | if (res >= 0) { | |
841 | if (buf) POST_WRITE(buf, struct_statfs_sz); | |
842 | } | |
843 | } | |
844 | ||
845 | PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) { | |
846 | if (path) | |
847 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
848 | } | |
849 | ||
850 | POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) { | |
851 | if (res >= 0) { | |
852 | if (buf) POST_WRITE(buf, struct_statfs64_sz); | |
853 | } | |
854 | } | |
855 | ||
856 | PRE_SYSCALL(fstatfs)(long fd, void *buf) {} | |
857 | ||
858 | POST_SYSCALL(fstatfs)(long res, long fd, void *buf) { | |
859 | if (res >= 0) { | |
860 | if (buf) POST_WRITE(buf, struct_statfs_sz); | |
861 | } | |
862 | } | |
863 | ||
864 | PRE_SYSCALL(fstatfs64)(long fd, long sz, void *buf) {} | |
865 | ||
866 | POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) { | |
867 | if (res >= 0) { | |
868 | if (buf) POST_WRITE(buf, struct_statfs64_sz); | |
869 | } | |
870 | } | |
866e32ad | 871 | #endif // !SANITIZER_ANDROID |
ef1b3fda KS |
872 | |
873 | PRE_SYSCALL(lstat)(const void *filename, void *statbuf) { | |
874 | if (filename) | |
875 | PRE_READ(filename, | |
876 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
877 | } | |
878 | ||
879 | POST_SYSCALL(lstat)(long res, const void *filename, void *statbuf) { | |
880 | if (res >= 0) { | |
881 | if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz); | |
882 | } | |
883 | } | |
884 | ||
885 | PRE_SYSCALL(fstat)(long fd, void *statbuf) {} | |
886 | ||
887 | POST_SYSCALL(fstat)(long res, long fd, void *statbuf) { | |
888 | if (res >= 0) { | |
889 | if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz); | |
890 | } | |
891 | } | |
892 | ||
893 | PRE_SYSCALL(newstat)(const void *filename, void *statbuf) { | |
894 | if (filename) | |
895 | PRE_READ(filename, | |
896 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
897 | } | |
898 | ||
899 | POST_SYSCALL(newstat)(long res, const void *filename, void *statbuf) { | |
900 | if (res >= 0) { | |
901 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz); | |
902 | } | |
903 | } | |
904 | ||
905 | PRE_SYSCALL(newlstat)(const void *filename, void *statbuf) { | |
906 | if (filename) | |
907 | PRE_READ(filename, | |
908 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
909 | } | |
910 | ||
911 | POST_SYSCALL(newlstat)(long res, const void *filename, void *statbuf) { | |
912 | if (res >= 0) { | |
913 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz); | |
914 | } | |
915 | } | |
916 | ||
917 | PRE_SYSCALL(newfstat)(long fd, void *statbuf) {} | |
918 | ||
919 | POST_SYSCALL(newfstat)(long res, long fd, void *statbuf) { | |
920 | if (res >= 0) { | |
921 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz); | |
922 | } | |
923 | } | |
924 | ||
dee5ea7a | 925 | #if !SANITIZER_ANDROID |
ef1b3fda KS |
926 | PRE_SYSCALL(ustat)(long dev, void *ubuf) {} |
927 | ||
928 | POST_SYSCALL(ustat)(long res, long dev, void *ubuf) { | |
929 | if (res >= 0) { | |
930 | if (ubuf) POST_WRITE(ubuf, struct_ustat_sz); | |
931 | } | |
932 | } | |
dee5ea7a | 933 | #endif // !SANITIZER_ANDROID |
ef1b3fda KS |
934 | |
935 | PRE_SYSCALL(stat64)(const void *filename, void *statbuf) { | |
936 | if (filename) | |
937 | PRE_READ(filename, | |
938 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
939 | } | |
940 | ||
941 | POST_SYSCALL(stat64)(long res, const void *filename, void *statbuf) { | |
942 | if (res >= 0) { | |
943 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz); | |
944 | } | |
945 | } | |
946 | ||
947 | PRE_SYSCALL(fstat64)(long fd, void *statbuf) {} | |
948 | ||
949 | POST_SYSCALL(fstat64)(long res, long fd, void *statbuf) { | |
950 | if (res >= 0) { | |
951 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz); | |
952 | } | |
953 | } | |
954 | ||
955 | PRE_SYSCALL(lstat64)(const void *filename, void *statbuf) { | |
956 | if (filename) | |
957 | PRE_READ(filename, | |
958 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
959 | } | |
960 | ||
961 | POST_SYSCALL(lstat64)(long res, const void *filename, void *statbuf) { | |
962 | if (res >= 0) { | |
963 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz); | |
964 | } | |
965 | } | |
966 | ||
967 | PRE_SYSCALL(setxattr)(const void *path, const void *name, const void *value, | |
968 | long size, long flags) { | |
969 | if (path) | |
970 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
971 | if (name) | |
972 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
973 | if (value) PRE_READ(value, size); | |
974 | } | |
975 | ||
976 | POST_SYSCALL(setxattr)(long res, const void *path, const void *name, | |
977 | const void *value, long size, long flags) {} | |
978 | ||
979 | PRE_SYSCALL(lsetxattr)(const void *path, const void *name, const void *value, | |
980 | long size, long flags) { | |
981 | if (path) | |
982 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
983 | if (name) | |
984 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
985 | if (value) PRE_READ(value, size); | |
986 | } | |
987 | ||
988 | POST_SYSCALL(lsetxattr)(long res, const void *path, const void *name, | |
989 | const void *value, long size, long flags) {} | |
990 | ||
991 | PRE_SYSCALL(fsetxattr)(long fd, const void *name, const void *value, long size, | |
992 | long flags) { | |
993 | if (name) | |
994 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
995 | if (value) PRE_READ(value, size); | |
996 | } | |
997 | ||
998 | POST_SYSCALL(fsetxattr)(long res, long fd, const void *name, const void *value, | |
999 | long size, long flags) {} | |
1000 | ||
1001 | PRE_SYSCALL(getxattr)(const void *path, const void *name, void *value, | |
1002 | long size) { | |
1003 | if (path) | |
1004 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1005 | if (name) | |
1006 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1007 | } | |
1008 | ||
1009 | POST_SYSCALL(getxattr)(long res, const void *path, const void *name, | |
1010 | void *value, long size) { | |
dee5ea7a KS |
1011 | if (size && res > 0) { |
1012 | if (value) POST_WRITE(value, res); | |
ef1b3fda KS |
1013 | } |
1014 | } | |
1015 | ||
1016 | PRE_SYSCALL(lgetxattr)(const void *path, const void *name, void *value, | |
1017 | long size) { | |
1018 | if (path) | |
1019 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1020 | if (name) | |
1021 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1022 | } | |
1023 | ||
1024 | POST_SYSCALL(lgetxattr)(long res, const void *path, const void *name, | |
1025 | void *value, long size) { | |
dee5ea7a KS |
1026 | if (size && res > 0) { |
1027 | if (value) POST_WRITE(value, res); | |
ef1b3fda KS |
1028 | } |
1029 | } | |
1030 | ||
1031 | PRE_SYSCALL(fgetxattr)(long fd, const void *name, void *value, long size) { | |
1032 | if (name) | |
1033 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1034 | } | |
1035 | ||
1036 | POST_SYSCALL(fgetxattr)(long res, long fd, const void *name, void *value, | |
1037 | long size) { | |
dee5ea7a KS |
1038 | if (size && res > 0) { |
1039 | if (value) POST_WRITE(value, res); | |
ef1b3fda KS |
1040 | } |
1041 | } | |
1042 | ||
1043 | PRE_SYSCALL(listxattr)(const void *path, void *list, long size) { | |
1044 | if (path) | |
1045 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1046 | } | |
1047 | ||
1048 | POST_SYSCALL(listxattr)(long res, const void *path, void *list, long size) { | |
dee5ea7a KS |
1049 | if (size && res > 0) { |
1050 | if (list) POST_WRITE(list, res); | |
ef1b3fda KS |
1051 | } |
1052 | } | |
1053 | ||
1054 | PRE_SYSCALL(llistxattr)(const void *path, void *list, long size) { | |
1055 | if (path) | |
1056 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1057 | } | |
1058 | ||
1059 | POST_SYSCALL(llistxattr)(long res, const void *path, void *list, long size) { | |
dee5ea7a KS |
1060 | if (size && res > 0) { |
1061 | if (list) POST_WRITE(list, res); | |
ef1b3fda KS |
1062 | } |
1063 | } | |
1064 | ||
1065 | PRE_SYSCALL(flistxattr)(long fd, void *list, long size) {} | |
1066 | ||
1067 | POST_SYSCALL(flistxattr)(long res, long fd, void *list, long size) { | |
dee5ea7a KS |
1068 | if (size && res > 0) { |
1069 | if (list) POST_WRITE(list, res); | |
ef1b3fda KS |
1070 | } |
1071 | } | |
1072 | ||
1073 | PRE_SYSCALL(removexattr)(const void *path, const void *name) { | |
1074 | if (path) | |
1075 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1076 | if (name) | |
1077 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1078 | } | |
1079 | ||
1080 | POST_SYSCALL(removexattr)(long res, const void *path, const void *name) {} | |
1081 | ||
1082 | PRE_SYSCALL(lremovexattr)(const void *path, const void *name) { | |
1083 | if (path) | |
1084 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1085 | if (name) | |
1086 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1087 | } | |
1088 | ||
1089 | POST_SYSCALL(lremovexattr)(long res, const void *path, const void *name) {} | |
1090 | ||
1091 | PRE_SYSCALL(fremovexattr)(long fd, const void *name) { | |
1092 | if (name) | |
1093 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1094 | } | |
1095 | ||
1096 | POST_SYSCALL(fremovexattr)(long res, long fd, const void *name) {} | |
1097 | ||
1098 | PRE_SYSCALL(brk)(long brk) {} | |
1099 | ||
1100 | POST_SYSCALL(brk)(long res, long brk) {} | |
1101 | ||
1102 | PRE_SYSCALL(mprotect)(long start, long len, long prot) {} | |
1103 | ||
1104 | POST_SYSCALL(mprotect)(long res, long start, long len, long prot) {} | |
1105 | ||
1106 | PRE_SYSCALL(mremap)(long addr, long old_len, long new_len, long flags, | |
1107 | long new_addr) {} | |
1108 | ||
1109 | POST_SYSCALL(mremap)(long res, long addr, long old_len, long new_len, | |
1110 | long flags, long new_addr) {} | |
1111 | ||
1112 | PRE_SYSCALL(remap_file_pages)(long start, long size, long prot, long pgoff, | |
1113 | long flags) {} | |
1114 | ||
1115 | POST_SYSCALL(remap_file_pages)(long res, long start, long size, long prot, | |
1116 | long pgoff, long flags) {} | |
1117 | ||
1118 | PRE_SYSCALL(msync)(long start, long len, long flags) {} | |
1119 | ||
1120 | POST_SYSCALL(msync)(long res, long start, long len, long flags) {} | |
1121 | ||
1122 | PRE_SYSCALL(munmap)(long addr, long len) {} | |
1123 | ||
1124 | POST_SYSCALL(munmap)(long res, long addr, long len) {} | |
1125 | ||
1126 | PRE_SYSCALL(mlock)(long start, long len) {} | |
1127 | ||
1128 | POST_SYSCALL(mlock)(long res, long start, long len) {} | |
1129 | ||
1130 | PRE_SYSCALL(munlock)(long start, long len) {} | |
1131 | ||
1132 | POST_SYSCALL(munlock)(long res, long start, long len) {} | |
1133 | ||
1134 | PRE_SYSCALL(mlockall)(long flags) {} | |
1135 | ||
1136 | POST_SYSCALL(mlockall)(long res, long flags) {} | |
1137 | ||
1138 | PRE_SYSCALL(munlockall)() {} | |
1139 | ||
1140 | POST_SYSCALL(munlockall)(long res) {} | |
1141 | ||
1142 | PRE_SYSCALL(madvise)(long start, long len, long behavior) {} | |
1143 | ||
1144 | POST_SYSCALL(madvise)(long res, long start, long len, long behavior) {} | |
1145 | ||
1146 | PRE_SYSCALL(mincore)(long start, long len, void *vec) {} | |
1147 | ||
1148 | POST_SYSCALL(mincore)(long res, long start, long len, void *vec) { | |
1149 | if (res >= 0) { | |
1150 | if (vec) { | |
1151 | POST_WRITE(vec, (len + GetPageSizeCached() - 1) / GetPageSizeCached()); | |
1152 | } | |
1153 | } | |
1154 | } | |
1155 | ||
1156 | PRE_SYSCALL(pivot_root)(const void *new_root, const void *put_old) { | |
1157 | if (new_root) | |
1158 | PRE_READ(new_root, | |
1159 | __sanitizer::internal_strlen((const char *)new_root) + 1); | |
1160 | if (put_old) | |
1161 | PRE_READ(put_old, __sanitizer::internal_strlen((const char *)put_old) + 1); | |
1162 | } | |
1163 | ||
1164 | POST_SYSCALL(pivot_root)(long res, const void *new_root, const void *put_old) {} | |
1165 | ||
1166 | PRE_SYSCALL(chroot)(const void *filename) { | |
1167 | if (filename) | |
1168 | PRE_READ(filename, | |
1169 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1170 | } | |
1171 | ||
1172 | POST_SYSCALL(chroot)(long res, const void *filename) {} | |
1173 | ||
1174 | PRE_SYSCALL(mknod)(const void *filename, long mode, long dev) { | |
1175 | if (filename) | |
1176 | PRE_READ(filename, | |
1177 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1178 | } | |
1179 | ||
1180 | POST_SYSCALL(mknod)(long res, const void *filename, long mode, long dev) {} | |
1181 | ||
1182 | PRE_SYSCALL(link)(const void *oldname, const void *newname) { | |
1183 | if (oldname) | |
1184 | PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1); | |
1185 | if (newname) | |
1186 | PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1); | |
1187 | } | |
1188 | ||
1189 | POST_SYSCALL(link)(long res, const void *oldname, const void *newname) {} | |
1190 | ||
1191 | PRE_SYSCALL(symlink)(const void *old, const void *new_) { | |
1192 | if (old) PRE_READ(old, __sanitizer::internal_strlen((const char *)old) + 1); | |
1193 | if (new_) | |
1194 | PRE_READ(new_, __sanitizer::internal_strlen((const char *)new_) + 1); | |
1195 | } | |
1196 | ||
1197 | POST_SYSCALL(symlink)(long res, const void *old, const void *new_) {} | |
1198 | ||
1199 | PRE_SYSCALL(unlink)(const void *pathname) { | |
1200 | if (pathname) | |
1201 | PRE_READ(pathname, | |
1202 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
1203 | } | |
1204 | ||
1205 | POST_SYSCALL(unlink)(long res, const void *pathname) {} | |
1206 | ||
1207 | PRE_SYSCALL(rename)(const void *oldname, const void *newname) { | |
1208 | if (oldname) | |
1209 | PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1); | |
1210 | if (newname) | |
1211 | PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1); | |
1212 | } | |
1213 | ||
1214 | POST_SYSCALL(rename)(long res, const void *oldname, const void *newname) {} | |
1215 | ||
1216 | PRE_SYSCALL(chmod)(const void *filename, long mode) { | |
1217 | if (filename) | |
1218 | PRE_READ(filename, | |
1219 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1220 | } | |
1221 | ||
1222 | POST_SYSCALL(chmod)(long res, const void *filename, long mode) {} | |
1223 | ||
1224 | PRE_SYSCALL(fchmod)(long fd, long mode) {} | |
1225 | ||
1226 | POST_SYSCALL(fchmod)(long res, long fd, long mode) {} | |
1227 | ||
1228 | PRE_SYSCALL(fcntl)(long fd, long cmd, long arg) {} | |
1229 | ||
1230 | POST_SYSCALL(fcntl)(long res, long fd, long cmd, long arg) {} | |
1231 | ||
1232 | PRE_SYSCALL(fcntl64)(long fd, long cmd, long arg) {} | |
1233 | ||
1234 | POST_SYSCALL(fcntl64)(long res, long fd, long cmd, long arg) {} | |
1235 | ||
1236 | PRE_SYSCALL(pipe)(void *fildes) {} | |
1237 | ||
1238 | POST_SYSCALL(pipe)(long res, void *fildes) { | |
10189819 MO |
1239 | if (res >= 0) |
1240 | if (fildes) POST_WRITE(fildes, sizeof(int) * 2); | |
ef1b3fda KS |
1241 | } |
1242 | ||
1243 | PRE_SYSCALL(pipe2)(void *fildes, long flags) {} | |
1244 | ||
1245 | POST_SYSCALL(pipe2)(long res, void *fildes, long flags) { | |
10189819 MO |
1246 | if (res >= 0) |
1247 | if (fildes) POST_WRITE(fildes, sizeof(int) * 2); | |
ef1b3fda KS |
1248 | } |
1249 | ||
1250 | PRE_SYSCALL(dup)(long fildes) {} | |
1251 | ||
1252 | POST_SYSCALL(dup)(long res, long fildes) {} | |
1253 | ||
1254 | PRE_SYSCALL(dup2)(long oldfd, long newfd) {} | |
1255 | ||
1256 | POST_SYSCALL(dup2)(long res, long oldfd, long newfd) {} | |
1257 | ||
1258 | PRE_SYSCALL(dup3)(long oldfd, long newfd, long flags) {} | |
1259 | ||
1260 | POST_SYSCALL(dup3)(long res, long oldfd, long newfd, long flags) {} | |
1261 | ||
1262 | PRE_SYSCALL(ioperm)(long from, long num, long on) {} | |
1263 | ||
1264 | POST_SYSCALL(ioperm)(long res, long from, long num, long on) {} | |
1265 | ||
1266 | PRE_SYSCALL(ioctl)(long fd, long cmd, long arg) {} | |
1267 | ||
1268 | POST_SYSCALL(ioctl)(long res, long fd, long cmd, long arg) {} | |
1269 | ||
1270 | PRE_SYSCALL(flock)(long fd, long cmd) {} | |
1271 | ||
1272 | POST_SYSCALL(flock)(long res, long fd, long cmd) {} | |
1273 | ||
df77f0e4 KS |
1274 | PRE_SYSCALL(io_setup)(long nr_reqs, void **ctx) { |
1275 | if (ctx) PRE_WRITE(ctx, sizeof(*ctx)); | |
1276 | } | |
ef1b3fda | 1277 | |
df77f0e4 | 1278 | POST_SYSCALL(io_setup)(long res, long nr_reqs, void **ctx) { |
ef1b3fda | 1279 | if (res >= 0) { |
df77f0e4 KS |
1280 | if (ctx) POST_WRITE(ctx, sizeof(*ctx)); |
1281 | // (*ctx) is actually a pointer to a kernel mapped page, and there are | |
1282 | // people out there who are crazy enough to peek into that page's 32-byte | |
1283 | // header. | |
1284 | if (*ctx) POST_WRITE(*ctx, 32); | |
ef1b3fda KS |
1285 | } |
1286 | } | |
1287 | ||
1288 | PRE_SYSCALL(io_destroy)(long ctx) {} | |
1289 | ||
1290 | POST_SYSCALL(io_destroy)(long res, long ctx) {} | |
1291 | ||
df77f0e4 KS |
1292 | PRE_SYSCALL(io_getevents)(long ctx_id, long min_nr, long nr, |
1293 | __sanitizer_io_event *ioevpp, void *timeout) { | |
ef1b3fda KS |
1294 | if (timeout) PRE_READ(timeout, struct_timespec_sz); |
1295 | } | |
1296 | ||
1297 | POST_SYSCALL(io_getevents)(long res, long ctx_id, long min_nr, long nr, | |
df77f0e4 | 1298 | __sanitizer_io_event *ioevpp, void *timeout) { |
ef1b3fda | 1299 | if (res >= 0) { |
df77f0e4 | 1300 | if (ioevpp) POST_WRITE(ioevpp, res * sizeof(*ioevpp)); |
ef1b3fda KS |
1301 | if (timeout) POST_WRITE(timeout, struct_timespec_sz); |
1302 | } | |
df77f0e4 KS |
1303 | for (long i = 0; i < res; i++) { |
1304 | // We synchronize io_submit -> io_getevents/io_cancel using the | |
1305 | // user-provided data context. Data is not necessary a pointer, it can be | |
1306 | // an int, 0 or whatever; acquire/release will correctly handle this. | |
1307 | // This scheme can lead to false negatives, e.g. when all operations | |
1308 | // synchronize on 0. But there does not seem to be a better solution | |
1309 | // (except wrapping all operations in own context, which is unreliable). | |
1310 | // We can not reliably extract fildes in io_getevents. | |
1311 | COMMON_SYSCALL_ACQUIRE((void*)ioevpp[i].data); | |
1312 | } | |
1313 | } | |
1314 | ||
1315 | PRE_SYSCALL(io_submit)(long ctx_id, long nr, __sanitizer_iocb **iocbpp) { | |
1316 | for (long i = 0; i < nr; ++i) { | |
1317 | uptr op = iocbpp[i]->aio_lio_opcode; | |
1318 | void *data = (void*)iocbpp[i]->aio_data; | |
1319 | void *buf = (void*)iocbpp[i]->aio_buf; | |
1320 | uptr len = (uptr)iocbpp[i]->aio_nbytes; | |
1321 | if (op == iocb_cmd_pwrite && buf && len) { | |
1322 | PRE_READ(buf, len); | |
1323 | } else if (op == iocb_cmd_pread && buf && len) { | |
1324 | POST_WRITE(buf, len); | |
1325 | } else if (op == iocb_cmd_pwritev) { | |
866e32ad | 1326 | __sanitizer_iovec *iovec = (__sanitizer_iovec*)buf; |
df77f0e4 | 1327 | for (uptr v = 0; v < len; v++) |
866e32ad | 1328 | PRE_READ(iovec[v].iov_base, iovec[v].iov_len); |
df77f0e4 | 1329 | } else if (op == iocb_cmd_preadv) { |
866e32ad | 1330 | __sanitizer_iovec *iovec = (__sanitizer_iovec*)buf; |
df77f0e4 | 1331 | for (uptr v = 0; v < len; v++) |
866e32ad | 1332 | POST_WRITE(iovec[v].iov_base, iovec[v].iov_len); |
df77f0e4 KS |
1333 | } |
1334 | // See comment in io_getevents. | |
1335 | COMMON_SYSCALL_RELEASE(data); | |
1336 | } | |
ef1b3fda KS |
1337 | } |
1338 | ||
df77f0e4 KS |
1339 | POST_SYSCALL(io_submit)(long res, long ctx_id, long nr, |
1340 | __sanitizer_iocb **iocbpp) {} | |
ef1b3fda | 1341 | |
df77f0e4 KS |
1342 | PRE_SYSCALL(io_cancel)(long ctx_id, __sanitizer_iocb *iocb, |
1343 | __sanitizer_io_event *result) { | |
1344 | } | |
ef1b3fda | 1345 | |
df77f0e4 KS |
1346 | POST_SYSCALL(io_cancel)(long res, long ctx_id, __sanitizer_iocb *iocb, |
1347 | __sanitizer_io_event *result) { | |
1348 | if (res == 0) { | |
1349 | if (result) { | |
1350 | // See comment in io_getevents. | |
1351 | COMMON_SYSCALL_ACQUIRE((void*)result->data); | |
1352 | POST_WRITE(result, sizeof(*result)); | |
1353 | } | |
1354 | if (iocb) | |
1355 | POST_WRITE(iocb, sizeof(*iocb)); | |
ef1b3fda KS |
1356 | } |
1357 | } | |
1358 | ||
1359 | PRE_SYSCALL(sendfile)(long out_fd, long in_fd, void *offset, long count) {} | |
1360 | ||
1361 | POST_SYSCALL(sendfile)(long res, long out_fd, long in_fd, | |
1362 | __sanitizer___kernel_off_t *offset, long count) { | |
1363 | if (res >= 0) { | |
1364 | if (offset) POST_WRITE(offset, sizeof(*offset)); | |
1365 | } | |
1366 | } | |
1367 | ||
1368 | PRE_SYSCALL(sendfile64)(long out_fd, long in_fd, void *offset, long count) {} | |
1369 | ||
1370 | POST_SYSCALL(sendfile64)(long res, long out_fd, long in_fd, | |
1371 | __sanitizer___kernel_loff_t *offset, long count) { | |
1372 | if (res >= 0) { | |
1373 | if (offset) POST_WRITE(offset, sizeof(*offset)); | |
1374 | } | |
1375 | } | |
1376 | ||
1377 | PRE_SYSCALL(readlink)(const void *path, void *buf, long bufsiz) { | |
1378 | if (path) | |
1379 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
1380 | } | |
1381 | ||
1382 | POST_SYSCALL(readlink)(long res, const void *path, void *buf, long bufsiz) { | |
1383 | if (res >= 0) { | |
1384 | if (buf) | |
1385 | POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1); | |
1386 | } | |
1387 | } | |
1388 | ||
1389 | PRE_SYSCALL(creat)(const void *pathname, long mode) { | |
1390 | if (pathname) | |
1391 | PRE_READ(pathname, | |
1392 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
1393 | } | |
1394 | ||
1395 | POST_SYSCALL(creat)(long res, const void *pathname, long mode) {} | |
1396 | ||
1397 | PRE_SYSCALL(open)(const void *filename, long flags, long mode) { | |
1398 | if (filename) | |
1399 | PRE_READ(filename, | |
1400 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1401 | } | |
1402 | ||
1403 | POST_SYSCALL(open)(long res, const void *filename, long flags, long mode) {} | |
1404 | ||
1405 | PRE_SYSCALL(close)(long fd) { | |
1406 | COMMON_SYSCALL_FD_CLOSE((int)fd); | |
1407 | } | |
1408 | ||
1409 | POST_SYSCALL(close)(long res, long fd) {} | |
1410 | ||
1411 | PRE_SYSCALL(access)(const void *filename, long mode) { | |
1412 | if (filename) | |
1413 | PRE_READ(filename, | |
1414 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1415 | } | |
1416 | ||
1417 | POST_SYSCALL(access)(long res, const void *filename, long mode) {} | |
1418 | ||
1419 | PRE_SYSCALL(vhangup)() {} | |
1420 | ||
1421 | POST_SYSCALL(vhangup)(long res) {} | |
1422 | ||
1423 | PRE_SYSCALL(chown)(const void *filename, long user, long group) { | |
1424 | if (filename) | |
1425 | PRE_READ(filename, | |
1426 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1427 | } | |
1428 | ||
1429 | POST_SYSCALL(chown)(long res, const void *filename, long user, long group) {} | |
1430 | ||
1431 | PRE_SYSCALL(lchown)(const void *filename, long user, long group) { | |
1432 | if (filename) | |
1433 | PRE_READ(filename, | |
1434 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1435 | } | |
1436 | ||
1437 | POST_SYSCALL(lchown)(long res, const void *filename, long user, long group) {} | |
1438 | ||
1439 | PRE_SYSCALL(fchown)(long fd, long user, long group) {} | |
1440 | ||
1441 | POST_SYSCALL(fchown)(long res, long fd, long user, long group) {} | |
1442 | ||
d886f7cc | 1443 | #if SANITIZER_USES_UID16_SYSCALLS |
ef1b3fda KS |
1444 | PRE_SYSCALL(chown16)(const void *filename, long user, long group) { |
1445 | if (filename) | |
1446 | PRE_READ(filename, | |
1447 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1448 | } | |
1449 | ||
1450 | POST_SYSCALL(chown16)(long res, const void *filename, long user, long group) {} | |
1451 | ||
1452 | PRE_SYSCALL(lchown16)(const void *filename, long user, long group) { | |
1453 | if (filename) | |
1454 | PRE_READ(filename, | |
1455 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1456 | } | |
1457 | ||
1458 | POST_SYSCALL(lchown16)(long res, const void *filename, long user, long group) {} | |
1459 | ||
1460 | PRE_SYSCALL(fchown16)(long fd, long user, long group) {} | |
1461 | ||
1462 | POST_SYSCALL(fchown16)(long res, long fd, long user, long group) {} | |
1463 | ||
1464 | PRE_SYSCALL(setregid16)(long rgid, long egid) {} | |
1465 | ||
1466 | POST_SYSCALL(setregid16)(long res, long rgid, long egid) {} | |
1467 | ||
1468 | PRE_SYSCALL(setgid16)(long gid) {} | |
1469 | ||
1470 | POST_SYSCALL(setgid16)(long res, long gid) {} | |
1471 | ||
1472 | PRE_SYSCALL(setreuid16)(long ruid, long euid) {} | |
1473 | ||
1474 | POST_SYSCALL(setreuid16)(long res, long ruid, long euid) {} | |
1475 | ||
1476 | PRE_SYSCALL(setuid16)(long uid) {} | |
1477 | ||
1478 | POST_SYSCALL(setuid16)(long res, long uid) {} | |
1479 | ||
1480 | PRE_SYSCALL(setresuid16)(long ruid, long euid, long suid) {} | |
1481 | ||
1482 | POST_SYSCALL(setresuid16)(long res, long ruid, long euid, long suid) {} | |
1483 | ||
1484 | PRE_SYSCALL(getresuid16)(void *ruid, void *euid, void *suid) {} | |
1485 | ||
1486 | POST_SYSCALL(getresuid16)(long res, __sanitizer___kernel_old_uid_t *ruid, | |
1487 | __sanitizer___kernel_old_uid_t *euid, | |
1488 | __sanitizer___kernel_old_uid_t *suid) { | |
1489 | if (res >= 0) { | |
1490 | if (ruid) POST_WRITE(ruid, sizeof(*ruid)); | |
1491 | if (euid) POST_WRITE(euid, sizeof(*euid)); | |
1492 | if (suid) POST_WRITE(suid, sizeof(*suid)); | |
1493 | } | |
1494 | } | |
1495 | ||
1496 | PRE_SYSCALL(setresgid16)(long rgid, long egid, long sgid) {} | |
1497 | ||
1498 | POST_SYSCALL(setresgid16)(long res, long rgid, long egid, long sgid) {} | |
1499 | ||
1500 | PRE_SYSCALL(getresgid16)(void *rgid, void *egid, void *sgid) {} | |
1501 | ||
1502 | POST_SYSCALL(getresgid16)(long res, __sanitizer___kernel_old_gid_t *rgid, | |
1503 | __sanitizer___kernel_old_gid_t *egid, | |
1504 | __sanitizer___kernel_old_gid_t *sgid) { | |
1505 | if (res >= 0) { | |
1506 | if (rgid) POST_WRITE(rgid, sizeof(*rgid)); | |
1507 | if (egid) POST_WRITE(egid, sizeof(*egid)); | |
1508 | if (sgid) POST_WRITE(sgid, sizeof(*sgid)); | |
1509 | } | |
1510 | } | |
1511 | ||
1512 | PRE_SYSCALL(setfsuid16)(long uid) {} | |
1513 | ||
1514 | POST_SYSCALL(setfsuid16)(long res, long uid) {} | |
1515 | ||
1516 | PRE_SYSCALL(setfsgid16)(long gid) {} | |
1517 | ||
1518 | POST_SYSCALL(setfsgid16)(long res, long gid) {} | |
1519 | ||
1520 | PRE_SYSCALL(getgroups16)(long gidsetsize, | |
1521 | __sanitizer___kernel_old_gid_t *grouplist) {} | |
1522 | ||
1523 | POST_SYSCALL(getgroups16)(long res, long gidsetsize, | |
1524 | __sanitizer___kernel_old_gid_t *grouplist) { | |
1525 | if (res >= 0) { | |
1526 | if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist)); | |
1527 | } | |
1528 | } | |
1529 | ||
1530 | PRE_SYSCALL(setgroups16)(long gidsetsize, | |
1531 | __sanitizer___kernel_old_gid_t *grouplist) { | |
1532 | if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist)); | |
1533 | } | |
1534 | ||
1535 | POST_SYSCALL(setgroups16)(long res, long gidsetsize, | |
1536 | __sanitizer___kernel_old_gid_t *grouplist) {} | |
1537 | ||
1538 | PRE_SYSCALL(getuid16)() {} | |
1539 | ||
1540 | POST_SYSCALL(getuid16)(long res) {} | |
1541 | ||
1542 | PRE_SYSCALL(geteuid16)() {} | |
1543 | ||
1544 | POST_SYSCALL(geteuid16)(long res) {} | |
1545 | ||
1546 | PRE_SYSCALL(getgid16)() {} | |
1547 | ||
1548 | POST_SYSCALL(getgid16)(long res) {} | |
1549 | ||
1550 | PRE_SYSCALL(getegid16)() {} | |
1551 | ||
1552 | POST_SYSCALL(getegid16)(long res) {} | |
d886f7cc | 1553 | #endif // SANITIZER_USES_UID16_SYSCALLS |
ef1b3fda KS |
1554 | |
1555 | PRE_SYSCALL(utime)(void *filename, void *times) {} | |
1556 | ||
1557 | POST_SYSCALL(utime)(long res, void *filename, void *times) { | |
1558 | if (res >= 0) { | |
1559 | if (filename) | |
1560 | POST_WRITE(filename, | |
1561 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1562 | if (times) POST_WRITE(times, struct_utimbuf_sz); | |
1563 | } | |
1564 | } | |
1565 | ||
1566 | PRE_SYSCALL(utimes)(void *filename, void *utimes) {} | |
1567 | ||
1568 | POST_SYSCALL(utimes)(long res, void *filename, void *utimes) { | |
1569 | if (res >= 0) { | |
1570 | if (filename) | |
1571 | POST_WRITE(filename, | |
1572 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1573 | if (utimes) POST_WRITE(utimes, timeval_sz); | |
1574 | } | |
1575 | } | |
1576 | ||
1577 | PRE_SYSCALL(lseek)(long fd, long offset, long origin) {} | |
1578 | ||
1579 | POST_SYSCALL(lseek)(long res, long fd, long offset, long origin) {} | |
1580 | ||
1581 | PRE_SYSCALL(llseek)(long fd, long offset_high, long offset_low, void *result, | |
1582 | long origin) {} | |
1583 | ||
1584 | POST_SYSCALL(llseek)(long res, long fd, long offset_high, long offset_low, | |
1585 | void *result, long origin) { | |
1586 | if (res >= 0) { | |
1587 | if (result) POST_WRITE(result, sizeof(long long)); | |
1588 | } | |
1589 | } | |
1590 | ||
1591 | PRE_SYSCALL(readv)(long fd, const __sanitizer_iovec *vec, long vlen) {} | |
1592 | ||
1593 | POST_SYSCALL(readv)(long res, long fd, const __sanitizer_iovec *vec, | |
1594 | long vlen) { | |
1595 | if (res >= 0) { | |
1596 | if (vec) kernel_write_iovec(vec, vlen, res); | |
1597 | } | |
1598 | } | |
1599 | ||
1600 | PRE_SYSCALL(write)(long fd, const void *buf, long count) { | |
1601 | if (buf) PRE_READ(buf, count); | |
1602 | } | |
1603 | ||
1604 | POST_SYSCALL(write)(long res, long fd, const void *buf, long count) {} | |
1605 | ||
1606 | PRE_SYSCALL(writev)(long fd, const __sanitizer_iovec *vec, long vlen) {} | |
1607 | ||
1608 | POST_SYSCALL(writev)(long res, long fd, const __sanitizer_iovec *vec, | |
1609 | long vlen) { | |
1610 | if (res >= 0) { | |
1611 | if (vec) kernel_read_iovec(vec, vlen, res); | |
1612 | } | |
1613 | } | |
1614 | ||
1615 | #ifdef _LP64 | |
1616 | PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos) {} | |
1617 | ||
1618 | POST_SYSCALL(pread64)(long res, long fd, void *buf, long count, long pos) { | |
1619 | if (res >= 0) { | |
1620 | if (buf) POST_WRITE(buf, res); | |
1621 | } | |
1622 | } | |
1623 | ||
1624 | PRE_SYSCALL(pwrite64)(long fd, const void *buf, long count, long pos) { | |
1625 | if (buf) PRE_READ(buf, count); | |
1626 | } | |
1627 | ||
1628 | POST_SYSCALL(pwrite64)(long res, long fd, const void *buf, long count, | |
1629 | long pos) {} | |
1630 | #else | |
1631 | PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos0, long pos1) {} | |
1632 | ||
1633 | POST_SYSCALL(pread64)(long res, long fd, void *buf, long count, long pos0, | |
1634 | long pos1) { | |
1635 | if (res >= 0) { | |
1636 | if (buf) POST_WRITE(buf, res); | |
1637 | } | |
1638 | } | |
1639 | ||
1640 | PRE_SYSCALL(pwrite64)(long fd, const void *buf, long count, long pos0, | |
1641 | long pos1) { | |
1642 | if (buf) PRE_READ(buf, count); | |
1643 | } | |
1644 | ||
1645 | POST_SYSCALL(pwrite64)(long res, long fd, const void *buf, long count, | |
1646 | long pos0, long pos1) {} | |
1647 | #endif | |
1648 | ||
1649 | PRE_SYSCALL(preadv)(long fd, const __sanitizer_iovec *vec, long vlen, | |
1650 | long pos_l, long pos_h) {} | |
1651 | ||
1652 | POST_SYSCALL(preadv)(long res, long fd, const __sanitizer_iovec *vec, long vlen, | |
1653 | long pos_l, long pos_h) { | |
1654 | if (res >= 0) { | |
1655 | if (vec) kernel_write_iovec(vec, vlen, res); | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | PRE_SYSCALL(pwritev)(long fd, const __sanitizer_iovec *vec, long vlen, | |
1660 | long pos_l, long pos_h) {} | |
1661 | ||
1662 | POST_SYSCALL(pwritev)(long res, long fd, const __sanitizer_iovec *vec, | |
1663 | long vlen, long pos_l, long pos_h) { | |
1664 | if (res >= 0) { | |
1665 | if (vec) kernel_read_iovec(vec, vlen, res); | |
1666 | } | |
1667 | } | |
1668 | ||
1669 | PRE_SYSCALL(getcwd)(void *buf, long size) {} | |
1670 | ||
1671 | POST_SYSCALL(getcwd)(long res, void *buf, long size) { | |
1672 | if (res >= 0) { | |
1673 | if (buf) | |
1674 | POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1); | |
1675 | } | |
1676 | } | |
1677 | ||
1678 | PRE_SYSCALL(mkdir)(const void *pathname, long mode) { | |
1679 | if (pathname) | |
1680 | PRE_READ(pathname, | |
1681 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
1682 | } | |
1683 | ||
1684 | POST_SYSCALL(mkdir)(long res, const void *pathname, long mode) {} | |
1685 | ||
1686 | PRE_SYSCALL(chdir)(const void *filename) { | |
1687 | if (filename) | |
1688 | PRE_READ(filename, | |
1689 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
1690 | } | |
1691 | ||
1692 | POST_SYSCALL(chdir)(long res, const void *filename) {} | |
1693 | ||
1694 | PRE_SYSCALL(fchdir)(long fd) {} | |
1695 | ||
1696 | POST_SYSCALL(fchdir)(long res, long fd) {} | |
1697 | ||
1698 | PRE_SYSCALL(rmdir)(const void *pathname) { | |
1699 | if (pathname) | |
1700 | PRE_READ(pathname, | |
1701 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
1702 | } | |
1703 | ||
1704 | POST_SYSCALL(rmdir)(long res, const void *pathname) {} | |
1705 | ||
1706 | PRE_SYSCALL(lookup_dcookie)(u64 cookie64, void *buf, long len) {} | |
1707 | ||
1708 | POST_SYSCALL(lookup_dcookie)(long res, u64 cookie64, void *buf, long len) { | |
1709 | if (res >= 0) { | |
1710 | if (buf) | |
1711 | POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1); | |
1712 | } | |
1713 | } | |
1714 | ||
1715 | PRE_SYSCALL(quotactl)(long cmd, const void *special, long id, void *addr) { | |
1716 | if (special) | |
1717 | PRE_READ(special, __sanitizer::internal_strlen((const char *)special) + 1); | |
1718 | } | |
1719 | ||
1720 | POST_SYSCALL(quotactl)(long res, long cmd, const void *special, long id, | |
1721 | void *addr) {} | |
1722 | ||
1723 | PRE_SYSCALL(getdents)(long fd, void *dirent, long count) {} | |
1724 | ||
1725 | POST_SYSCALL(getdents)(long res, long fd, void *dirent, long count) { | |
1726 | if (res >= 0) { | |
1727 | if (dirent) POST_WRITE(dirent, res); | |
1728 | } | |
1729 | } | |
1730 | ||
1731 | PRE_SYSCALL(getdents64)(long fd, void *dirent, long count) {} | |
1732 | ||
1733 | POST_SYSCALL(getdents64)(long res, long fd, void *dirent, long count) { | |
1734 | if (res >= 0) { | |
1735 | if (dirent) POST_WRITE(dirent, res); | |
1736 | } | |
1737 | } | |
1738 | ||
1739 | PRE_SYSCALL(setsockopt)(long fd, long level, long optname, void *optval, | |
1740 | long optlen) {} | |
1741 | ||
1742 | POST_SYSCALL(setsockopt)(long res, long fd, long level, long optname, | |
1743 | void *optval, long optlen) { | |
1744 | if (res >= 0) { | |
1745 | if (optval) | |
1746 | POST_WRITE(optval, | |
1747 | __sanitizer::internal_strlen((const char *)optval) + 1); | |
1748 | } | |
1749 | } | |
1750 | ||
1751 | PRE_SYSCALL(getsockopt)(long fd, long level, long optname, void *optval, | |
1752 | void *optlen) {} | |
1753 | ||
1754 | POST_SYSCALL(getsockopt)(long res, long fd, long level, long optname, | |
1755 | void *optval, void *optlen) { | |
1756 | if (res >= 0) { | |
1757 | if (optval) | |
1758 | POST_WRITE(optval, | |
1759 | __sanitizer::internal_strlen((const char *)optval) + 1); | |
1760 | if (optlen) POST_WRITE(optlen, sizeof(int)); | |
1761 | } | |
1762 | } | |
1763 | ||
1764 | PRE_SYSCALL(bind)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {} | |
1765 | ||
1766 | POST_SYSCALL(bind)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1767 | long arg2) { | |
1768 | if (res >= 0) { | |
1769 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1770 | } | |
1771 | } | |
1772 | ||
1773 | PRE_SYSCALL(connect)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {} | |
1774 | ||
1775 | POST_SYSCALL(connect)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1776 | long arg2) { | |
1777 | if (res >= 0) { | |
1778 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1779 | } | |
1780 | } | |
1781 | ||
1782 | PRE_SYSCALL(accept)(long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {} | |
1783 | ||
1784 | POST_SYSCALL(accept)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1785 | void *arg2) { | |
1786 | if (res >= 0) { | |
1787 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1788 | if (arg2) POST_WRITE(arg2, sizeof(unsigned)); | |
1789 | } | |
1790 | } | |
1791 | ||
1792 | PRE_SYSCALL(accept4)(long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2, | |
1793 | long arg3) {} | |
1794 | ||
1795 | POST_SYSCALL(accept4)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1796 | void *arg2, long arg3) { | |
1797 | if (res >= 0) { | |
1798 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1799 | if (arg2) POST_WRITE(arg2, sizeof(unsigned)); | |
1800 | } | |
1801 | } | |
1802 | ||
1803 | PRE_SYSCALL(getsockname)(long arg0, sanitizer_kernel_sockaddr *arg1, | |
1804 | void *arg2) {} | |
1805 | ||
1806 | POST_SYSCALL(getsockname)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1807 | void *arg2) { | |
1808 | if (res >= 0) { | |
1809 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1810 | if (arg2) POST_WRITE(arg2, sizeof(unsigned)); | |
1811 | } | |
1812 | } | |
1813 | ||
1814 | PRE_SYSCALL(getpeername)(long arg0, sanitizer_kernel_sockaddr *arg1, | |
1815 | void *arg2) {} | |
1816 | ||
1817 | POST_SYSCALL(getpeername)(long res, long arg0, sanitizer_kernel_sockaddr *arg1, | |
1818 | void *arg2) { | |
1819 | if (res >= 0) { | |
1820 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
1821 | if (arg2) POST_WRITE(arg2, sizeof(unsigned)); | |
1822 | } | |
1823 | } | |
1824 | ||
1825 | PRE_SYSCALL(send)(long arg0, void *arg1, long arg2, long arg3) {} | |
1826 | ||
1827 | POST_SYSCALL(send)(long res, long arg0, void *arg1, long arg2, long arg3) { | |
1828 | if (res) { | |
1829 | if (arg1) POST_READ(arg1, res); | |
1830 | } | |
1831 | } | |
1832 | ||
1833 | PRE_SYSCALL(sendto)(long arg0, void *arg1, long arg2, long arg3, | |
1834 | sanitizer_kernel_sockaddr *arg4, long arg5) {} | |
1835 | ||
1836 | POST_SYSCALL(sendto)(long res, long arg0, void *arg1, long arg2, long arg3, | |
1837 | sanitizer_kernel_sockaddr *arg4, long arg5) { | |
1838 | if (res >= 0) { | |
1839 | if (arg1) POST_READ(arg1, res); | |
1840 | if (arg4) POST_WRITE(arg4, sizeof(*arg4)); | |
1841 | } | |
1842 | } | |
1843 | ||
1844 | PRE_SYSCALL(sendmsg)(long fd, void *msg, long flags) {} | |
1845 | ||
1846 | POST_SYSCALL(sendmsg)(long res, long fd, void *msg, long flags) { | |
1847 | // FIXME: POST_READ | |
1848 | } | |
1849 | ||
1850 | PRE_SYSCALL(sendmmsg)(long fd, void *msg, long vlen, long flags) {} | |
1851 | ||
1852 | POST_SYSCALL(sendmmsg)(long res, long fd, void *msg, long vlen, long flags) { | |
1853 | // FIXME: POST_READ | |
1854 | } | |
1855 | ||
1856 | PRE_SYSCALL(recv)(long arg0, void *buf, long len, long flags) {} | |
1857 | ||
1858 | POST_SYSCALL(recv)(long res, void *buf, long len, long flags) { | |
1859 | if (res >= 0) { | |
1860 | if (buf) POST_WRITE(buf, res); | |
1861 | } | |
1862 | } | |
1863 | ||
1864 | PRE_SYSCALL(recvfrom)(long arg0, void *buf, long len, long flags, | |
1865 | sanitizer_kernel_sockaddr *arg4, void *arg5) {} | |
1866 | ||
1867 | POST_SYSCALL(recvfrom)(long res, long arg0, void *buf, long len, long flags, | |
1868 | sanitizer_kernel_sockaddr *arg4, void *arg5) { | |
1869 | if (res >= 0) { | |
1870 | if (buf) POST_WRITE(buf, res); | |
1871 | if (arg4) POST_WRITE(arg4, sizeof(*arg4)); | |
1872 | if (arg5) POST_WRITE(arg5, sizeof(int)); | |
1873 | } | |
1874 | } | |
1875 | ||
1876 | PRE_SYSCALL(socket)(long arg0, long arg1, long arg2) {} | |
1877 | ||
1878 | POST_SYSCALL(socket)(long res, long arg0, long arg1, long arg2) {} | |
1879 | ||
10189819 | 1880 | PRE_SYSCALL(socketpair)(long arg0, long arg1, long arg2, int *sv) {} |
ef1b3fda | 1881 | |
10189819 MO |
1882 | POST_SYSCALL(socketpair)(long res, long arg0, long arg1, long arg2, int *sv) { |
1883 | if (res >= 0) | |
1884 | if (sv) POST_WRITE(sv, sizeof(int) * 2); | |
ef1b3fda KS |
1885 | } |
1886 | ||
1887 | PRE_SYSCALL(socketcall)(long call, void *args) {} | |
1888 | ||
1889 | POST_SYSCALL(socketcall)(long res, long call, void *args) { | |
1890 | if (res >= 0) { | |
1891 | if (args) POST_WRITE(args, sizeof(long)); | |
1892 | } | |
1893 | } | |
1894 | ||
1895 | PRE_SYSCALL(listen)(long arg0, long arg1) {} | |
1896 | ||
1897 | POST_SYSCALL(listen)(long res, long arg0, long arg1) {} | |
1898 | ||
1899 | PRE_SYSCALL(poll)(void *ufds, long nfds, long timeout) {} | |
1900 | ||
1901 | POST_SYSCALL(poll)(long res, __sanitizer_pollfd *ufds, long nfds, | |
1902 | long timeout) { | |
1903 | if (res >= 0) { | |
1904 | if (ufds) POST_WRITE(ufds, nfds * sizeof(*ufds)); | |
1905 | } | |
1906 | } | |
1907 | ||
1908 | PRE_SYSCALL(select)(long n, __sanitizer___kernel_fd_set *inp, | |
1909 | __sanitizer___kernel_fd_set *outp, | |
1910 | __sanitizer___kernel_fd_set *exp, void *tvp) {} | |
1911 | ||
1912 | POST_SYSCALL(select)(long res, long n, __sanitizer___kernel_fd_set *inp, | |
1913 | __sanitizer___kernel_fd_set *outp, | |
1914 | __sanitizer___kernel_fd_set *exp, void *tvp) { | |
1915 | if (res >= 0) { | |
1916 | if (inp) POST_WRITE(inp, sizeof(*inp)); | |
1917 | if (outp) POST_WRITE(outp, sizeof(*outp)); | |
1918 | if (exp) POST_WRITE(exp, sizeof(*exp)); | |
1919 | if (tvp) POST_WRITE(tvp, timeval_sz); | |
1920 | } | |
1921 | } | |
1922 | ||
1923 | PRE_SYSCALL(old_select)(void *arg) {} | |
1924 | ||
1925 | POST_SYSCALL(old_select)(long res, void *arg) {} | |
1926 | ||
1927 | PRE_SYSCALL(epoll_create)(long size) {} | |
1928 | ||
1929 | POST_SYSCALL(epoll_create)(long res, long size) {} | |
1930 | ||
1931 | PRE_SYSCALL(epoll_create1)(long flags) {} | |
1932 | ||
1933 | POST_SYSCALL(epoll_create1)(long res, long flags) {} | |
1934 | ||
1935 | PRE_SYSCALL(epoll_ctl)(long epfd, long op, long fd, void *event) {} | |
1936 | ||
1937 | POST_SYSCALL(epoll_ctl)(long res, long epfd, long op, long fd, void *event) { | |
1938 | if (res >= 0) { | |
1939 | if (event) POST_WRITE(event, struct_epoll_event_sz); | |
1940 | } | |
1941 | } | |
1942 | ||
1943 | PRE_SYSCALL(epoll_wait)(long epfd, void *events, long maxevents, long timeout) { | |
1944 | } | |
1945 | ||
1946 | POST_SYSCALL(epoll_wait)(long res, long epfd, void *events, long maxevents, | |
1947 | long timeout) { | |
1948 | if (res >= 0) { | |
1949 | if (events) POST_WRITE(events, struct_epoll_event_sz); | |
1950 | } | |
1951 | } | |
1952 | ||
1953 | PRE_SYSCALL(epoll_pwait)(long epfd, void *events, long maxevents, long timeout, | |
1954 | const kernel_sigset_t *sigmask, long sigsetsize) { | |
1955 | if (sigmask) PRE_READ(sigmask, sigsetsize); | |
1956 | } | |
1957 | ||
1958 | POST_SYSCALL(epoll_pwait)(long res, long epfd, void *events, long maxevents, | |
1959 | long timeout, const void *sigmask, long sigsetsize) { | |
1960 | if (res >= 0) { | |
1961 | if (events) POST_WRITE(events, struct_epoll_event_sz); | |
1962 | } | |
1963 | } | |
1964 | ||
1965 | PRE_SYSCALL(gethostname)(void *name, long len) {} | |
1966 | ||
1967 | POST_SYSCALL(gethostname)(long res, void *name, long len) { | |
1968 | if (res >= 0) { | |
1969 | if (name) | |
1970 | POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1971 | } | |
1972 | } | |
1973 | ||
1974 | PRE_SYSCALL(sethostname)(void *name, long len) {} | |
1975 | ||
1976 | POST_SYSCALL(sethostname)(long res, void *name, long len) { | |
1977 | if (res >= 0) { | |
1978 | if (name) | |
1979 | POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1980 | } | |
1981 | } | |
1982 | ||
1983 | PRE_SYSCALL(setdomainname)(void *name, long len) {} | |
1984 | ||
1985 | POST_SYSCALL(setdomainname)(long res, void *name, long len) { | |
1986 | if (res >= 0) { | |
1987 | if (name) | |
1988 | POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
1989 | } | |
1990 | } | |
1991 | ||
1992 | PRE_SYSCALL(newuname)(void *name) {} | |
1993 | ||
1994 | POST_SYSCALL(newuname)(long res, void *name) { | |
1995 | if (res >= 0) { | |
1996 | if (name) POST_WRITE(name, struct_new_utsname_sz); | |
1997 | } | |
1998 | } | |
1999 | ||
2000 | PRE_SYSCALL(uname)(void *arg0) {} | |
2001 | ||
2002 | POST_SYSCALL(uname)(long res, void *arg0) { | |
2003 | if (res >= 0) { | |
2004 | if (arg0) POST_WRITE(arg0, struct_old_utsname_sz); | |
2005 | } | |
2006 | } | |
2007 | ||
2008 | PRE_SYSCALL(olduname)(void *arg0) {} | |
2009 | ||
2010 | POST_SYSCALL(olduname)(long res, void *arg0) { | |
2011 | if (res >= 0) { | |
2012 | if (arg0) POST_WRITE(arg0, struct_oldold_utsname_sz); | |
2013 | } | |
2014 | } | |
2015 | ||
2016 | PRE_SYSCALL(getrlimit)(long resource, void *rlim) {} | |
2017 | ||
2018 | POST_SYSCALL(getrlimit)(long res, long resource, void *rlim) { | |
2019 | if (res >= 0) { | |
2020 | if (rlim) POST_WRITE(rlim, struct_rlimit_sz); | |
2021 | } | |
2022 | } | |
2023 | ||
2024 | PRE_SYSCALL(old_getrlimit)(long resource, void *rlim) {} | |
2025 | ||
2026 | POST_SYSCALL(old_getrlimit)(long res, long resource, void *rlim) { | |
2027 | if (res >= 0) { | |
2028 | if (rlim) POST_WRITE(rlim, struct_rlimit_sz); | |
2029 | } | |
2030 | } | |
2031 | ||
2032 | PRE_SYSCALL(setrlimit)(long resource, void *rlim) {} | |
2033 | ||
2034 | POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { | |
2035 | if (res >= 0) { | |
2036 | if (rlim) POST_WRITE(rlim, struct_rlimit_sz); | |
2037 | } | |
2038 | } | |
2039 | ||
2040 | #if !SANITIZER_ANDROID | |
2041 | PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, | |
2042 | void *old_rlim) { | |
2043 | if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); | |
2044 | } | |
2045 | ||
2046 | POST_SYSCALL(prlimit64)(long res, long pid, long resource, const void *new_rlim, | |
2047 | void *old_rlim) { | |
2048 | if (res >= 0) { | |
2049 | if (old_rlim) POST_WRITE(old_rlim, struct_rlimit64_sz); | |
2050 | } | |
2051 | } | |
2052 | #endif | |
2053 | ||
2054 | PRE_SYSCALL(getrusage)(long who, void *ru) {} | |
2055 | ||
2056 | POST_SYSCALL(getrusage)(long res, long who, void *ru) { | |
2057 | if (res >= 0) { | |
2058 | if (ru) POST_WRITE(ru, struct_rusage_sz); | |
2059 | } | |
2060 | } | |
2061 | ||
2062 | PRE_SYSCALL(umask)(long mask) {} | |
2063 | ||
2064 | POST_SYSCALL(umask)(long res, long mask) {} | |
2065 | ||
2066 | PRE_SYSCALL(msgget)(long key, long msgflg) {} | |
2067 | ||
2068 | POST_SYSCALL(msgget)(long res, long key, long msgflg) {} | |
2069 | ||
2070 | PRE_SYSCALL(msgsnd)(long msqid, void *msgp, long msgsz, long msgflg) { | |
2071 | if (msgp) PRE_READ(msgp, msgsz); | |
2072 | } | |
2073 | ||
2074 | POST_SYSCALL(msgsnd)(long res, long msqid, void *msgp, long msgsz, | |
2075 | long msgflg) {} | |
2076 | ||
2077 | PRE_SYSCALL(msgrcv)(long msqid, void *msgp, long msgsz, long msgtyp, | |
2078 | long msgflg) {} | |
2079 | ||
2080 | POST_SYSCALL(msgrcv)(long res, long msqid, void *msgp, long msgsz, long msgtyp, | |
2081 | long msgflg) { | |
2082 | if (res >= 0) { | |
2083 | if (msgp) POST_WRITE(msgp, res); | |
2084 | } | |
2085 | } | |
2086 | ||
dee5ea7a | 2087 | #if !SANITIZER_ANDROID |
ef1b3fda KS |
2088 | PRE_SYSCALL(msgctl)(long msqid, long cmd, void *buf) {} |
2089 | ||
2090 | POST_SYSCALL(msgctl)(long res, long msqid, long cmd, void *buf) { | |
2091 | if (res >= 0) { | |
2092 | if (buf) POST_WRITE(buf, struct_msqid_ds_sz); | |
2093 | } | |
2094 | } | |
dee5ea7a | 2095 | #endif |
ef1b3fda KS |
2096 | |
2097 | PRE_SYSCALL(semget)(long key, long nsems, long semflg) {} | |
2098 | ||
2099 | POST_SYSCALL(semget)(long res, long key, long nsems, long semflg) {} | |
2100 | ||
2101 | PRE_SYSCALL(semop)(long semid, void *sops, long nsops) {} | |
2102 | ||
2103 | POST_SYSCALL(semop)(long res, long semid, void *sops, long nsops) {} | |
2104 | ||
2105 | PRE_SYSCALL(semctl)(long semid, long semnum, long cmd, void *arg) {} | |
2106 | ||
2107 | POST_SYSCALL(semctl)(long res, long semid, long semnum, long cmd, void *arg) {} | |
2108 | ||
2109 | PRE_SYSCALL(semtimedop)(long semid, void *sops, long nsops, | |
2110 | const void *timeout) { | |
2111 | if (timeout) PRE_READ(timeout, struct_timespec_sz); | |
2112 | } | |
2113 | ||
2114 | POST_SYSCALL(semtimedop)(long res, long semid, void *sops, long nsops, | |
2115 | const void *timeout) {} | |
2116 | ||
2117 | PRE_SYSCALL(shmat)(long shmid, void *shmaddr, long shmflg) {} | |
2118 | ||
2119 | POST_SYSCALL(shmat)(long res, long shmid, void *shmaddr, long shmflg) { | |
2120 | if (res >= 0) { | |
2121 | if (shmaddr) | |
2122 | POST_WRITE(shmaddr, | |
2123 | __sanitizer::internal_strlen((const char *)shmaddr) + 1); | |
2124 | } | |
2125 | } | |
2126 | ||
2127 | PRE_SYSCALL(shmget)(long key, long size, long flag) {} | |
2128 | ||
2129 | POST_SYSCALL(shmget)(long res, long key, long size, long flag) {} | |
2130 | ||
2131 | PRE_SYSCALL(shmdt)(void *shmaddr) {} | |
2132 | ||
2133 | POST_SYSCALL(shmdt)(long res, void *shmaddr) { | |
2134 | if (res >= 0) { | |
2135 | if (shmaddr) | |
2136 | POST_WRITE(shmaddr, | |
2137 | __sanitizer::internal_strlen((const char *)shmaddr) + 1); | |
2138 | } | |
2139 | } | |
2140 | ||
ef1b3fda KS |
2141 | PRE_SYSCALL(ipc)(long call, long first, long second, long third, void *ptr, |
2142 | long fifth) {} | |
2143 | ||
2144 | POST_SYSCALL(ipc)(long res, long call, long first, long second, long third, | |
2145 | void *ptr, long fifth) {} | |
2146 | ||
2147 | #if !SANITIZER_ANDROID | |
df77f0e4 KS |
2148 | PRE_SYSCALL(shmctl)(long shmid, long cmd, void *buf) {} |
2149 | ||
2150 | POST_SYSCALL(shmctl)(long res, long shmid, long cmd, void *buf) { | |
2151 | if (res >= 0) { | |
2152 | if (buf) POST_WRITE(buf, sizeof(__sanitizer_shmid_ds)); | |
2153 | } | |
2154 | } | |
2155 | ||
ef1b3fda KS |
2156 | PRE_SYSCALL(mq_open)(const void *name, long oflag, long mode, void *attr) { |
2157 | if (name) | |
2158 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
2159 | } | |
2160 | ||
2161 | POST_SYSCALL(mq_open)(long res, const void *name, long oflag, long mode, | |
2162 | void *attr) { | |
2163 | if (res >= 0) { | |
2164 | if (attr) POST_WRITE(attr, struct_mq_attr_sz); | |
2165 | } | |
2166 | } | |
2167 | ||
2168 | PRE_SYSCALL(mq_unlink)(const void *name) { | |
2169 | if (name) | |
2170 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
2171 | } | |
2172 | ||
2173 | POST_SYSCALL(mq_unlink)(long res, const void *name) {} | |
2174 | ||
2175 | PRE_SYSCALL(mq_timedsend)(long mqdes, const void *msg_ptr, long msg_len, | |
2176 | long msg_prio, const void *abs_timeout) { | |
2177 | if (msg_ptr) PRE_READ(msg_ptr, msg_len); | |
2178 | if (abs_timeout) PRE_READ(abs_timeout, struct_timespec_sz); | |
2179 | } | |
2180 | ||
2181 | POST_SYSCALL(mq_timedsend)(long res, long mqdes, const void *msg_ptr, | |
2182 | long msg_len, long msg_prio, | |
2183 | const void *abs_timeout) {} | |
2184 | ||
2185 | PRE_SYSCALL(mq_timedreceive)(long mqdes, void *msg_ptr, long msg_len, | |
2186 | void *msg_prio, const void *abs_timeout) { | |
2187 | if (abs_timeout) PRE_READ(abs_timeout, struct_timespec_sz); | |
2188 | } | |
2189 | ||
2190 | POST_SYSCALL(mq_timedreceive)(long res, long mqdes, void *msg_ptr, long msg_len, | |
2191 | int *msg_prio, const void *abs_timeout) { | |
2192 | if (res >= 0) { | |
2193 | if (msg_ptr) POST_WRITE(msg_ptr, res); | |
2194 | if (msg_prio) POST_WRITE(msg_prio, sizeof(*msg_prio)); | |
2195 | } | |
2196 | } | |
2197 | ||
2198 | PRE_SYSCALL(mq_notify)(long mqdes, const void *notification) { | |
2199 | if (notification) PRE_READ(notification, struct_sigevent_sz); | |
2200 | } | |
2201 | ||
2202 | POST_SYSCALL(mq_notify)(long res, long mqdes, const void *notification) {} | |
2203 | ||
2204 | PRE_SYSCALL(mq_getsetattr)(long mqdes, const void *mqstat, void *omqstat) { | |
2205 | if (mqstat) PRE_READ(mqstat, struct_mq_attr_sz); | |
2206 | } | |
2207 | ||
2208 | POST_SYSCALL(mq_getsetattr)(long res, long mqdes, const void *mqstat, | |
2209 | void *omqstat) { | |
2210 | if (res >= 0) { | |
2211 | if (omqstat) POST_WRITE(omqstat, struct_mq_attr_sz); | |
2212 | } | |
2213 | } | |
2214 | #endif // SANITIZER_ANDROID | |
2215 | ||
2216 | PRE_SYSCALL(pciconfig_iobase)(long which, long bus, long devfn) {} | |
2217 | ||
2218 | POST_SYSCALL(pciconfig_iobase)(long res, long which, long bus, long devfn) {} | |
2219 | ||
2220 | PRE_SYSCALL(pciconfig_read)(long bus, long dfn, long off, long len, void *buf) { | |
2221 | } | |
2222 | ||
2223 | POST_SYSCALL(pciconfig_read)(long res, long bus, long dfn, long off, long len, | |
2224 | void *buf) {} | |
2225 | ||
2226 | PRE_SYSCALL(pciconfig_write)(long bus, long dfn, long off, long len, | |
2227 | void *buf) {} | |
2228 | ||
2229 | POST_SYSCALL(pciconfig_write)(long res, long bus, long dfn, long off, long len, | |
2230 | void *buf) {} | |
2231 | ||
2232 | PRE_SYSCALL(swapon)(const void *specialfile, long swap_flags) { | |
2233 | if (specialfile) | |
2234 | PRE_READ(specialfile, | |
2235 | __sanitizer::internal_strlen((const char *)specialfile) + 1); | |
2236 | } | |
2237 | ||
2238 | POST_SYSCALL(swapon)(long res, const void *specialfile, long swap_flags) {} | |
2239 | ||
2240 | PRE_SYSCALL(swapoff)(const void *specialfile) { | |
2241 | if (specialfile) | |
2242 | PRE_READ(specialfile, | |
2243 | __sanitizer::internal_strlen((const char *)specialfile) + 1); | |
2244 | } | |
2245 | ||
2246 | POST_SYSCALL(swapoff)(long res, const void *specialfile) {} | |
2247 | ||
2248 | PRE_SYSCALL(sysctl)(__sanitizer___sysctl_args *args) { | |
2249 | if (args) { | |
2250 | if (args->name) PRE_READ(args->name, args->nlen * sizeof(*args->name)); | |
2251 | if (args->newval) PRE_READ(args->name, args->newlen); | |
2252 | } | |
2253 | } | |
2254 | ||
2255 | POST_SYSCALL(sysctl)(long res, __sanitizer___sysctl_args *args) { | |
2256 | if (res >= 0) { | |
2257 | if (args && args->oldval && args->oldlenp) { | |
2258 | POST_WRITE(args->oldlenp, sizeof(*args->oldlenp)); | |
2259 | POST_WRITE(args->oldval, *args->oldlenp); | |
2260 | } | |
2261 | } | |
2262 | } | |
2263 | ||
2264 | PRE_SYSCALL(sysinfo)(void *info) {} | |
2265 | ||
2266 | POST_SYSCALL(sysinfo)(long res, void *info) { | |
2267 | if (res >= 0) { | |
2268 | if (info) POST_WRITE(info, struct_sysinfo_sz); | |
2269 | } | |
2270 | } | |
2271 | ||
2272 | PRE_SYSCALL(sysfs)(long option, long arg1, long arg2) {} | |
2273 | ||
2274 | POST_SYSCALL(sysfs)(long res, long option, long arg1, long arg2) {} | |
2275 | ||
2276 | PRE_SYSCALL(syslog)(long type, void *buf, long len) {} | |
2277 | ||
2278 | POST_SYSCALL(syslog)(long res, long type, void *buf, long len) { | |
2279 | if (res >= 0) { | |
2280 | if (buf) | |
2281 | POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1); | |
2282 | } | |
2283 | } | |
2284 | ||
2285 | PRE_SYSCALL(uselib)(const void *library) { | |
2286 | if (library) | |
2287 | PRE_READ(library, __sanitizer::internal_strlen((const char *)library) + 1); | |
2288 | } | |
2289 | ||
2290 | POST_SYSCALL(uselib)(long res, const void *library) {} | |
2291 | ||
2292 | PRE_SYSCALL(ni_syscall)() {} | |
2293 | ||
2294 | POST_SYSCALL(ni_syscall)(long res) {} | |
2295 | ||
df77f0e4 | 2296 | PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) { |
696d846a MO |
2297 | #if !SANITIZER_ANDROID && \ |
2298 | (defined(__i386) || defined(__x86_64) || defined(__mips64) || \ | |
10189819 | 2299 | defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__)) |
df77f0e4 KS |
2300 | if (data) { |
2301 | if (request == ptrace_setregs) { | |
2302 | PRE_READ((void *)data, struct_user_regs_struct_sz); | |
2303 | } else if (request == ptrace_setfpregs) { | |
2304 | PRE_READ((void *)data, struct_user_fpregs_struct_sz); | |
2305 | } else if (request == ptrace_setfpxregs) { | |
2306 | PRE_READ((void *)data, struct_user_fpxregs_struct_sz); | |
2307 | } else if (request == ptrace_setsiginfo) { | |
2308 | PRE_READ((void *)data, siginfo_t_sz); | |
2309 | } else if (request == ptrace_setregset) { | |
2310 | __sanitizer_iovec *iov = (__sanitizer_iovec *)data; | |
2311 | PRE_READ(iov->iov_base, iov->iov_len); | |
2312 | } | |
2313 | } | |
2314 | #endif | |
2315 | } | |
ef1b3fda | 2316 | |
df77f0e4 | 2317 | POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) { |
696d846a MO |
2318 | #if !SANITIZER_ANDROID && \ |
2319 | (defined(__i386) || defined(__x86_64) || defined(__mips64) || \ | |
10189819 | 2320 | defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__)) |
df77f0e4 KS |
2321 | if (res >= 0 && data) { |
2322 | // Note that this is different from the interceptor in | |
2323 | // sanitizer_common_interceptors.inc. | |
2324 | // PEEK* requests return resulting values through data pointer. | |
2325 | if (request == ptrace_getregs) { | |
2326 | POST_WRITE((void *)data, struct_user_regs_struct_sz); | |
2327 | } else if (request == ptrace_getfpregs) { | |
2328 | POST_WRITE((void *)data, struct_user_fpregs_struct_sz); | |
2329 | } else if (request == ptrace_getfpxregs) { | |
2330 | POST_WRITE((void *)data, struct_user_fpxregs_struct_sz); | |
2331 | } else if (request == ptrace_getsiginfo) { | |
2332 | POST_WRITE((void *)data, siginfo_t_sz); | |
2333 | } else if (request == ptrace_getregset) { | |
2334 | __sanitizer_iovec *iov = (__sanitizer_iovec *)data; | |
2335 | POST_WRITE(iov->iov_base, iov->iov_len); | |
2336 | } else if (request == ptrace_peekdata || request == ptrace_peektext || | |
2337 | request == ptrace_peekuser) { | |
2338 | POST_WRITE((void *)data, sizeof(void *)); | |
2339 | } | |
2340 | } | |
2341 | #endif | |
2342 | } | |
ef1b3fda KS |
2343 | |
2344 | PRE_SYSCALL(add_key)(const void *_type, const void *_description, | |
2345 | const void *_payload, long plen, long destringid) { | |
2346 | if (_type) | |
2347 | PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1); | |
2348 | if (_description) | |
2349 | PRE_READ(_description, | |
2350 | __sanitizer::internal_strlen((const char *)_description) + 1); | |
2351 | } | |
2352 | ||
2353 | POST_SYSCALL(add_key)(long res, const void *_type, const void *_description, | |
2354 | const void *_payload, long plen, long destringid) {} | |
2355 | ||
2356 | PRE_SYSCALL(request_key)(const void *_type, const void *_description, | |
2357 | const void *_callout_info, long destringid) { | |
2358 | if (_type) | |
2359 | PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1); | |
2360 | if (_description) | |
2361 | PRE_READ(_description, | |
2362 | __sanitizer::internal_strlen((const char *)_description) + 1); | |
2363 | if (_callout_info) | |
2364 | PRE_READ(_callout_info, | |
2365 | __sanitizer::internal_strlen((const char *)_callout_info) + 1); | |
2366 | } | |
2367 | ||
2368 | POST_SYSCALL(request_key)(long res, const void *_type, const void *_description, | |
2369 | const void *_callout_info, long destringid) {} | |
2370 | ||
2371 | PRE_SYSCALL(keyctl)(long cmd, long arg2, long arg3, long arg4, long arg5) {} | |
2372 | ||
2373 | POST_SYSCALL(keyctl)(long res, long cmd, long arg2, long arg3, long arg4, | |
2374 | long arg5) {} | |
2375 | ||
2376 | PRE_SYSCALL(ioprio_set)(long which, long who, long ioprio) {} | |
2377 | ||
2378 | POST_SYSCALL(ioprio_set)(long res, long which, long who, long ioprio) {} | |
2379 | ||
2380 | PRE_SYSCALL(ioprio_get)(long which, long who) {} | |
2381 | ||
2382 | POST_SYSCALL(ioprio_get)(long res, long which, long who) {} | |
2383 | ||
2384 | PRE_SYSCALL(set_mempolicy)(long mode, void *nmask, long maxnode) {} | |
2385 | ||
2386 | POST_SYSCALL(set_mempolicy)(long res, long mode, void *nmask, long maxnode) { | |
2387 | if (res >= 0) { | |
2388 | if (nmask) POST_WRITE(nmask, sizeof(long)); | |
2389 | } | |
2390 | } | |
2391 | ||
2392 | PRE_SYSCALL(migrate_pages)(long pid, long maxnode, const void *from, | |
2393 | const void *to) { | |
2394 | if (from) PRE_READ(from, sizeof(long)); | |
2395 | if (to) PRE_READ(to, sizeof(long)); | |
2396 | } | |
2397 | ||
2398 | POST_SYSCALL(migrate_pages)(long res, long pid, long maxnode, const void *from, | |
2399 | const void *to) {} | |
2400 | ||
2401 | PRE_SYSCALL(move_pages)(long pid, long nr_pages, const void **pages, | |
2402 | const int *nodes, int *status, long flags) { | |
2403 | if (pages) PRE_READ(pages, nr_pages * sizeof(*pages)); | |
2404 | if (nodes) PRE_READ(nodes, nr_pages * sizeof(*nodes)); | |
2405 | } | |
2406 | ||
2407 | POST_SYSCALL(move_pages)(long res, long pid, long nr_pages, const void **pages, | |
2408 | const int *nodes, int *status, long flags) { | |
2409 | if (res >= 0) { | |
2410 | if (status) POST_WRITE(status, nr_pages * sizeof(*status)); | |
2411 | } | |
2412 | } | |
2413 | ||
2414 | PRE_SYSCALL(mbind)(long start, long len, long mode, void *nmask, long maxnode, | |
2415 | long flags) {} | |
2416 | ||
2417 | POST_SYSCALL(mbind)(long res, long start, long len, long mode, void *nmask, | |
2418 | long maxnode, long flags) { | |
2419 | if (res >= 0) { | |
2420 | if (nmask) POST_WRITE(nmask, sizeof(long)); | |
2421 | } | |
2422 | } | |
2423 | ||
2424 | PRE_SYSCALL(get_mempolicy)(void *policy, void *nmask, long maxnode, long addr, | |
2425 | long flags) {} | |
2426 | ||
2427 | POST_SYSCALL(get_mempolicy)(long res, void *policy, void *nmask, long maxnode, | |
2428 | long addr, long flags) { | |
2429 | if (res >= 0) { | |
2430 | if (policy) POST_WRITE(policy, sizeof(int)); | |
2431 | if (nmask) POST_WRITE(nmask, sizeof(long)); | |
2432 | } | |
2433 | } | |
2434 | ||
2435 | PRE_SYSCALL(inotify_init)() {} | |
2436 | ||
2437 | POST_SYSCALL(inotify_init)(long res) {} | |
2438 | ||
2439 | PRE_SYSCALL(inotify_init1)(long flags) {} | |
2440 | ||
2441 | POST_SYSCALL(inotify_init1)(long res, long flags) {} | |
2442 | ||
2443 | PRE_SYSCALL(inotify_add_watch)(long fd, const void *path, long mask) { | |
2444 | if (path) | |
2445 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
2446 | } | |
2447 | ||
2448 | POST_SYSCALL(inotify_add_watch)(long res, long fd, const void *path, | |
2449 | long mask) {} | |
2450 | ||
2451 | PRE_SYSCALL(inotify_rm_watch)(long fd, long wd) {} | |
2452 | ||
2453 | POST_SYSCALL(inotify_rm_watch)(long res, long fd, long wd) {} | |
2454 | ||
2455 | PRE_SYSCALL(spu_run)(long fd, void *unpc, void *ustatus) {} | |
2456 | ||
2457 | POST_SYSCALL(spu_run)(long res, long fd, unsigned *unpc, unsigned *ustatus) { | |
2458 | if (res >= 0) { | |
2459 | if (unpc) POST_WRITE(unpc, sizeof(*unpc)); | |
2460 | if (ustatus) POST_WRITE(ustatus, sizeof(*ustatus)); | |
2461 | } | |
2462 | } | |
2463 | ||
2464 | PRE_SYSCALL(spu_create)(const void *name, long flags, long mode, long fd) { | |
2465 | if (name) | |
2466 | PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); | |
2467 | } | |
2468 | ||
2469 | POST_SYSCALL(spu_create)(long res, const void *name, long flags, long mode, | |
2470 | long fd) {} | |
2471 | ||
2472 | PRE_SYSCALL(mknodat)(long dfd, const void *filename, long mode, long dev) { | |
2473 | if (filename) | |
2474 | PRE_READ(filename, | |
2475 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2476 | } | |
2477 | ||
2478 | POST_SYSCALL(mknodat)(long res, long dfd, const void *filename, long mode, | |
2479 | long dev) {} | |
2480 | ||
2481 | PRE_SYSCALL(mkdirat)(long dfd, const void *pathname, long mode) { | |
2482 | if (pathname) | |
2483 | PRE_READ(pathname, | |
2484 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
2485 | } | |
2486 | ||
2487 | POST_SYSCALL(mkdirat)(long res, long dfd, const void *pathname, long mode) {} | |
2488 | ||
2489 | PRE_SYSCALL(unlinkat)(long dfd, const void *pathname, long flag) { | |
2490 | if (pathname) | |
2491 | PRE_READ(pathname, | |
2492 | __sanitizer::internal_strlen((const char *)pathname) + 1); | |
2493 | } | |
2494 | ||
2495 | POST_SYSCALL(unlinkat)(long res, long dfd, const void *pathname, long flag) {} | |
2496 | ||
2497 | PRE_SYSCALL(symlinkat)(const void *oldname, long newdfd, const void *newname) { | |
2498 | if (oldname) | |
2499 | PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1); | |
2500 | if (newname) | |
2501 | PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1); | |
2502 | } | |
2503 | ||
2504 | POST_SYSCALL(symlinkat)(long res, const void *oldname, long newdfd, | |
2505 | const void *newname) {} | |
2506 | ||
2507 | PRE_SYSCALL(linkat)(long olddfd, const void *oldname, long newdfd, | |
2508 | const void *newname, long flags) { | |
2509 | if (oldname) | |
2510 | PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1); | |
2511 | if (newname) | |
2512 | PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1); | |
2513 | } | |
2514 | ||
2515 | POST_SYSCALL(linkat)(long res, long olddfd, const void *oldname, long newdfd, | |
2516 | const void *newname, long flags) {} | |
2517 | ||
2518 | PRE_SYSCALL(renameat)(long olddfd, const void *oldname, long newdfd, | |
2519 | const void *newname) { | |
2520 | if (oldname) | |
2521 | PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1); | |
2522 | if (newname) | |
2523 | PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1); | |
2524 | } | |
2525 | ||
2526 | POST_SYSCALL(renameat)(long res, long olddfd, const void *oldname, long newdfd, | |
2527 | const void *newname) {} | |
2528 | ||
2529 | PRE_SYSCALL(futimesat)(long dfd, const void *filename, void *utimes) { | |
2530 | if (filename) | |
2531 | PRE_READ(filename, | |
2532 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2533 | } | |
2534 | ||
2535 | POST_SYSCALL(futimesat)(long res, long dfd, const void *filename, | |
2536 | void *utimes) { | |
2537 | if (res >= 0) { | |
2538 | if (utimes) POST_WRITE(utimes, timeval_sz); | |
2539 | } | |
2540 | } | |
2541 | ||
2542 | PRE_SYSCALL(faccessat)(long dfd, const void *filename, long mode) { | |
2543 | if (filename) | |
2544 | PRE_READ(filename, | |
2545 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2546 | } | |
2547 | ||
2548 | POST_SYSCALL(faccessat)(long res, long dfd, const void *filename, long mode) {} | |
2549 | ||
2550 | PRE_SYSCALL(fchmodat)(long dfd, const void *filename, long mode) { | |
2551 | if (filename) | |
2552 | PRE_READ(filename, | |
2553 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2554 | } | |
2555 | ||
2556 | POST_SYSCALL(fchmodat)(long res, long dfd, const void *filename, long mode) {} | |
2557 | ||
2558 | PRE_SYSCALL(fchownat)(long dfd, const void *filename, long user, long group, | |
2559 | long flag) { | |
2560 | if (filename) | |
2561 | PRE_READ(filename, | |
2562 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2563 | } | |
2564 | ||
2565 | POST_SYSCALL(fchownat)(long res, long dfd, const void *filename, long user, | |
2566 | long group, long flag) {} | |
2567 | ||
2568 | PRE_SYSCALL(openat)(long dfd, const void *filename, long flags, long mode) { | |
2569 | if (filename) | |
2570 | PRE_READ(filename, | |
2571 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2572 | } | |
2573 | ||
2574 | POST_SYSCALL(openat)(long res, long dfd, const void *filename, long flags, | |
2575 | long mode) {} | |
2576 | ||
2577 | PRE_SYSCALL(newfstatat)(long dfd, const void *filename, void *statbuf, | |
2578 | long flag) { | |
2579 | if (filename) | |
2580 | PRE_READ(filename, | |
2581 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2582 | } | |
2583 | ||
2584 | POST_SYSCALL(newfstatat)(long res, long dfd, const void *filename, | |
2585 | void *statbuf, long flag) { | |
2586 | if (res >= 0) { | |
2587 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz); | |
2588 | } | |
2589 | } | |
2590 | ||
2591 | PRE_SYSCALL(fstatat64)(long dfd, const void *filename, void *statbuf, | |
2592 | long flag) { | |
2593 | if (filename) | |
2594 | PRE_READ(filename, | |
2595 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2596 | } | |
2597 | ||
2598 | POST_SYSCALL(fstatat64)(long res, long dfd, const void *filename, void *statbuf, | |
2599 | long flag) { | |
2600 | if (res >= 0) { | |
2601 | if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz); | |
2602 | } | |
2603 | } | |
2604 | ||
2605 | PRE_SYSCALL(readlinkat)(long dfd, const void *path, void *buf, long bufsiz) { | |
2606 | if (path) | |
2607 | PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); | |
2608 | } | |
2609 | ||
2610 | POST_SYSCALL(readlinkat)(long res, long dfd, const void *path, void *buf, | |
2611 | long bufsiz) { | |
2612 | if (res >= 0) { | |
2613 | if (buf) | |
2614 | POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1); | |
2615 | } | |
2616 | } | |
2617 | ||
2618 | PRE_SYSCALL(utimensat)(long dfd, const void *filename, void *utimes, | |
2619 | long flags) { | |
2620 | if (filename) | |
2621 | PRE_READ(filename, | |
2622 | __sanitizer::internal_strlen((const char *)filename) + 1); | |
2623 | } | |
2624 | ||
2625 | POST_SYSCALL(utimensat)(long res, long dfd, const void *filename, void *utimes, | |
2626 | long flags) { | |
2627 | if (res >= 0) { | |
2628 | if (utimes) POST_WRITE(utimes, struct_timespec_sz); | |
2629 | } | |
2630 | } | |
2631 | ||
2632 | PRE_SYSCALL(unshare)(long unshare_flags) {} | |
2633 | ||
2634 | POST_SYSCALL(unshare)(long res, long unshare_flags) {} | |
2635 | ||
2636 | PRE_SYSCALL(splice)(long fd_in, void *off_in, long fd_out, void *off_out, | |
2637 | long len, long flags) {} | |
2638 | ||
2639 | POST_SYSCALL(splice)(long res, long fd_in, void *off_in, long fd_out, | |
2640 | void *off_out, long len, long flags) { | |
2641 | if (res >= 0) { | |
2642 | if (off_in) POST_WRITE(off_in, sizeof(long long)); | |
2643 | if (off_out) POST_WRITE(off_out, sizeof(long long)); | |
2644 | } | |
2645 | } | |
2646 | ||
2647 | PRE_SYSCALL(vmsplice)(long fd, const __sanitizer_iovec *iov, long nr_segs, | |
2648 | long flags) {} | |
2649 | ||
2650 | POST_SYSCALL(vmsplice)(long res, long fd, const __sanitizer_iovec *iov, | |
2651 | long nr_segs, long flags) { | |
2652 | if (res >= 0) { | |
2653 | if (iov) kernel_read_iovec(iov, nr_segs, res); | |
2654 | } | |
2655 | } | |
2656 | ||
2657 | PRE_SYSCALL(tee)(long fdin, long fdout, long len, long flags) {} | |
2658 | ||
2659 | POST_SYSCALL(tee)(long res, long fdin, long fdout, long len, long flags) {} | |
2660 | ||
2661 | PRE_SYSCALL(get_robust_list)(long pid, void *head_ptr, void *len_ptr) {} | |
2662 | ||
2663 | POST_SYSCALL(get_robust_list)(long res, long pid, void *head_ptr, | |
2664 | void *len_ptr) {} | |
2665 | ||
2666 | PRE_SYSCALL(set_robust_list)(void *head, long len) {} | |
2667 | ||
2668 | POST_SYSCALL(set_robust_list)(long res, void *head, long len) {} | |
2669 | ||
2670 | PRE_SYSCALL(getcpu)(void *cpu, void *node, void *cache) {} | |
2671 | ||
2672 | POST_SYSCALL(getcpu)(long res, void *cpu, void *node, void *cache) { | |
2673 | if (res >= 0) { | |
2674 | if (cpu) POST_WRITE(cpu, sizeof(unsigned)); | |
2675 | if (node) POST_WRITE(node, sizeof(unsigned)); | |
2676 | // The third argument to this system call is nowadays unused. | |
2677 | } | |
2678 | } | |
2679 | ||
2680 | PRE_SYSCALL(signalfd)(long ufd, void *user_mask, long sizemask) {} | |
2681 | ||
2682 | POST_SYSCALL(signalfd)(long res, long ufd, kernel_sigset_t *user_mask, | |
2683 | long sizemask) { | |
2684 | if (res >= 0) { | |
2685 | if (user_mask) POST_WRITE(user_mask, sizemask); | |
2686 | } | |
2687 | } | |
2688 | ||
2689 | PRE_SYSCALL(signalfd4)(long ufd, void *user_mask, long sizemask, long flags) {} | |
2690 | ||
2691 | POST_SYSCALL(signalfd4)(long res, long ufd, kernel_sigset_t *user_mask, | |
2692 | long sizemask, long flags) { | |
2693 | if (res >= 0) { | |
2694 | if (user_mask) POST_WRITE(user_mask, sizemask); | |
2695 | } | |
2696 | } | |
2697 | ||
2698 | PRE_SYSCALL(timerfd_create)(long clockid, long flags) {} | |
2699 | ||
2700 | POST_SYSCALL(timerfd_create)(long res, long clockid, long flags) {} | |
2701 | ||
2702 | PRE_SYSCALL(timerfd_settime)(long ufd, long flags, const void *utmr, | |
2703 | void *otmr) { | |
2704 | if (utmr) PRE_READ(utmr, struct_itimerspec_sz); | |
2705 | } | |
2706 | ||
2707 | POST_SYSCALL(timerfd_settime)(long res, long ufd, long flags, const void *utmr, | |
2708 | void *otmr) { | |
2709 | if (res >= 0) { | |
2710 | if (otmr) POST_WRITE(otmr, struct_itimerspec_sz); | |
2711 | } | |
2712 | } | |
2713 | ||
2714 | PRE_SYSCALL(timerfd_gettime)(long ufd, void *otmr) {} | |
2715 | ||
2716 | POST_SYSCALL(timerfd_gettime)(long res, long ufd, void *otmr) { | |
2717 | if (res >= 0) { | |
2718 | if (otmr) POST_WRITE(otmr, struct_itimerspec_sz); | |
2719 | } | |
2720 | } | |
2721 | ||
2722 | PRE_SYSCALL(eventfd)(long count) {} | |
2723 | ||
2724 | POST_SYSCALL(eventfd)(long res, long count) {} | |
2725 | ||
2726 | PRE_SYSCALL(eventfd2)(long count, long flags) {} | |
2727 | ||
2728 | POST_SYSCALL(eventfd2)(long res, long count, long flags) {} | |
2729 | ||
2730 | PRE_SYSCALL(old_readdir)(long arg0, void *arg1, long arg2) {} | |
2731 | ||
2732 | POST_SYSCALL(old_readdir)(long res, long arg0, void *arg1, long arg2) { | |
2733 | // Missing definition of 'struct old_linux_dirent'. | |
2734 | } | |
2735 | ||
2736 | PRE_SYSCALL(pselect6)(long arg0, __sanitizer___kernel_fd_set *arg1, | |
2737 | __sanitizer___kernel_fd_set *arg2, | |
2738 | __sanitizer___kernel_fd_set *arg3, void *arg4, | |
2739 | void *arg5) {} | |
2740 | ||
2741 | POST_SYSCALL(pselect6)(long res, long arg0, __sanitizer___kernel_fd_set *arg1, | |
2742 | __sanitizer___kernel_fd_set *arg2, | |
2743 | __sanitizer___kernel_fd_set *arg3, void *arg4, | |
2744 | void *arg5) { | |
2745 | if (res >= 0) { | |
2746 | if (arg1) POST_WRITE(arg1, sizeof(*arg1)); | |
2747 | if (arg2) POST_WRITE(arg2, sizeof(*arg2)); | |
2748 | if (arg3) POST_WRITE(arg3, sizeof(*arg3)); | |
2749 | if (arg4) POST_WRITE(arg4, struct_timespec_sz); | |
2750 | } | |
2751 | } | |
2752 | ||
2753 | PRE_SYSCALL(ppoll)(__sanitizer_pollfd *arg0, long arg1, void *arg2, | |
2754 | const kernel_sigset_t *arg3, long arg4) { | |
2755 | if (arg3) PRE_READ(arg3, arg4); | |
2756 | } | |
2757 | ||
2758 | POST_SYSCALL(ppoll)(long res, __sanitizer_pollfd *arg0, long arg1, void *arg2, | |
2759 | const void *arg3, long arg4) { | |
2760 | if (res >= 0) { | |
2761 | if (arg0) POST_WRITE(arg0, sizeof(*arg0)); | |
2762 | if (arg2) POST_WRITE(arg2, struct_timespec_sz); | |
2763 | } | |
2764 | } | |
2765 | ||
2766 | PRE_SYSCALL(syncfs)(long fd) {} | |
2767 | ||
2768 | POST_SYSCALL(syncfs)(long res, long fd) {} | |
2769 | ||
df77f0e4 KS |
2770 | PRE_SYSCALL(perf_event_open)(__sanitizer_perf_event_attr *attr_uptr, long pid, |
2771 | long cpu, long group_fd, long flags) { | |
2772 | if (attr_uptr) PRE_READ(attr_uptr, attr_uptr->size); | |
ef1b3fda KS |
2773 | } |
2774 | ||
df77f0e4 KS |
2775 | POST_SYSCALL(perf_event_open)(long res, __sanitizer_perf_event_attr *attr_uptr, |
2776 | long pid, long cpu, long group_fd, long flags) {} | |
2777 | ||
ef1b3fda KS |
2778 | PRE_SYSCALL(mmap_pgoff)(long addr, long len, long prot, long flags, long fd, |
2779 | long pgoff) {} | |
2780 | ||
2781 | POST_SYSCALL(mmap_pgoff)(long res, long addr, long len, long prot, long flags, | |
2782 | long fd, long pgoff) {} | |
2783 | ||
2784 | PRE_SYSCALL(old_mmap)(void *arg) {} | |
2785 | ||
2786 | POST_SYSCALL(old_mmap)(long res, void *arg) {} | |
2787 | ||
2788 | PRE_SYSCALL(name_to_handle_at)(long dfd, const void *name, void *handle, | |
2789 | void *mnt_id, long flag) {} | |
2790 | ||
2791 | POST_SYSCALL(name_to_handle_at)(long res, long dfd, const void *name, | |
2792 | void *handle, void *mnt_id, long flag) {} | |
2793 | ||
2794 | PRE_SYSCALL(open_by_handle_at)(long mountdirfd, void *handle, long flags) {} | |
2795 | ||
2796 | POST_SYSCALL(open_by_handle_at)(long res, long mountdirfd, void *handle, | |
2797 | long flags) {} | |
2798 | ||
2799 | PRE_SYSCALL(setns)(long fd, long nstype) {} | |
2800 | ||
2801 | POST_SYSCALL(setns)(long res, long fd, long nstype) {} | |
2802 | ||
2803 | PRE_SYSCALL(process_vm_readv)(long pid, const __sanitizer_iovec *lvec, | |
2804 | long liovcnt, const void *rvec, long riovcnt, | |
2805 | long flags) {} | |
2806 | ||
2807 | POST_SYSCALL(process_vm_readv)(long res, long pid, | |
2808 | const __sanitizer_iovec *lvec, long liovcnt, | |
2809 | const void *rvec, long riovcnt, long flags) { | |
2810 | if (res >= 0) { | |
2811 | if (lvec) kernel_write_iovec(lvec, liovcnt, res); | |
2812 | } | |
2813 | } | |
2814 | ||
2815 | PRE_SYSCALL(process_vm_writev)(long pid, const __sanitizer_iovec *lvec, | |
2816 | long liovcnt, const void *rvec, long riovcnt, | |
2817 | long flags) {} | |
2818 | ||
2819 | POST_SYSCALL(process_vm_writev)(long res, long pid, | |
2820 | const __sanitizer_iovec *lvec, long liovcnt, | |
2821 | const void *rvec, long riovcnt, long flags) { | |
2822 | if (res >= 0) { | |
2823 | if (lvec) kernel_read_iovec(lvec, liovcnt, res); | |
2824 | } | |
2825 | } | |
2826 | ||
2827 | PRE_SYSCALL(fork)() { | |
2828 | COMMON_SYSCALL_PRE_FORK(); | |
2829 | } | |
2830 | ||
2831 | POST_SYSCALL(fork)(long res) { | |
2832 | COMMON_SYSCALL_POST_FORK(res); | |
2833 | } | |
2834 | ||
2835 | PRE_SYSCALL(vfork)() { | |
2836 | COMMON_SYSCALL_PRE_FORK(); | |
2837 | } | |
2838 | ||
2839 | POST_SYSCALL(vfork)(long res) { | |
2840 | COMMON_SYSCALL_POST_FORK(res); | |
2841 | } | |
10189819 MO |
2842 | |
2843 | PRE_SYSCALL(sigaction)(long signum, const __sanitizer_kernel_sigaction_t *act, | |
2844 | __sanitizer_kernel_sigaction_t *oldact) { | |
2845 | if (act) { | |
2846 | PRE_READ(&act->sigaction, sizeof(act->sigaction)); | |
2847 | PRE_READ(&act->sa_flags, sizeof(act->sa_flags)); | |
2848 | PRE_READ(&act->sa_mask, sizeof(act->sa_mask)); | |
2849 | } | |
2850 | } | |
2851 | ||
2852 | POST_SYSCALL(sigaction)(long res, long signum, | |
2853 | const __sanitizer_kernel_sigaction_t *act, | |
2854 | __sanitizer_kernel_sigaction_t *oldact) { | |
2855 | if (res >= 0 && oldact) POST_WRITE(oldact, sizeof(*oldact)); | |
2856 | } | |
2857 | ||
2858 | PRE_SYSCALL(rt_sigaction)(long signum, | |
2859 | const __sanitizer_kernel_sigaction_t *act, | |
2860 | __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) { | |
2861 | if (act) { | |
2862 | PRE_READ(&act->sigaction, sizeof(act->sigaction)); | |
2863 | PRE_READ(&act->sa_flags, sizeof(act->sa_flags)); | |
2864 | PRE_READ(&act->sa_mask, sz); | |
2865 | } | |
2866 | } | |
2867 | ||
2868 | POST_SYSCALL(rt_sigaction)(long res, long signum, | |
2869 | const __sanitizer_kernel_sigaction_t *act, | |
2870 | __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) { | |
2871 | if (res >= 0 && oldact) { | |
2872 | SIZE_T oldact_sz = ((char *)&oldact->sa_mask) - ((char *)oldact) + sz; | |
2873 | POST_WRITE(oldact, oldact_sz); | |
2874 | } | |
2875 | } | |
b667dd70 ML |
2876 | |
2877 | PRE_SYSCALL(getrandom)(void *buf, uptr count, long flags) { | |
2878 | if (buf) { | |
2879 | PRE_WRITE(buf, count); | |
2880 | } | |
2881 | } | |
2882 | ||
2883 | POST_SYSCALL(getrandom)(long res, void *buf, uptr count, long flags) { | |
2884 | if (res > 0 && buf) { | |
2885 | POST_WRITE(buf, res); | |
2886 | } | |
2887 | } | |
3c6331c2 ML |
2888 | |
2889 | PRE_SYSCALL(sigaltstack)(const void *ss, void *oss) { | |
2890 | if (ss != nullptr) { | |
2891 | PRE_READ(ss, struct_stack_t_sz); | |
2892 | } | |
2893 | if (oss != nullptr) { | |
2894 | PRE_WRITE(oss, struct_stack_t_sz); | |
2895 | } | |
2896 | } | |
2897 | ||
2898 | POST_SYSCALL(sigaltstack)(long res, void *ss, void *oss) { | |
2899 | if (res == 0) { | |
2900 | if (oss != nullptr) { | |
2901 | POST_WRITE(oss, struct_stack_t_sz); | |
2902 | } | |
2903 | } | |
2904 | } | |
ef1b3fda KS |
2905 | } // extern "C" |
2906 | ||
2907 | #undef PRE_SYSCALL | |
2908 | #undef PRE_READ | |
2909 | #undef PRE_WRITE | |
2910 | #undef POST_SYSCALL | |
2911 | #undef POST_READ | |
2912 | #undef POST_WRITE | |
2913 | ||
2914 | #endif // SANITIZER_LINUX |