1 //===-- sanitizer_common_syscalls.inc ---------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // Common syscalls handlers for tools like AddressSanitizer,
9 // ThreadSanitizer, MemorySanitizer, etc.
11 // This file should be included into the tool's interceptor file,
12 // which has to define it's own macros:
13 // COMMON_SYSCALL_PRE_READ_RANGE
14 // Called in prehook for regions that will be read by the kernel and
15 // must be initialized.
16 // COMMON_SYSCALL_PRE_WRITE_RANGE
17 // Called in prehook for regions that will be written to by the kernel
18 // and must be addressable. The actual write range may be smaller than
19 // reported in the prehook. See POST_WRITE_RANGE.
20 // COMMON_SYSCALL_POST_READ_RANGE
21 // Called in posthook for regions that were read by the kernel. Does
22 // not make much sense.
23 // COMMON_SYSCALL_POST_WRITE_RANGE
24 // Called in posthook for regions that were written to by the kernel
25 // and are now initialized.
26 // COMMON_SYSCALL_ACQUIRE(addr)
27 // Acquire memory visibility from addr.
28 // COMMON_SYSCALL_RELEASE(addr)
29 // Release memory visibility to addr.
30 // COMMON_SYSCALL_FD_CLOSE(fd)
31 // Called before closing file descriptor fd.
32 // COMMON_SYSCALL_FD_ACQUIRE(fd)
33 // Acquire memory visibility from fd.
34 // COMMON_SYSCALL_FD_RELEASE(fd)
35 // Release memory visibility to fd.
36 // COMMON_SYSCALL_PRE_FORK()
37 // Called before fork syscall.
38 // COMMON_SYSCALL_POST_FORK(long res)
39 // Called after fork syscall.
40 //===----------------------------------------------------------------------===//
42 #include "sanitizer_platform.h"
45 #include "sanitizer_libc.h"
47 #define PRE_SYSCALL(name) \
48 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name
49 #define PRE_READ(p, s) COMMON_SYSCALL_PRE_READ_RANGE(p, s)
50 #define PRE_WRITE(p, s) COMMON_SYSCALL_PRE_WRITE_RANGE(p, s)
52 #define POST_SYSCALL(name) \
53 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_post_impl_##name
54 #define POST_READ(p, s) COMMON_SYSCALL_POST_READ_RANGE(p, s)
55 #define POST_WRITE(p, s) COMMON_SYSCALL_POST_WRITE_RANGE(p, s)
57 #ifndef COMMON_SYSCALL_ACQUIRE
58 # define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr))
61 #ifndef COMMON_SYSCALL_RELEASE
62 # define COMMON_SYSCALL_RELEASE(addr) ((void)(addr))
65 #ifndef COMMON_SYSCALL_FD_CLOSE
66 # define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd))
69 #ifndef COMMON_SYSCALL_FD_ACQUIRE
70 # define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd))
73 #ifndef COMMON_SYSCALL_FD_RELEASE
74 # define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd))
77 #ifndef COMMON_SYSCALL_PRE_FORK
78 # define COMMON_SYSCALL_PRE_FORK() {}
81 #ifndef COMMON_SYSCALL_POST_FORK
82 # define COMMON_SYSCALL_POST_FORK(res) {}
85 // FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such).
88 struct sanitizer_kernel_iovec {
90 unsigned long iov_len;
93 struct sanitizer_kernel_msghdr {
96 struct sanitizer_kernel_iovec *msg_iov;
97 unsigned long msg_iovlen;
99 unsigned long msg_controllen;
103 struct sanitizer_kernel_mmsghdr {
104 struct sanitizer_kernel_msghdr msg_hdr;
108 struct sanitizer_kernel_timespec {
113 struct sanitizer_kernel_timeval {
118 struct sanitizer_kernel_rusage {
119 struct sanitizer_kernel_timeval ru_timeval[2];
123 struct sanitizer_kernel_sockaddr {
124 unsigned short sa_family;
128 // Real sigset size is always passed as a syscall argument.
129 // Declare it "void" to catch sizeof(kernel_sigset_t).
130 typedef void kernel_sigset_t;
132 static void kernel_write_iovec(const __sanitizer_iovec *iovec,
133 SIZE_T iovlen, SIZE_T maxlen) {
134 for (SIZE_T i = 0; i < iovlen && maxlen; ++i) {
135 SSIZE_T sz = Min(iovec[i].iov_len, maxlen);
136 POST_WRITE(iovec[i].iov_base, sz);
141 // This functions uses POST_READ, because it needs to run after syscall to know
142 // the real read range.
143 static void kernel_read_iovec(const __sanitizer_iovec *iovec,
144 SIZE_T iovlen, SIZE_T maxlen) {
145 POST_READ(iovec, sizeof(*iovec) * iovlen);
146 for (SIZE_T i = 0; i < iovlen && maxlen; ++i) {
147 SSIZE_T sz = Min(iovec[i].iov_len, maxlen);
148 POST_READ(iovec[i].iov_base, sz);
153 PRE_SYSCALL(recvmsg)(long sockfd, sanitizer_kernel_msghdr *msg, long flags) {
154 PRE_READ(msg, sizeof(*msg));
157 POST_SYSCALL(recvmsg)(long res, long sockfd, sanitizer_kernel_msghdr *msg,
161 for (unsigned long i = 0; i < msg->msg_iovlen; ++i) {
162 POST_WRITE(msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
164 POST_WRITE(msg->msg_control, msg->msg_controllen);
169 PRE_SYSCALL(recvmmsg)(long fd, sanitizer_kernel_mmsghdr *msg, long vlen,
170 long flags, void *timeout) {
171 PRE_READ(msg, vlen * sizeof(*msg));
174 POST_SYSCALL(recvmmsg)(long res, long fd, sanitizer_kernel_mmsghdr *msg,
175 long vlen, long flags, void *timeout) {
178 for (unsigned long i = 0; i < msg->msg_hdr.msg_iovlen; ++i) {
179 POST_WRITE(msg->msg_hdr.msg_iov[i].iov_base,
180 msg->msg_hdr.msg_iov[i].iov_len);
182 POST_WRITE(msg->msg_hdr.msg_control, msg->msg_hdr.msg_controllen);
183 POST_WRITE(&msg->msg_len, sizeof(msg->msg_len));
185 if (timeout) POST_WRITE(timeout, struct_timespec_sz);
189 PRE_SYSCALL(read)(long fd, void *buf, uptr count) {
191 PRE_WRITE(buf, count);
195 POST_SYSCALL(read)(long res, long fd, void *buf, uptr count) {
196 if (res > 0 && buf) {
197 POST_WRITE(buf, res);
201 PRE_SYSCALL(time)(void *tloc) {}
203 POST_SYSCALL(time)(long res, void *tloc) {
205 if (tloc) POST_WRITE(tloc, sizeof(long));
209 PRE_SYSCALL(stime)(void *tptr) {}
211 POST_SYSCALL(stime)(long res, void *tptr) {
213 if (tptr) POST_WRITE(tptr, sizeof(long));
217 PRE_SYSCALL(gettimeofday)(void *tv, void *tz) {}
219 POST_SYSCALL(gettimeofday)(long res, void *tv, void *tz) {
221 if (tv) POST_WRITE(tv, timeval_sz);
222 if (tz) POST_WRITE(tz, struct_timezone_sz);
226 PRE_SYSCALL(settimeofday)(void *tv, void *tz) {}
228 POST_SYSCALL(settimeofday)(long res, void *tv, void *tz) {
230 if (tv) POST_WRITE(tv, timeval_sz);
231 if (tz) POST_WRITE(tz, struct_timezone_sz);
235 #if !SANITIZER_ANDROID
236 PRE_SYSCALL(adjtimex)(void *txc_p) {}
238 POST_SYSCALL(adjtimex)(long res, void *txc_p) {
240 if (txc_p) POST_WRITE(txc_p, struct_timex_sz);
245 PRE_SYSCALL(times)(void *tbuf) {}
247 POST_SYSCALL(times)(long res, void *tbuf) {
249 if (tbuf) POST_WRITE(tbuf, struct_tms_sz);
253 PRE_SYSCALL(gettid)() {}
255 POST_SYSCALL(gettid)(long res) {}
257 PRE_SYSCALL(nanosleep)(void *rqtp, void *rmtp) {}
259 POST_SYSCALL(nanosleep)(long res, void *rqtp, void *rmtp) {
261 if (rqtp) POST_WRITE(rqtp, struct_timespec_sz);
262 if (rmtp) POST_WRITE(rmtp, struct_timespec_sz);
266 PRE_SYSCALL(alarm)(long seconds) {}
268 POST_SYSCALL(alarm)(long res, long seconds) {}
270 PRE_SYSCALL(getpid)() {}
272 POST_SYSCALL(getpid)(long res) {}
274 PRE_SYSCALL(getppid)() {}
276 POST_SYSCALL(getppid)(long res) {}
278 PRE_SYSCALL(getuid)() {}
280 POST_SYSCALL(getuid)(long res) {}
282 PRE_SYSCALL(geteuid)() {}
284 POST_SYSCALL(geteuid)(long res) {}
286 PRE_SYSCALL(getgid)() {}
288 POST_SYSCALL(getgid)(long res) {}
290 PRE_SYSCALL(getegid)() {}
292 POST_SYSCALL(getegid)(long res) {}
294 PRE_SYSCALL(getresuid)(void *ruid, void *euid, void *suid) {}
296 POST_SYSCALL(getresuid)(long res, void *ruid, void *euid, void *suid) {
298 if (ruid) POST_WRITE(ruid, sizeof(unsigned));
299 if (euid) POST_WRITE(euid, sizeof(unsigned));
300 if (suid) POST_WRITE(suid, sizeof(unsigned));
304 PRE_SYSCALL(getresgid)(void *rgid, void *egid, void *sgid) {}
306 POST_SYSCALL(getresgid)(long res, void *rgid, void *egid, void *sgid) {
308 if (rgid) POST_WRITE(rgid, sizeof(unsigned));
309 if (egid) POST_WRITE(egid, sizeof(unsigned));
310 if (sgid) POST_WRITE(sgid, sizeof(unsigned));
314 PRE_SYSCALL(getpgid)(long pid) {}
316 POST_SYSCALL(getpgid)(long res, long pid) {}
318 PRE_SYSCALL(getpgrp)() {}
320 POST_SYSCALL(getpgrp)(long res) {}
322 PRE_SYSCALL(getsid)(long pid) {}
324 POST_SYSCALL(getsid)(long res, long pid) {}
326 PRE_SYSCALL(getgroups)(long gidsetsize, void *grouplist) {}
328 POST_SYSCALL(getgroups)(long res, long gidsetsize,
329 __sanitizer___kernel_gid_t *grouplist) {
331 if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist));
335 PRE_SYSCALL(setregid)(long rgid, long egid) {}
337 POST_SYSCALL(setregid)(long res, long rgid, long egid) {}
339 PRE_SYSCALL(setgid)(long gid) {}
341 POST_SYSCALL(setgid)(long res, long gid) {}
343 PRE_SYSCALL(setreuid)(long ruid, long euid) {}
345 POST_SYSCALL(setreuid)(long res, long ruid, long euid) {}
347 PRE_SYSCALL(setuid)(long uid) {}
349 POST_SYSCALL(setuid)(long res, long uid) {}
351 PRE_SYSCALL(setresuid)(long ruid, long euid, long suid) {}
353 POST_SYSCALL(setresuid)(long res, long ruid, long euid, long suid) {}
355 PRE_SYSCALL(setresgid)(long rgid, long egid, long sgid) {}
357 POST_SYSCALL(setresgid)(long res, long rgid, long egid, long sgid) {}
359 PRE_SYSCALL(setfsuid)(long uid) {}
361 POST_SYSCALL(setfsuid)(long res, long uid) {}
363 PRE_SYSCALL(setfsgid)(long gid) {}
365 POST_SYSCALL(setfsgid)(long res, long gid) {}
367 PRE_SYSCALL(setpgid)(long pid, long pgid) {}
369 POST_SYSCALL(setpgid)(long res, long pid, long pgid) {}
371 PRE_SYSCALL(setsid)() {}
373 POST_SYSCALL(setsid)(long res) {}
375 PRE_SYSCALL(setgroups)(long gidsetsize, __sanitizer___kernel_gid_t *grouplist) {
376 if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
379 POST_SYSCALL(setgroups)(long res, long gidsetsize,
380 __sanitizer___kernel_gid_t *grouplist) {}
382 PRE_SYSCALL(acct)(const void *name) {
384 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
387 POST_SYSCALL(acct)(long res, const void *name) {}
389 PRE_SYSCALL(capget)(void *header, void *dataptr) {
390 if (header) PRE_READ(header, __user_cap_header_struct_sz);
393 POST_SYSCALL(capget)(long res, void *header, void *dataptr) {
395 if (dataptr) POST_WRITE(dataptr, __user_cap_data_struct_sz);
398 PRE_SYSCALL(capset)(void *header, const void *data) {
399 if (header) PRE_READ(header, __user_cap_header_struct_sz);
400 if (data) PRE_READ(data, __user_cap_data_struct_sz);
403 POST_SYSCALL(capset)(long res, void *header, const void *data) {}
405 PRE_SYSCALL(personality)(long personality) {}
407 POST_SYSCALL(personality)(long res, long personality) {}
409 PRE_SYSCALL(sigpending)(void *set) {}
411 POST_SYSCALL(sigpending)(long res, void *set) {
413 if (set) POST_WRITE(set, old_sigset_t_sz);
417 PRE_SYSCALL(sigprocmask)(long how, void *set, void *oset) {}
419 POST_SYSCALL(sigprocmask)(long res, long how, void *set, void *oset) {
421 if (set) POST_WRITE(set, old_sigset_t_sz);
422 if (oset) POST_WRITE(oset, old_sigset_t_sz);
426 PRE_SYSCALL(getitimer)(long which, void *value) {}
428 POST_SYSCALL(getitimer)(long res, long which, void *value) {
430 if (value) POST_WRITE(value, struct_itimerval_sz);
434 PRE_SYSCALL(setitimer)(long which, void *value, void *ovalue) {}
436 POST_SYSCALL(setitimer)(long res, long which, void *value, void *ovalue) {
438 if (value) POST_WRITE(value, struct_itimerval_sz);
439 if (ovalue) POST_WRITE(ovalue, struct_itimerval_sz);
443 PRE_SYSCALL(timer_create)(long which_clock, void *timer_event_spec,
444 void *created_timer_id) {}
446 POST_SYSCALL(timer_create)(long res, long which_clock, void *timer_event_spec,
447 void *created_timer_id) {
449 if (timer_event_spec) POST_WRITE(timer_event_spec, struct_sigevent_sz);
450 if (created_timer_id) POST_WRITE(created_timer_id, sizeof(long));
454 PRE_SYSCALL(timer_gettime)(long timer_id, void *setting) {}
456 POST_SYSCALL(timer_gettime)(long res, long timer_id, void *setting) {
458 if (setting) POST_WRITE(setting, struct_itimerspec_sz);
462 PRE_SYSCALL(timer_getoverrun)(long timer_id) {}
464 POST_SYSCALL(timer_getoverrun)(long res, long timer_id) {}
466 PRE_SYSCALL(timer_settime)(long timer_id, long flags, const void *new_setting,
468 if (new_setting) PRE_READ(new_setting, struct_itimerspec_sz);
471 POST_SYSCALL(timer_settime)(long res, long timer_id, long flags,
472 const void *new_setting, void *old_setting) {
474 if (old_setting) POST_WRITE(old_setting, struct_itimerspec_sz);
478 PRE_SYSCALL(timer_delete)(long timer_id) {}
480 POST_SYSCALL(timer_delete)(long res, long timer_id) {}
482 PRE_SYSCALL(clock_settime)(long which_clock, const void *tp) {
483 if (tp) PRE_READ(tp, struct_timespec_sz);
486 POST_SYSCALL(clock_settime)(long res, long which_clock, const void *tp) {}
488 PRE_SYSCALL(clock_gettime)(long which_clock, void *tp) {}
490 POST_SYSCALL(clock_gettime)(long res, long which_clock, void *tp) {
492 if (tp) POST_WRITE(tp, struct_timespec_sz);
496 #if !SANITIZER_ANDROID
497 PRE_SYSCALL(clock_adjtime)(long which_clock, void *tx) {}
499 POST_SYSCALL(clock_adjtime)(long res, long which_clock, void *tx) {
501 if (tx) POST_WRITE(tx, struct_timex_sz);
506 PRE_SYSCALL(clock_getres)(long which_clock, void *tp) {}
508 POST_SYSCALL(clock_getres)(long res, long which_clock, void *tp) {
510 if (tp) POST_WRITE(tp, struct_timespec_sz);
514 PRE_SYSCALL(clock_nanosleep)(long which_clock, long flags, const void *rqtp,
516 if (rqtp) PRE_READ(rqtp, struct_timespec_sz);
519 POST_SYSCALL(clock_nanosleep)(long res, long which_clock, long flags,
520 const void *rqtp, void *rmtp) {
522 if (rmtp) POST_WRITE(rmtp, struct_timespec_sz);
526 PRE_SYSCALL(nice)(long increment) {}
528 POST_SYSCALL(nice)(long res, long increment) {}
530 PRE_SYSCALL(sched_setscheduler)(long pid, long policy, void *param) {}
532 POST_SYSCALL(sched_setscheduler)(long res, long pid, long policy, void *param) {
534 if (param) POST_WRITE(param, struct_sched_param_sz);
538 PRE_SYSCALL(sched_setparam)(long pid, void *param) {
539 if (param) PRE_READ(param, struct_sched_param_sz);
542 POST_SYSCALL(sched_setparam)(long res, long pid, void *param) {}
544 PRE_SYSCALL(sched_getscheduler)(long pid) {}
546 POST_SYSCALL(sched_getscheduler)(long res, long pid) {}
548 PRE_SYSCALL(sched_getparam)(long pid, void *param) {}
550 POST_SYSCALL(sched_getparam)(long res, long pid, void *param) {
552 if (param) POST_WRITE(param, struct_sched_param_sz);
556 PRE_SYSCALL(sched_setaffinity)(long pid, long len, void *user_mask_ptr) {
557 if (user_mask_ptr) PRE_READ(user_mask_ptr, len);
560 POST_SYSCALL(sched_setaffinity)(long res, long pid, long len,
561 void *user_mask_ptr) {}
563 PRE_SYSCALL(sched_getaffinity)(long pid, long len, void *user_mask_ptr) {}
565 POST_SYSCALL(sched_getaffinity)(long res, long pid, long len,
566 void *user_mask_ptr) {
568 if (user_mask_ptr) POST_WRITE(user_mask_ptr, len);
572 PRE_SYSCALL(sched_yield)() {}
574 POST_SYSCALL(sched_yield)(long res) {}
576 PRE_SYSCALL(sched_get_priority_max)(long policy) {}
578 POST_SYSCALL(sched_get_priority_max)(long res, long policy) {}
580 PRE_SYSCALL(sched_get_priority_min)(long policy) {}
582 POST_SYSCALL(sched_get_priority_min)(long res, long policy) {}
584 PRE_SYSCALL(sched_rr_get_interval)(long pid, void *interval) {}
586 POST_SYSCALL(sched_rr_get_interval)(long res, long pid, void *interval) {
588 if (interval) POST_WRITE(interval, struct_timespec_sz);
592 PRE_SYSCALL(setpriority)(long which, long who, long niceval) {}
594 POST_SYSCALL(setpriority)(long res, long which, long who, long niceval) {}
596 PRE_SYSCALL(getpriority)(long which, long who) {}
598 POST_SYSCALL(getpriority)(long res, long which, long who) {}
600 PRE_SYSCALL(shutdown)(long arg0, long arg1) {}
602 POST_SYSCALL(shutdown)(long res, long arg0, long arg1) {}
604 PRE_SYSCALL(reboot)(long magic1, long magic2, long cmd, void *arg) {}
606 POST_SYSCALL(reboot)(long res, long magic1, long magic2, long cmd, void *arg) {}
608 PRE_SYSCALL(restart_syscall)() {}
610 POST_SYSCALL(restart_syscall)(long res) {}
612 PRE_SYSCALL(kexec_load)(long entry, long nr_segments, void *segments,
615 POST_SYSCALL(kexec_load)(long res, long entry, long nr_segments, void *segments,
618 if (segments) POST_WRITE(segments, struct_kexec_segment_sz);
622 PRE_SYSCALL(exit)(long error_code) {}
624 POST_SYSCALL(exit)(long res, long error_code) {}
626 PRE_SYSCALL(exit_group)(long error_code) {}
628 POST_SYSCALL(exit_group)(long res, long error_code) {}
630 PRE_SYSCALL(wait4)(long pid, void *stat_addr, long options, void *ru) {}
632 POST_SYSCALL(wait4)(long res, long pid, void *stat_addr, long options,
635 if (stat_addr) POST_WRITE(stat_addr, sizeof(int));
636 if (ru) POST_WRITE(ru, struct_rusage_sz);
640 PRE_SYSCALL(waitid)(long which, long pid, void *infop, long options, void *ru) {
643 POST_SYSCALL(waitid)(long res, long which, long pid, void *infop, long options,
646 if (infop) POST_WRITE(infop, siginfo_t_sz);
647 if (ru) POST_WRITE(ru, struct_rusage_sz);
651 PRE_SYSCALL(waitpid)(long pid, void *stat_addr, long options) {}
653 POST_SYSCALL(waitpid)(long res, long pid, void *stat_addr, long options) {
655 if (stat_addr) POST_WRITE(stat_addr, sizeof(int));
659 PRE_SYSCALL(set_tid_address)(void *tidptr) {}
661 POST_SYSCALL(set_tid_address)(long res, void *tidptr) {
663 if (tidptr) POST_WRITE(tidptr, sizeof(int));
667 PRE_SYSCALL(init_module)(void *umod, long len, const void *uargs) {
669 PRE_READ(uargs, __sanitizer::internal_strlen((const char *)uargs) + 1);
672 POST_SYSCALL(init_module)(long res, void *umod, long len, const void *uargs) {}
674 PRE_SYSCALL(delete_module)(const void *name_user, long flags) {
677 __sanitizer::internal_strlen((const char *)name_user) + 1);
680 POST_SYSCALL(delete_module)(long res, const void *name_user, long flags) {}
682 PRE_SYSCALL(rt_sigprocmask)(long how, void *set, void *oset, long sigsetsize) {}
684 POST_SYSCALL(rt_sigprocmask)(long res, long how, kernel_sigset_t *set,
685 kernel_sigset_t *oset, long sigsetsize) {
687 if (set) POST_WRITE(set, sigsetsize);
688 if (oset) POST_WRITE(oset, sigsetsize);
692 PRE_SYSCALL(rt_sigpending)(void *set, long sigsetsize) {}
694 POST_SYSCALL(rt_sigpending)(long res, kernel_sigset_t *set, long sigsetsize) {
696 if (set) POST_WRITE(set, sigsetsize);
700 PRE_SYSCALL(rt_sigtimedwait)(const kernel_sigset_t *uthese, void *uinfo,
701 const void *uts, long sigsetsize) {
702 if (uthese) PRE_READ(uthese, sigsetsize);
703 if (uts) PRE_READ(uts, struct_timespec_sz);
706 POST_SYSCALL(rt_sigtimedwait)(long res, const void *uthese, void *uinfo,
707 const void *uts, long sigsetsize) {
709 if (uinfo) POST_WRITE(uinfo, siginfo_t_sz);
713 PRE_SYSCALL(rt_tgsigqueueinfo)(long tgid, long pid, long sig, void *uinfo) {}
715 POST_SYSCALL(rt_tgsigqueueinfo)(long res, long tgid, long pid, long sig,
718 if (uinfo) POST_WRITE(uinfo, siginfo_t_sz);
722 PRE_SYSCALL(kill)(long pid, long sig) {}
724 POST_SYSCALL(kill)(long res, long pid, long sig) {}
726 PRE_SYSCALL(tgkill)(long tgid, long pid, long sig) {}
728 POST_SYSCALL(tgkill)(long res, long tgid, long pid, long sig) {}
730 PRE_SYSCALL(tkill)(long pid, long sig) {}
732 POST_SYSCALL(tkill)(long res, long pid, long sig) {}
734 PRE_SYSCALL(rt_sigqueueinfo)(long pid, long sig, void *uinfo) {}
736 POST_SYSCALL(rt_sigqueueinfo)(long res, long pid, long sig, void *uinfo) {
738 if (uinfo) POST_WRITE(uinfo, siginfo_t_sz);
742 PRE_SYSCALL(sgetmask)() {}
744 POST_SYSCALL(sgetmask)(long res) {}
746 PRE_SYSCALL(ssetmask)(long newmask) {}
748 POST_SYSCALL(ssetmask)(long res, long newmask) {}
750 PRE_SYSCALL(signal)(long sig, long handler) {}
752 POST_SYSCALL(signal)(long res, long sig, long handler) {}
754 PRE_SYSCALL(pause)() {}
756 POST_SYSCALL(pause)(long res) {}
758 PRE_SYSCALL(sync)() {}
760 POST_SYSCALL(sync)(long res) {}
762 PRE_SYSCALL(fsync)(long fd) {}
764 POST_SYSCALL(fsync)(long res, long fd) {}
766 PRE_SYSCALL(fdatasync)(long fd) {}
768 POST_SYSCALL(fdatasync)(long res, long fd) {}
770 PRE_SYSCALL(bdflush)(long func, long data) {}
772 POST_SYSCALL(bdflush)(long res, long func, long data) {}
774 PRE_SYSCALL(mount)(void *dev_name, void *dir_name, void *type, long flags,
777 POST_SYSCALL(mount)(long res, void *dev_name, void *dir_name, void *type,
778 long flags, void *data) {
782 __sanitizer::internal_strlen((const char *)dev_name) + 1);
785 __sanitizer::internal_strlen((const char *)dir_name) + 1);
787 POST_WRITE(type, __sanitizer::internal_strlen((const char *)type) + 1);
791 PRE_SYSCALL(umount)(void *name, long flags) {}
793 POST_SYSCALL(umount)(long res, void *name, long flags) {
796 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
800 PRE_SYSCALL(oldumount)(void *name) {}
802 POST_SYSCALL(oldumount)(long res, void *name) {
805 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
809 PRE_SYSCALL(truncate)(const void *path, long length) {
811 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
814 POST_SYSCALL(truncate)(long res, const void *path, long length) {}
816 PRE_SYSCALL(ftruncate)(long fd, long length) {}
818 POST_SYSCALL(ftruncate)(long res, long fd, long length) {}
820 PRE_SYSCALL(stat)(const void *filename, void *statbuf) {
823 __sanitizer::internal_strlen((const char *)filename) + 1);
826 POST_SYSCALL(stat)(long res, const void *filename, void *statbuf) {
828 if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz);
832 #if !SANITIZER_ANDROID
833 PRE_SYSCALL(statfs)(const void *path, void *buf) {
835 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
838 POST_SYSCALL(statfs)(long res, const void *path, void *buf) {
840 if (buf) POST_WRITE(buf, struct_statfs_sz);
844 PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) {
846 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
849 POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) {
851 if (buf) POST_WRITE(buf, struct_statfs64_sz);
855 PRE_SYSCALL(fstatfs)(long fd, void *buf) {}
857 POST_SYSCALL(fstatfs)(long res, long fd, void *buf) {
859 if (buf) POST_WRITE(buf, struct_statfs_sz);
863 PRE_SYSCALL(fstatfs64)(long fd, long sz, void *buf) {}
865 POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) {
867 if (buf) POST_WRITE(buf, struct_statfs64_sz);
870 #endif // !SANITIZER_ANDROID
872 PRE_SYSCALL(lstat)(const void *filename, void *statbuf) {
875 __sanitizer::internal_strlen((const char *)filename) + 1);
878 POST_SYSCALL(lstat)(long res, const void *filename, void *statbuf) {
880 if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz);
884 PRE_SYSCALL(fstat)(long fd, void *statbuf) {}
886 POST_SYSCALL(fstat)(long res, long fd, void *statbuf) {
888 if (statbuf) POST_WRITE(statbuf, struct___old_kernel_stat_sz);
892 PRE_SYSCALL(newstat)(const void *filename, void *statbuf) {
895 __sanitizer::internal_strlen((const char *)filename) + 1);
898 POST_SYSCALL(newstat)(long res, const void *filename, void *statbuf) {
900 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz);
904 PRE_SYSCALL(newlstat)(const void *filename, void *statbuf) {
907 __sanitizer::internal_strlen((const char *)filename) + 1);
910 POST_SYSCALL(newlstat)(long res, const void *filename, void *statbuf) {
912 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz);
916 PRE_SYSCALL(newfstat)(long fd, void *statbuf) {}
918 POST_SYSCALL(newfstat)(long res, long fd, void *statbuf) {
920 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz);
924 #if !SANITIZER_ANDROID
925 PRE_SYSCALL(ustat)(long dev, void *ubuf) {}
927 POST_SYSCALL(ustat)(long res, long dev, void *ubuf) {
929 if (ubuf) POST_WRITE(ubuf, struct_ustat_sz);
932 #endif // !SANITIZER_ANDROID
934 PRE_SYSCALL(stat64)(const void *filename, void *statbuf) {
937 __sanitizer::internal_strlen((const char *)filename) + 1);
940 POST_SYSCALL(stat64)(long res, const void *filename, void *statbuf) {
942 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz);
946 PRE_SYSCALL(fstat64)(long fd, void *statbuf) {}
948 POST_SYSCALL(fstat64)(long res, long fd, void *statbuf) {
950 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz);
954 PRE_SYSCALL(lstat64)(const void *filename, void *statbuf) {
957 __sanitizer::internal_strlen((const char *)filename) + 1);
960 POST_SYSCALL(lstat64)(long res, const void *filename, void *statbuf) {
962 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz);
966 PRE_SYSCALL(setxattr)(const void *path, const void *name, const void *value,
967 long size, long flags) {
969 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
971 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
972 if (value) PRE_READ(value, size);
975 POST_SYSCALL(setxattr)(long res, const void *path, const void *name,
976 const void *value, long size, long flags) {}
978 PRE_SYSCALL(lsetxattr)(const void *path, const void *name, const void *value,
979 long size, long flags) {
981 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
983 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
984 if (value) PRE_READ(value, size);
987 POST_SYSCALL(lsetxattr)(long res, const void *path, const void *name,
988 const void *value, long size, long flags) {}
990 PRE_SYSCALL(fsetxattr)(long fd, const void *name, const void *value, long size,
993 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
994 if (value) PRE_READ(value, size);
997 POST_SYSCALL(fsetxattr)(long res, long fd, const void *name, const void *value,
998 long size, long flags) {}
1000 PRE_SYSCALL(getxattr)(const void *path, const void *name, void *value,
1003 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1005 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1008 POST_SYSCALL(getxattr)(long res, const void *path, const void *name,
1009 void *value, long size) {
1010 if (size && res > 0) {
1011 if (value) POST_WRITE(value, res);
1015 PRE_SYSCALL(lgetxattr)(const void *path, const void *name, void *value,
1018 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1020 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1023 POST_SYSCALL(lgetxattr)(long res, const void *path, const void *name,
1024 void *value, long size) {
1025 if (size && res > 0) {
1026 if (value) POST_WRITE(value, res);
1030 PRE_SYSCALL(fgetxattr)(long fd, const void *name, void *value, long size) {
1032 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1035 POST_SYSCALL(fgetxattr)(long res, long fd, const void *name, void *value,
1037 if (size && res > 0) {
1038 if (value) POST_WRITE(value, res);
1042 PRE_SYSCALL(listxattr)(const void *path, void *list, long size) {
1044 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1047 POST_SYSCALL(listxattr)(long res, const void *path, void *list, long size) {
1048 if (size && res > 0) {
1049 if (list) POST_WRITE(list, res);
1053 PRE_SYSCALL(llistxattr)(const void *path, void *list, long size) {
1055 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1058 POST_SYSCALL(llistxattr)(long res, const void *path, void *list, long size) {
1059 if (size && res > 0) {
1060 if (list) POST_WRITE(list, res);
1064 PRE_SYSCALL(flistxattr)(long fd, void *list, long size) {}
1066 POST_SYSCALL(flistxattr)(long res, long fd, void *list, long size) {
1067 if (size && res > 0) {
1068 if (list) POST_WRITE(list, res);
1072 PRE_SYSCALL(removexattr)(const void *path, const void *name) {
1074 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1076 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1079 POST_SYSCALL(removexattr)(long res, const void *path, const void *name) {}
1081 PRE_SYSCALL(lremovexattr)(const void *path, const void *name) {
1083 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1085 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1088 POST_SYSCALL(lremovexattr)(long res, const void *path, const void *name) {}
1090 PRE_SYSCALL(fremovexattr)(long fd, const void *name) {
1092 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1095 POST_SYSCALL(fremovexattr)(long res, long fd, const void *name) {}
1097 PRE_SYSCALL(brk)(long brk) {}
1099 POST_SYSCALL(brk)(long res, long brk) {}
1101 PRE_SYSCALL(mprotect)(long start, long len, long prot) {}
1103 POST_SYSCALL(mprotect)(long res, long start, long len, long prot) {}
1105 PRE_SYSCALL(mremap)(long addr, long old_len, long new_len, long flags,
1108 POST_SYSCALL(mremap)(long res, long addr, long old_len, long new_len,
1109 long flags, long new_addr) {}
1111 PRE_SYSCALL(remap_file_pages)(long start, long size, long prot, long pgoff,
1114 POST_SYSCALL(remap_file_pages)(long res, long start, long size, long prot,
1115 long pgoff, long flags) {}
1117 PRE_SYSCALL(msync)(long start, long len, long flags) {}
1119 POST_SYSCALL(msync)(long res, long start, long len, long flags) {}
1121 PRE_SYSCALL(munmap)(long addr, long len) {}
1123 POST_SYSCALL(munmap)(long res, long addr, long len) {}
1125 PRE_SYSCALL(mlock)(long start, long len) {}
1127 POST_SYSCALL(mlock)(long res, long start, long len) {}
1129 PRE_SYSCALL(munlock)(long start, long len) {}
1131 POST_SYSCALL(munlock)(long res, long start, long len) {}
1133 PRE_SYSCALL(mlockall)(long flags) {}
1135 POST_SYSCALL(mlockall)(long res, long flags) {}
1137 PRE_SYSCALL(munlockall)() {}
1139 POST_SYSCALL(munlockall)(long res) {}
1141 PRE_SYSCALL(madvise)(long start, long len, long behavior) {}
1143 POST_SYSCALL(madvise)(long res, long start, long len, long behavior) {}
1145 PRE_SYSCALL(mincore)(long start, long len, void *vec) {}
1147 POST_SYSCALL(mincore)(long res, long start, long len, void *vec) {
1150 POST_WRITE(vec, (len + GetPageSizeCached() - 1) / GetPageSizeCached());
1155 PRE_SYSCALL(pivot_root)(const void *new_root, const void *put_old) {
1158 __sanitizer::internal_strlen((const char *)new_root) + 1);
1160 PRE_READ(put_old, __sanitizer::internal_strlen((const char *)put_old) + 1);
1163 POST_SYSCALL(pivot_root)(long res, const void *new_root, const void *put_old) {}
1165 PRE_SYSCALL(chroot)(const void *filename) {
1168 __sanitizer::internal_strlen((const char *)filename) + 1);
1171 POST_SYSCALL(chroot)(long res, const void *filename) {}
1173 PRE_SYSCALL(mknod)(const void *filename, long mode, long dev) {
1176 __sanitizer::internal_strlen((const char *)filename) + 1);
1179 POST_SYSCALL(mknod)(long res, const void *filename, long mode, long dev) {}
1181 PRE_SYSCALL(link)(const void *oldname, const void *newname) {
1183 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
1185 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
1188 POST_SYSCALL(link)(long res, const void *oldname, const void *newname) {}
1190 PRE_SYSCALL(symlink)(const void *old, const void *new_) {
1191 if (old) PRE_READ(old, __sanitizer::internal_strlen((const char *)old) + 1);
1193 PRE_READ(new_, __sanitizer::internal_strlen((const char *)new_) + 1);
1196 POST_SYSCALL(symlink)(long res, const void *old, const void *new_) {}
1198 PRE_SYSCALL(unlink)(const void *pathname) {
1201 __sanitizer::internal_strlen((const char *)pathname) + 1);
1204 POST_SYSCALL(unlink)(long res, const void *pathname) {}
1206 PRE_SYSCALL(rename)(const void *oldname, const void *newname) {
1208 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
1210 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
1213 POST_SYSCALL(rename)(long res, const void *oldname, const void *newname) {}
1215 PRE_SYSCALL(chmod)(const void *filename, long mode) {
1218 __sanitizer::internal_strlen((const char *)filename) + 1);
1221 POST_SYSCALL(chmod)(long res, const void *filename, long mode) {}
1223 PRE_SYSCALL(fchmod)(long fd, long mode) {}
1225 POST_SYSCALL(fchmod)(long res, long fd, long mode) {}
1227 PRE_SYSCALL(fcntl)(long fd, long cmd, long arg) {}
1229 POST_SYSCALL(fcntl)(long res, long fd, long cmd, long arg) {}
1231 PRE_SYSCALL(fcntl64)(long fd, long cmd, long arg) {}
1233 POST_SYSCALL(fcntl64)(long res, long fd, long cmd, long arg) {}
1235 PRE_SYSCALL(pipe)(void *fildes) {}
1237 POST_SYSCALL(pipe)(long res, void *fildes) {
1239 if (fildes) POST_WRITE(fildes, sizeof(int) * 2);
1242 PRE_SYSCALL(pipe2)(void *fildes, long flags) {}
1244 POST_SYSCALL(pipe2)(long res, void *fildes, long flags) {
1246 if (fildes) POST_WRITE(fildes, sizeof(int) * 2);
1249 PRE_SYSCALL(dup)(long fildes) {}
1251 POST_SYSCALL(dup)(long res, long fildes) {}
1253 PRE_SYSCALL(dup2)(long oldfd, long newfd) {}
1255 POST_SYSCALL(dup2)(long res, long oldfd, long newfd) {}
1257 PRE_SYSCALL(dup3)(long oldfd, long newfd, long flags) {}
1259 POST_SYSCALL(dup3)(long res, long oldfd, long newfd, long flags) {}
1261 PRE_SYSCALL(ioperm)(long from, long num, long on) {}
1263 POST_SYSCALL(ioperm)(long res, long from, long num, long on) {}
1265 PRE_SYSCALL(ioctl)(long fd, long cmd, long arg) {}
1267 POST_SYSCALL(ioctl)(long res, long fd, long cmd, long arg) {}
1269 PRE_SYSCALL(flock)(long fd, long cmd) {}
1271 POST_SYSCALL(flock)(long res, long fd, long cmd) {}
1273 PRE_SYSCALL(io_setup)(long nr_reqs, void **ctx) {
1274 if (ctx) PRE_WRITE(ctx, sizeof(*ctx));
1277 POST_SYSCALL(io_setup)(long res, long nr_reqs, void **ctx) {
1279 if (ctx) POST_WRITE(ctx, sizeof(*ctx));
1280 // (*ctx) is actually a pointer to a kernel mapped page, and there are
1281 // people out there who are crazy enough to peek into that page's 32-byte
1283 if (*ctx) POST_WRITE(*ctx, 32);
1287 PRE_SYSCALL(io_destroy)(long ctx) {}
1289 POST_SYSCALL(io_destroy)(long res, long ctx) {}
1291 PRE_SYSCALL(io_getevents)(long ctx_id, long min_nr, long nr,
1292 __sanitizer_io_event *ioevpp, void *timeout) {
1293 if (timeout) PRE_READ(timeout, struct_timespec_sz);
1296 POST_SYSCALL(io_getevents)(long res, long ctx_id, long min_nr, long nr,
1297 __sanitizer_io_event *ioevpp, void *timeout) {
1299 if (ioevpp) POST_WRITE(ioevpp, res * sizeof(*ioevpp));
1300 if (timeout) POST_WRITE(timeout, struct_timespec_sz);
1302 for (long i = 0; i < res; i++) {
1303 // We synchronize io_submit -> io_getevents/io_cancel using the
1304 // user-provided data context. Data is not necessary a pointer, it can be
1305 // an int, 0 or whatever; acquire/release will correctly handle this.
1306 // This scheme can lead to false negatives, e.g. when all operations
1307 // synchronize on 0. But there does not seem to be a better solution
1308 // (except wrapping all operations in own context, which is unreliable).
1309 // We can not reliably extract fildes in io_getevents.
1310 COMMON_SYSCALL_ACQUIRE((void*)ioevpp[i].data);
1314 PRE_SYSCALL(io_submit)(long ctx_id, long nr, __sanitizer_iocb **iocbpp) {
1315 for (long i = 0; i < nr; ++i) {
1316 uptr op = iocbpp[i]->aio_lio_opcode;
1317 void *data = (void*)iocbpp[i]->aio_data;
1318 void *buf = (void*)iocbpp[i]->aio_buf;
1319 uptr len = (uptr)iocbpp[i]->aio_nbytes;
1320 if (op == iocb_cmd_pwrite && buf && len) {
1322 } else if (op == iocb_cmd_pread && buf && len) {
1323 POST_WRITE(buf, len);
1324 } else if (op == iocb_cmd_pwritev) {
1325 __sanitizer_iovec *iovec = (__sanitizer_iovec*)buf;
1326 for (uptr v = 0; v < len; v++)
1327 PRE_READ(iovec[v].iov_base, iovec[v].iov_len);
1328 } else if (op == iocb_cmd_preadv) {
1329 __sanitizer_iovec *iovec = (__sanitizer_iovec*)buf;
1330 for (uptr v = 0; v < len; v++)
1331 POST_WRITE(iovec[v].iov_base, iovec[v].iov_len);
1333 // See comment in io_getevents.
1334 COMMON_SYSCALL_RELEASE(data);
1338 POST_SYSCALL(io_submit)(long res, long ctx_id, long nr,
1339 __sanitizer_iocb **iocbpp) {}
1341 PRE_SYSCALL(io_cancel)(long ctx_id, __sanitizer_iocb *iocb,
1342 __sanitizer_io_event *result) {
1345 POST_SYSCALL(io_cancel)(long res, long ctx_id, __sanitizer_iocb *iocb,
1346 __sanitizer_io_event *result) {
1349 // See comment in io_getevents.
1350 COMMON_SYSCALL_ACQUIRE((void*)result->data);
1351 POST_WRITE(result, sizeof(*result));
1354 POST_WRITE(iocb, sizeof(*iocb));
1358 PRE_SYSCALL(sendfile)(long out_fd, long in_fd, void *offset, long count) {}
1360 POST_SYSCALL(sendfile)(long res, long out_fd, long in_fd,
1361 __sanitizer___kernel_off_t *offset, long count) {
1363 if (offset) POST_WRITE(offset, sizeof(*offset));
1367 PRE_SYSCALL(sendfile64)(long out_fd, long in_fd, void *offset, long count) {}
1369 POST_SYSCALL(sendfile64)(long res, long out_fd, long in_fd,
1370 __sanitizer___kernel_loff_t *offset, long count) {
1372 if (offset) POST_WRITE(offset, sizeof(*offset));
1376 PRE_SYSCALL(readlink)(const void *path, void *buf, long bufsiz) {
1378 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1381 POST_SYSCALL(readlink)(long res, const void *path, void *buf, long bufsiz) {
1384 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1388 PRE_SYSCALL(creat)(const void *pathname, long mode) {
1391 __sanitizer::internal_strlen((const char *)pathname) + 1);
1394 POST_SYSCALL(creat)(long res, const void *pathname, long mode) {}
1396 PRE_SYSCALL(open)(const void *filename, long flags, long mode) {
1399 __sanitizer::internal_strlen((const char *)filename) + 1);
1402 POST_SYSCALL(open)(long res, const void *filename, long flags, long mode) {}
1404 PRE_SYSCALL(close)(long fd) {
1405 COMMON_SYSCALL_FD_CLOSE((int)fd);
1408 POST_SYSCALL(close)(long res, long fd) {}
1410 PRE_SYSCALL(access)(const void *filename, long mode) {
1413 __sanitizer::internal_strlen((const char *)filename) + 1);
1416 POST_SYSCALL(access)(long res, const void *filename, long mode) {}
1418 PRE_SYSCALL(vhangup)() {}
1420 POST_SYSCALL(vhangup)(long res) {}
1422 PRE_SYSCALL(chown)(const void *filename, long user, long group) {
1425 __sanitizer::internal_strlen((const char *)filename) + 1);
1428 POST_SYSCALL(chown)(long res, const void *filename, long user, long group) {}
1430 PRE_SYSCALL(lchown)(const void *filename, long user, long group) {
1433 __sanitizer::internal_strlen((const char *)filename) + 1);
1436 POST_SYSCALL(lchown)(long res, const void *filename, long user, long group) {}
1438 PRE_SYSCALL(fchown)(long fd, long user, long group) {}
1440 POST_SYSCALL(fchown)(long res, long fd, long user, long group) {}
1442 #if SANITIZER_USES_UID16_SYSCALLS
1443 PRE_SYSCALL(chown16)(const void *filename, long user, long group) {
1446 __sanitizer::internal_strlen((const char *)filename) + 1);
1449 POST_SYSCALL(chown16)(long res, const void *filename, long user, long group) {}
1451 PRE_SYSCALL(lchown16)(const void *filename, long user, long group) {
1454 __sanitizer::internal_strlen((const char *)filename) + 1);
1457 POST_SYSCALL(lchown16)(long res, const void *filename, long user, long group) {}
1459 PRE_SYSCALL(fchown16)(long fd, long user, long group) {}
1461 POST_SYSCALL(fchown16)(long res, long fd, long user, long group) {}
1463 PRE_SYSCALL(setregid16)(long rgid, long egid) {}
1465 POST_SYSCALL(setregid16)(long res, long rgid, long egid) {}
1467 PRE_SYSCALL(setgid16)(long gid) {}
1469 POST_SYSCALL(setgid16)(long res, long gid) {}
1471 PRE_SYSCALL(setreuid16)(long ruid, long euid) {}
1473 POST_SYSCALL(setreuid16)(long res, long ruid, long euid) {}
1475 PRE_SYSCALL(setuid16)(long uid) {}
1477 POST_SYSCALL(setuid16)(long res, long uid) {}
1479 PRE_SYSCALL(setresuid16)(long ruid, long euid, long suid) {}
1481 POST_SYSCALL(setresuid16)(long res, long ruid, long euid, long suid) {}
1483 PRE_SYSCALL(getresuid16)(void *ruid, void *euid, void *suid) {}
1485 POST_SYSCALL(getresuid16)(long res, __sanitizer___kernel_old_uid_t *ruid,
1486 __sanitizer___kernel_old_uid_t *euid,
1487 __sanitizer___kernel_old_uid_t *suid) {
1489 if (ruid) POST_WRITE(ruid, sizeof(*ruid));
1490 if (euid) POST_WRITE(euid, sizeof(*euid));
1491 if (suid) POST_WRITE(suid, sizeof(*suid));
1495 PRE_SYSCALL(setresgid16)(long rgid, long egid, long sgid) {}
1497 POST_SYSCALL(setresgid16)(long res, long rgid, long egid, long sgid) {}
1499 PRE_SYSCALL(getresgid16)(void *rgid, void *egid, void *sgid) {}
1501 POST_SYSCALL(getresgid16)(long res, __sanitizer___kernel_old_gid_t *rgid,
1502 __sanitizer___kernel_old_gid_t *egid,
1503 __sanitizer___kernel_old_gid_t *sgid) {
1505 if (rgid) POST_WRITE(rgid, sizeof(*rgid));
1506 if (egid) POST_WRITE(egid, sizeof(*egid));
1507 if (sgid) POST_WRITE(sgid, sizeof(*sgid));
1511 PRE_SYSCALL(setfsuid16)(long uid) {}
1513 POST_SYSCALL(setfsuid16)(long res, long uid) {}
1515 PRE_SYSCALL(setfsgid16)(long gid) {}
1517 POST_SYSCALL(setfsgid16)(long res, long gid) {}
1519 PRE_SYSCALL(getgroups16)(long gidsetsize,
1520 __sanitizer___kernel_old_gid_t *grouplist) {}
1522 POST_SYSCALL(getgroups16)(long res, long gidsetsize,
1523 __sanitizer___kernel_old_gid_t *grouplist) {
1525 if (grouplist) POST_WRITE(grouplist, res * sizeof(*grouplist));
1529 PRE_SYSCALL(setgroups16)(long gidsetsize,
1530 __sanitizer___kernel_old_gid_t *grouplist) {
1531 if (grouplist) POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
1534 POST_SYSCALL(setgroups16)(long res, long gidsetsize,
1535 __sanitizer___kernel_old_gid_t *grouplist) {}
1537 PRE_SYSCALL(getuid16)() {}
1539 POST_SYSCALL(getuid16)(long res) {}
1541 PRE_SYSCALL(geteuid16)() {}
1543 POST_SYSCALL(geteuid16)(long res) {}
1545 PRE_SYSCALL(getgid16)() {}
1547 POST_SYSCALL(getgid16)(long res) {}
1549 PRE_SYSCALL(getegid16)() {}
1551 POST_SYSCALL(getegid16)(long res) {}
1552 #endif // SANITIZER_USES_UID16_SYSCALLS
1554 PRE_SYSCALL(utime)(void *filename, void *times) {}
1556 POST_SYSCALL(utime)(long res, void *filename, void *times) {
1559 POST_WRITE(filename,
1560 __sanitizer::internal_strlen((const char *)filename) + 1);
1561 if (times) POST_WRITE(times, struct_utimbuf_sz);
1565 PRE_SYSCALL(utimes)(void *filename, void *utimes) {}
1567 POST_SYSCALL(utimes)(long res, void *filename, void *utimes) {
1570 POST_WRITE(filename,
1571 __sanitizer::internal_strlen((const char *)filename) + 1);
1572 if (utimes) POST_WRITE(utimes, timeval_sz);
1576 PRE_SYSCALL(lseek)(long fd, long offset, long origin) {}
1578 POST_SYSCALL(lseek)(long res, long fd, long offset, long origin) {}
1580 PRE_SYSCALL(llseek)(long fd, long offset_high, long offset_low, void *result,
1583 POST_SYSCALL(llseek)(long res, long fd, long offset_high, long offset_low,
1584 void *result, long origin) {
1586 if (result) POST_WRITE(result, sizeof(long long));
1590 PRE_SYSCALL(readv)(long fd, const __sanitizer_iovec *vec, long vlen) {}
1592 POST_SYSCALL(readv)(long res, long fd, const __sanitizer_iovec *vec,
1595 if (vec) kernel_write_iovec(vec, vlen, res);
1599 PRE_SYSCALL(write)(long fd, const void *buf, long count) {
1600 if (buf) PRE_READ(buf, count);
1603 POST_SYSCALL(write)(long res, long fd, const void *buf, long count) {}
1605 PRE_SYSCALL(writev)(long fd, const __sanitizer_iovec *vec, long vlen) {}
1607 POST_SYSCALL(writev)(long res, long fd, const __sanitizer_iovec *vec,
1610 if (vec) kernel_read_iovec(vec, vlen, res);
1615 PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos) {}
1617 POST_SYSCALL(pread64)(long res, long fd, void *buf, long count, long pos) {
1619 if (buf) POST_WRITE(buf, res);
1623 PRE_SYSCALL(pwrite64)(long fd, const void *buf, long count, long pos) {
1624 if (buf) PRE_READ(buf, count);
1627 POST_SYSCALL(pwrite64)(long res, long fd, const void *buf, long count,
1630 PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos0, long pos1) {}
1632 POST_SYSCALL(pread64)(long res, long fd, void *buf, long count, long pos0,
1635 if (buf) POST_WRITE(buf, res);
1639 PRE_SYSCALL(pwrite64)(long fd, const void *buf, long count, long pos0,
1641 if (buf) PRE_READ(buf, count);
1644 POST_SYSCALL(pwrite64)(long res, long fd, const void *buf, long count,
1645 long pos0, long pos1) {}
1648 PRE_SYSCALL(preadv)(long fd, const __sanitizer_iovec *vec, long vlen,
1649 long pos_l, long pos_h) {}
1651 POST_SYSCALL(preadv)(long res, long fd, const __sanitizer_iovec *vec, long vlen,
1652 long pos_l, long pos_h) {
1654 if (vec) kernel_write_iovec(vec, vlen, res);
1658 PRE_SYSCALL(pwritev)(long fd, const __sanitizer_iovec *vec, long vlen,
1659 long pos_l, long pos_h) {}
1661 POST_SYSCALL(pwritev)(long res, long fd, const __sanitizer_iovec *vec,
1662 long vlen, long pos_l, long pos_h) {
1664 if (vec) kernel_read_iovec(vec, vlen, res);
1668 PRE_SYSCALL(getcwd)(void *buf, long size) {}
1670 POST_SYSCALL(getcwd)(long res, void *buf, long size) {
1673 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1677 PRE_SYSCALL(mkdir)(const void *pathname, long mode) {
1680 __sanitizer::internal_strlen((const char *)pathname) + 1);
1683 POST_SYSCALL(mkdir)(long res, const void *pathname, long mode) {}
1685 PRE_SYSCALL(chdir)(const void *filename) {
1688 __sanitizer::internal_strlen((const char *)filename) + 1);
1691 POST_SYSCALL(chdir)(long res, const void *filename) {}
1693 PRE_SYSCALL(fchdir)(long fd) {}
1695 POST_SYSCALL(fchdir)(long res, long fd) {}
1697 PRE_SYSCALL(rmdir)(const void *pathname) {
1700 __sanitizer::internal_strlen((const char *)pathname) + 1);
1703 POST_SYSCALL(rmdir)(long res, const void *pathname) {}
1705 PRE_SYSCALL(lookup_dcookie)(u64 cookie64, void *buf, long len) {}
1707 POST_SYSCALL(lookup_dcookie)(long res, u64 cookie64, void *buf, long len) {
1710 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1714 PRE_SYSCALL(quotactl)(long cmd, const void *special, long id, void *addr) {
1716 PRE_READ(special, __sanitizer::internal_strlen((const char *)special) + 1);
1719 POST_SYSCALL(quotactl)(long res, long cmd, const void *special, long id,
1722 PRE_SYSCALL(getdents)(long fd, void *dirent, long count) {}
1724 POST_SYSCALL(getdents)(long res, long fd, void *dirent, long count) {
1726 if (dirent) POST_WRITE(dirent, res);
1730 PRE_SYSCALL(getdents64)(long fd, void *dirent, long count) {}
1732 POST_SYSCALL(getdents64)(long res, long fd, void *dirent, long count) {
1734 if (dirent) POST_WRITE(dirent, res);
1738 PRE_SYSCALL(setsockopt)(long fd, long level, long optname, void *optval,
1741 POST_SYSCALL(setsockopt)(long res, long fd, long level, long optname,
1742 void *optval, long optlen) {
1746 __sanitizer::internal_strlen((const char *)optval) + 1);
1750 PRE_SYSCALL(getsockopt)(long fd, long level, long optname, void *optval,
1753 POST_SYSCALL(getsockopt)(long res, long fd, long level, long optname,
1754 void *optval, void *optlen) {
1758 __sanitizer::internal_strlen((const char *)optval) + 1);
1759 if (optlen) POST_WRITE(optlen, sizeof(int));
1763 PRE_SYSCALL(bind)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {}
1765 POST_SYSCALL(bind)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1768 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1772 PRE_SYSCALL(connect)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {}
1774 POST_SYSCALL(connect)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1777 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1781 PRE_SYSCALL(accept)(long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {}
1783 POST_SYSCALL(accept)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1786 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1787 if (arg2) POST_WRITE(arg2, sizeof(unsigned));
1791 PRE_SYSCALL(accept4)(long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2,
1794 POST_SYSCALL(accept4)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1795 void *arg2, long arg3) {
1797 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1798 if (arg2) POST_WRITE(arg2, sizeof(unsigned));
1802 PRE_SYSCALL(getsockname)(long arg0, sanitizer_kernel_sockaddr *arg1,
1805 POST_SYSCALL(getsockname)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1808 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1809 if (arg2) POST_WRITE(arg2, sizeof(unsigned));
1813 PRE_SYSCALL(getpeername)(long arg0, sanitizer_kernel_sockaddr *arg1,
1816 POST_SYSCALL(getpeername)(long res, long arg0, sanitizer_kernel_sockaddr *arg1,
1819 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
1820 if (arg2) POST_WRITE(arg2, sizeof(unsigned));
1824 PRE_SYSCALL(send)(long arg0, void *arg1, long arg2, long arg3) {}
1826 POST_SYSCALL(send)(long res, long arg0, void *arg1, long arg2, long arg3) {
1828 if (arg1) POST_READ(arg1, res);
1832 PRE_SYSCALL(sendto)(long arg0, void *arg1, long arg2, long arg3,
1833 sanitizer_kernel_sockaddr *arg4, long arg5) {}
1835 POST_SYSCALL(sendto)(long res, long arg0, void *arg1, long arg2, long arg3,
1836 sanitizer_kernel_sockaddr *arg4, long arg5) {
1838 if (arg1) POST_READ(arg1, res);
1839 if (arg4) POST_WRITE(arg4, sizeof(*arg4));
1843 PRE_SYSCALL(sendmsg)(long fd, void *msg, long flags) {}
1845 POST_SYSCALL(sendmsg)(long res, long fd, void *msg, long flags) {
1849 PRE_SYSCALL(sendmmsg)(long fd, void *msg, long vlen, long flags) {}
1851 POST_SYSCALL(sendmmsg)(long res, long fd, void *msg, long vlen, long flags) {
1855 PRE_SYSCALL(recv)(long arg0, void *buf, long len, long flags) {}
1857 POST_SYSCALL(recv)(long res, void *buf, long len, long flags) {
1859 if (buf) POST_WRITE(buf, res);
1863 PRE_SYSCALL(recvfrom)(long arg0, void *buf, long len, long flags,
1864 sanitizer_kernel_sockaddr *arg4, void *arg5) {}
1866 POST_SYSCALL(recvfrom)(long res, long arg0, void *buf, long len, long flags,
1867 sanitizer_kernel_sockaddr *arg4, void *arg5) {
1869 if (buf) POST_WRITE(buf, res);
1870 if (arg4) POST_WRITE(arg4, sizeof(*arg4));
1871 if (arg5) POST_WRITE(arg5, sizeof(int));
1875 PRE_SYSCALL(socket)(long arg0, long arg1, long arg2) {}
1877 POST_SYSCALL(socket)(long res, long arg0, long arg1, long arg2) {}
1879 PRE_SYSCALL(socketpair)(long arg0, long arg1, long arg2, int *sv) {}
1881 POST_SYSCALL(socketpair)(long res, long arg0, long arg1, long arg2, int *sv) {
1883 if (sv) POST_WRITE(sv, sizeof(int) * 2);
1886 PRE_SYSCALL(socketcall)(long call, void *args) {}
1888 POST_SYSCALL(socketcall)(long res, long call, void *args) {
1890 if (args) POST_WRITE(args, sizeof(long));
1894 PRE_SYSCALL(listen)(long arg0, long arg1) {}
1896 POST_SYSCALL(listen)(long res, long arg0, long arg1) {}
1898 PRE_SYSCALL(poll)(void *ufds, long nfds, long timeout) {}
1900 POST_SYSCALL(poll)(long res, __sanitizer_pollfd *ufds, long nfds,
1903 if (ufds) POST_WRITE(ufds, nfds * sizeof(*ufds));
1907 PRE_SYSCALL(select)(long n, __sanitizer___kernel_fd_set *inp,
1908 __sanitizer___kernel_fd_set *outp,
1909 __sanitizer___kernel_fd_set *exp, void *tvp) {}
1911 POST_SYSCALL(select)(long res, long n, __sanitizer___kernel_fd_set *inp,
1912 __sanitizer___kernel_fd_set *outp,
1913 __sanitizer___kernel_fd_set *exp, void *tvp) {
1915 if (inp) POST_WRITE(inp, sizeof(*inp));
1916 if (outp) POST_WRITE(outp, sizeof(*outp));
1917 if (exp) POST_WRITE(exp, sizeof(*exp));
1918 if (tvp) POST_WRITE(tvp, timeval_sz);
1922 PRE_SYSCALL(old_select)(void *arg) {}
1924 POST_SYSCALL(old_select)(long res, void *arg) {}
1926 PRE_SYSCALL(epoll_create)(long size) {}
1928 POST_SYSCALL(epoll_create)(long res, long size) {}
1930 PRE_SYSCALL(epoll_create1)(long flags) {}
1932 POST_SYSCALL(epoll_create1)(long res, long flags) {}
1934 PRE_SYSCALL(epoll_ctl)(long epfd, long op, long fd, void *event) {}
1936 POST_SYSCALL(epoll_ctl)(long res, long epfd, long op, long fd, void *event) {
1938 if (event) POST_WRITE(event, struct_epoll_event_sz);
1942 PRE_SYSCALL(epoll_wait)(long epfd, void *events, long maxevents, long timeout) {
1945 POST_SYSCALL(epoll_wait)(long res, long epfd, void *events, long maxevents,
1948 if (events) POST_WRITE(events, struct_epoll_event_sz);
1952 PRE_SYSCALL(epoll_pwait)(long epfd, void *events, long maxevents, long timeout,
1953 const kernel_sigset_t *sigmask, long sigsetsize) {
1954 if (sigmask) PRE_READ(sigmask, sigsetsize);
1957 POST_SYSCALL(epoll_pwait)(long res, long epfd, void *events, long maxevents,
1958 long timeout, const void *sigmask, long sigsetsize) {
1960 if (events) POST_WRITE(events, struct_epoll_event_sz);
1964 PRE_SYSCALL(gethostname)(void *name, long len) {}
1966 POST_SYSCALL(gethostname)(long res, void *name, long len) {
1969 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
1973 PRE_SYSCALL(sethostname)(void *name, long len) {}
1975 POST_SYSCALL(sethostname)(long res, void *name, long len) {
1978 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
1982 PRE_SYSCALL(setdomainname)(void *name, long len) {}
1984 POST_SYSCALL(setdomainname)(long res, void *name, long len) {
1987 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
1991 PRE_SYSCALL(newuname)(void *name) {}
1993 POST_SYSCALL(newuname)(long res, void *name) {
1995 if (name) POST_WRITE(name, struct_new_utsname_sz);
1999 PRE_SYSCALL(uname)(void *arg0) {}
2001 POST_SYSCALL(uname)(long res, void *arg0) {
2003 if (arg0) POST_WRITE(arg0, struct_old_utsname_sz);
2007 PRE_SYSCALL(olduname)(void *arg0) {}
2009 POST_SYSCALL(olduname)(long res, void *arg0) {
2011 if (arg0) POST_WRITE(arg0, struct_oldold_utsname_sz);
2015 PRE_SYSCALL(getrlimit)(long resource, void *rlim) {}
2017 POST_SYSCALL(getrlimit)(long res, long resource, void *rlim) {
2019 if (rlim) POST_WRITE(rlim, struct_rlimit_sz);
2023 PRE_SYSCALL(old_getrlimit)(long resource, void *rlim) {}
2025 POST_SYSCALL(old_getrlimit)(long res, long resource, void *rlim) {
2027 if (rlim) POST_WRITE(rlim, struct_rlimit_sz);
2031 PRE_SYSCALL(setrlimit)(long resource, void *rlim) {}
2033 POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
2035 if (rlim) POST_WRITE(rlim, struct_rlimit_sz);
2039 #if !SANITIZER_ANDROID
2040 PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
2042 if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
2045 POST_SYSCALL(prlimit64)(long res, long pid, long resource, const void *new_rlim,
2048 if (old_rlim) POST_WRITE(old_rlim, struct_rlimit64_sz);
2053 PRE_SYSCALL(getrusage)(long who, void *ru) {}
2055 POST_SYSCALL(getrusage)(long res, long who, void *ru) {
2057 if (ru) POST_WRITE(ru, struct_rusage_sz);
2061 PRE_SYSCALL(umask)(long mask) {}
2063 POST_SYSCALL(umask)(long res, long mask) {}
2065 PRE_SYSCALL(msgget)(long key, long msgflg) {}
2067 POST_SYSCALL(msgget)(long res, long key, long msgflg) {}
2069 PRE_SYSCALL(msgsnd)(long msqid, void *msgp, long msgsz, long msgflg) {
2070 if (msgp) PRE_READ(msgp, msgsz);
2073 POST_SYSCALL(msgsnd)(long res, long msqid, void *msgp, long msgsz,
2076 PRE_SYSCALL(msgrcv)(long msqid, void *msgp, long msgsz, long msgtyp,
2079 POST_SYSCALL(msgrcv)(long res, long msqid, void *msgp, long msgsz, long msgtyp,
2082 if (msgp) POST_WRITE(msgp, res);
2086 #if !SANITIZER_ANDROID
2087 PRE_SYSCALL(msgctl)(long msqid, long cmd, void *buf) {}
2089 POST_SYSCALL(msgctl)(long res, long msqid, long cmd, void *buf) {
2091 if (buf) POST_WRITE(buf, struct_msqid_ds_sz);
2096 PRE_SYSCALL(semget)(long key, long nsems, long semflg) {}
2098 POST_SYSCALL(semget)(long res, long key, long nsems, long semflg) {}
2100 PRE_SYSCALL(semop)(long semid, void *sops, long nsops) {}
2102 POST_SYSCALL(semop)(long res, long semid, void *sops, long nsops) {}
2104 PRE_SYSCALL(semctl)(long semid, long semnum, long cmd, void *arg) {}
2106 POST_SYSCALL(semctl)(long res, long semid, long semnum, long cmd, void *arg) {}
2108 PRE_SYSCALL(semtimedop)(long semid, void *sops, long nsops,
2109 const void *timeout) {
2110 if (timeout) PRE_READ(timeout, struct_timespec_sz);
2113 POST_SYSCALL(semtimedop)(long res, long semid, void *sops, long nsops,
2114 const void *timeout) {}
2116 PRE_SYSCALL(shmat)(long shmid, void *shmaddr, long shmflg) {}
2118 POST_SYSCALL(shmat)(long res, long shmid, void *shmaddr, long shmflg) {
2122 __sanitizer::internal_strlen((const char *)shmaddr) + 1);
2126 PRE_SYSCALL(shmget)(long key, long size, long flag) {}
2128 POST_SYSCALL(shmget)(long res, long key, long size, long flag) {}
2130 PRE_SYSCALL(shmdt)(void *shmaddr) {}
2132 POST_SYSCALL(shmdt)(long res, void *shmaddr) {
2136 __sanitizer::internal_strlen((const char *)shmaddr) + 1);
2140 PRE_SYSCALL(ipc)(long call, long first, long second, long third, void *ptr,
2143 POST_SYSCALL(ipc)(long res, long call, long first, long second, long third,
2144 void *ptr, long fifth) {}
2146 #if !SANITIZER_ANDROID
2147 PRE_SYSCALL(shmctl)(long shmid, long cmd, void *buf) {}
2149 POST_SYSCALL(shmctl)(long res, long shmid, long cmd, void *buf) {
2151 if (buf) POST_WRITE(buf, sizeof(__sanitizer_shmid_ds));
2155 PRE_SYSCALL(mq_open)(const void *name, long oflag, long mode, void *attr) {
2157 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2160 POST_SYSCALL(mq_open)(long res, const void *name, long oflag, long mode,
2163 if (attr) POST_WRITE(attr, struct_mq_attr_sz);
2167 PRE_SYSCALL(mq_unlink)(const void *name) {
2169 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2172 POST_SYSCALL(mq_unlink)(long res, const void *name) {}
2174 PRE_SYSCALL(mq_timedsend)(long mqdes, const void *msg_ptr, long msg_len,
2175 long msg_prio, const void *abs_timeout) {
2176 if (msg_ptr) PRE_READ(msg_ptr, msg_len);
2177 if (abs_timeout) PRE_READ(abs_timeout, struct_timespec_sz);
2180 POST_SYSCALL(mq_timedsend)(long res, long mqdes, const void *msg_ptr,
2181 long msg_len, long msg_prio,
2182 const void *abs_timeout) {}
2184 PRE_SYSCALL(mq_timedreceive)(long mqdes, void *msg_ptr, long msg_len,
2185 void *msg_prio, const void *abs_timeout) {
2186 if (abs_timeout) PRE_READ(abs_timeout, struct_timespec_sz);
2189 POST_SYSCALL(mq_timedreceive)(long res, long mqdes, void *msg_ptr, long msg_len,
2190 int *msg_prio, const void *abs_timeout) {
2192 if (msg_ptr) POST_WRITE(msg_ptr, res);
2193 if (msg_prio) POST_WRITE(msg_prio, sizeof(*msg_prio));
2197 PRE_SYSCALL(mq_notify)(long mqdes, const void *notification) {
2198 if (notification) PRE_READ(notification, struct_sigevent_sz);
2201 POST_SYSCALL(mq_notify)(long res, long mqdes, const void *notification) {}
2203 PRE_SYSCALL(mq_getsetattr)(long mqdes, const void *mqstat, void *omqstat) {
2204 if (mqstat) PRE_READ(mqstat, struct_mq_attr_sz);
2207 POST_SYSCALL(mq_getsetattr)(long res, long mqdes, const void *mqstat,
2210 if (omqstat) POST_WRITE(omqstat, struct_mq_attr_sz);
2213 #endif // SANITIZER_ANDROID
2215 PRE_SYSCALL(pciconfig_iobase)(long which, long bus, long devfn) {}
2217 POST_SYSCALL(pciconfig_iobase)(long res, long which, long bus, long devfn) {}
2219 PRE_SYSCALL(pciconfig_read)(long bus, long dfn, long off, long len, void *buf) {
2222 POST_SYSCALL(pciconfig_read)(long res, long bus, long dfn, long off, long len,
2225 PRE_SYSCALL(pciconfig_write)(long bus, long dfn, long off, long len,
2228 POST_SYSCALL(pciconfig_write)(long res, long bus, long dfn, long off, long len,
2231 PRE_SYSCALL(swapon)(const void *specialfile, long swap_flags) {
2233 PRE_READ(specialfile,
2234 __sanitizer::internal_strlen((const char *)specialfile) + 1);
2237 POST_SYSCALL(swapon)(long res, const void *specialfile, long swap_flags) {}
2239 PRE_SYSCALL(swapoff)(const void *specialfile) {
2241 PRE_READ(specialfile,
2242 __sanitizer::internal_strlen((const char *)specialfile) + 1);
2245 POST_SYSCALL(swapoff)(long res, const void *specialfile) {}
2247 PRE_SYSCALL(sysctl)(__sanitizer___sysctl_args *args) {
2249 if (args->name) PRE_READ(args->name, args->nlen * sizeof(*args->name));
2250 if (args->newval) PRE_READ(args->name, args->newlen);
2254 POST_SYSCALL(sysctl)(long res, __sanitizer___sysctl_args *args) {
2256 if (args && args->oldval && args->oldlenp) {
2257 POST_WRITE(args->oldlenp, sizeof(*args->oldlenp));
2258 POST_WRITE(args->oldval, *args->oldlenp);
2263 PRE_SYSCALL(sysinfo)(void *info) {}
2265 POST_SYSCALL(sysinfo)(long res, void *info) {
2267 if (info) POST_WRITE(info, struct_sysinfo_sz);
2271 PRE_SYSCALL(sysfs)(long option, long arg1, long arg2) {}
2273 POST_SYSCALL(sysfs)(long res, long option, long arg1, long arg2) {}
2275 PRE_SYSCALL(syslog)(long type, void *buf, long len) {}
2277 POST_SYSCALL(syslog)(long res, long type, void *buf, long len) {
2280 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
2284 PRE_SYSCALL(uselib)(const void *library) {
2286 PRE_READ(library, __sanitizer::internal_strlen((const char *)library) + 1);
2289 POST_SYSCALL(uselib)(long res, const void *library) {}
2291 PRE_SYSCALL(ni_syscall)() {}
2293 POST_SYSCALL(ni_syscall)(long res) {}
2295 PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) {
2296 #if !SANITIZER_ANDROID && \
2297 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
2298 defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__))
2300 if (request == ptrace_setregs) {
2301 PRE_READ((void *)data, struct_user_regs_struct_sz);
2302 } else if (request == ptrace_setfpregs) {
2303 PRE_READ((void *)data, struct_user_fpregs_struct_sz);
2304 } else if (request == ptrace_setfpxregs) {
2305 PRE_READ((void *)data, struct_user_fpxregs_struct_sz);
2306 } else if (request == ptrace_setsiginfo) {
2307 PRE_READ((void *)data, siginfo_t_sz);
2308 } else if (request == ptrace_setregset) {
2309 __sanitizer_iovec *iov = (__sanitizer_iovec *)data;
2310 PRE_READ(iov->iov_base, iov->iov_len);
2316 POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) {
2317 #if !SANITIZER_ANDROID && \
2318 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
2319 defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__))
2320 if (res >= 0 && data) {
2321 // Note that this is different from the interceptor in
2322 // sanitizer_common_interceptors.inc.
2323 // PEEK* requests return resulting values through data pointer.
2324 if (request == ptrace_getregs) {
2325 POST_WRITE((void *)data, struct_user_regs_struct_sz);
2326 } else if (request == ptrace_getfpregs) {
2327 POST_WRITE((void *)data, struct_user_fpregs_struct_sz);
2328 } else if (request == ptrace_getfpxregs) {
2329 POST_WRITE((void *)data, struct_user_fpxregs_struct_sz);
2330 } else if (request == ptrace_getsiginfo) {
2331 POST_WRITE((void *)data, siginfo_t_sz);
2332 } else if (request == ptrace_getregset) {
2333 __sanitizer_iovec *iov = (__sanitizer_iovec *)data;
2334 POST_WRITE(iov->iov_base, iov->iov_len);
2335 } else if (request == ptrace_peekdata || request == ptrace_peektext ||
2336 request == ptrace_peekuser) {
2337 POST_WRITE((void *)data, sizeof(void *));
2343 PRE_SYSCALL(add_key)(const void *_type, const void *_description,
2344 const void *_payload, long plen, long destringid) {
2346 PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1);
2348 PRE_READ(_description,
2349 __sanitizer::internal_strlen((const char *)_description) + 1);
2352 POST_SYSCALL(add_key)(long res, const void *_type, const void *_description,
2353 const void *_payload, long plen, long destringid) {}
2355 PRE_SYSCALL(request_key)(const void *_type, const void *_description,
2356 const void *_callout_info, long destringid) {
2358 PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1);
2360 PRE_READ(_description,
2361 __sanitizer::internal_strlen((const char *)_description) + 1);
2363 PRE_READ(_callout_info,
2364 __sanitizer::internal_strlen((const char *)_callout_info) + 1);
2367 POST_SYSCALL(request_key)(long res, const void *_type, const void *_description,
2368 const void *_callout_info, long destringid) {}
2370 PRE_SYSCALL(keyctl)(long cmd, long arg2, long arg3, long arg4, long arg5) {}
2372 POST_SYSCALL(keyctl)(long res, long cmd, long arg2, long arg3, long arg4,
2375 PRE_SYSCALL(ioprio_set)(long which, long who, long ioprio) {}
2377 POST_SYSCALL(ioprio_set)(long res, long which, long who, long ioprio) {}
2379 PRE_SYSCALL(ioprio_get)(long which, long who) {}
2381 POST_SYSCALL(ioprio_get)(long res, long which, long who) {}
2383 PRE_SYSCALL(set_mempolicy)(long mode, void *nmask, long maxnode) {}
2385 POST_SYSCALL(set_mempolicy)(long res, long mode, void *nmask, long maxnode) {
2387 if (nmask) POST_WRITE(nmask, sizeof(long));
2391 PRE_SYSCALL(migrate_pages)(long pid, long maxnode, const void *from,
2393 if (from) PRE_READ(from, sizeof(long));
2394 if (to) PRE_READ(to, sizeof(long));
2397 POST_SYSCALL(migrate_pages)(long res, long pid, long maxnode, const void *from,
2400 PRE_SYSCALL(move_pages)(long pid, long nr_pages, const void **pages,
2401 const int *nodes, int *status, long flags) {
2402 if (pages) PRE_READ(pages, nr_pages * sizeof(*pages));
2403 if (nodes) PRE_READ(nodes, nr_pages * sizeof(*nodes));
2406 POST_SYSCALL(move_pages)(long res, long pid, long nr_pages, const void **pages,
2407 const int *nodes, int *status, long flags) {
2409 if (status) POST_WRITE(status, nr_pages * sizeof(*status));
2413 PRE_SYSCALL(mbind)(long start, long len, long mode, void *nmask, long maxnode,
2416 POST_SYSCALL(mbind)(long res, long start, long len, long mode, void *nmask,
2417 long maxnode, long flags) {
2419 if (nmask) POST_WRITE(nmask, sizeof(long));
2423 PRE_SYSCALL(get_mempolicy)(void *policy, void *nmask, long maxnode, long addr,
2426 POST_SYSCALL(get_mempolicy)(long res, void *policy, void *nmask, long maxnode,
2427 long addr, long flags) {
2429 if (policy) POST_WRITE(policy, sizeof(int));
2430 if (nmask) POST_WRITE(nmask, sizeof(long));
2434 PRE_SYSCALL(inotify_init)() {}
2436 POST_SYSCALL(inotify_init)(long res) {}
2438 PRE_SYSCALL(inotify_init1)(long flags) {}
2440 POST_SYSCALL(inotify_init1)(long res, long flags) {}
2442 PRE_SYSCALL(inotify_add_watch)(long fd, const void *path, long mask) {
2444 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
2447 POST_SYSCALL(inotify_add_watch)(long res, long fd, const void *path,
2450 PRE_SYSCALL(inotify_rm_watch)(long fd, long wd) {}
2452 POST_SYSCALL(inotify_rm_watch)(long res, long fd, long wd) {}
2454 PRE_SYSCALL(spu_run)(long fd, void *unpc, void *ustatus) {}
2456 POST_SYSCALL(spu_run)(long res, long fd, unsigned *unpc, unsigned *ustatus) {
2458 if (unpc) POST_WRITE(unpc, sizeof(*unpc));
2459 if (ustatus) POST_WRITE(ustatus, sizeof(*ustatus));
2463 PRE_SYSCALL(spu_create)(const void *name, long flags, long mode, long fd) {
2465 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2468 POST_SYSCALL(spu_create)(long res, const void *name, long flags, long mode,
2471 PRE_SYSCALL(mknodat)(long dfd, const void *filename, long mode, long dev) {
2474 __sanitizer::internal_strlen((const char *)filename) + 1);
2477 POST_SYSCALL(mknodat)(long res, long dfd, const void *filename, long mode,
2480 PRE_SYSCALL(mkdirat)(long dfd, const void *pathname, long mode) {
2483 __sanitizer::internal_strlen((const char *)pathname) + 1);
2486 POST_SYSCALL(mkdirat)(long res, long dfd, const void *pathname, long mode) {}
2488 PRE_SYSCALL(unlinkat)(long dfd, const void *pathname, long flag) {
2491 __sanitizer::internal_strlen((const char *)pathname) + 1);
2494 POST_SYSCALL(unlinkat)(long res, long dfd, const void *pathname, long flag) {}
2496 PRE_SYSCALL(symlinkat)(const void *oldname, long newdfd, const void *newname) {
2498 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2500 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2503 POST_SYSCALL(symlinkat)(long res, const void *oldname, long newdfd,
2504 const void *newname) {}
2506 PRE_SYSCALL(linkat)(long olddfd, const void *oldname, long newdfd,
2507 const void *newname, long flags) {
2509 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2511 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2514 POST_SYSCALL(linkat)(long res, long olddfd, const void *oldname, long newdfd,
2515 const void *newname, long flags) {}
2517 PRE_SYSCALL(renameat)(long olddfd, const void *oldname, long newdfd,
2518 const void *newname) {
2520 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2522 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2525 POST_SYSCALL(renameat)(long res, long olddfd, const void *oldname, long newdfd,
2526 const void *newname) {}
2528 PRE_SYSCALL(futimesat)(long dfd, const void *filename, void *utimes) {
2531 __sanitizer::internal_strlen((const char *)filename) + 1);
2534 POST_SYSCALL(futimesat)(long res, long dfd, const void *filename,
2537 if (utimes) POST_WRITE(utimes, timeval_sz);
2541 PRE_SYSCALL(faccessat)(long dfd, const void *filename, long mode) {
2544 __sanitizer::internal_strlen((const char *)filename) + 1);
2547 POST_SYSCALL(faccessat)(long res, long dfd, const void *filename, long mode) {}
2549 PRE_SYSCALL(fchmodat)(long dfd, const void *filename, long mode) {
2552 __sanitizer::internal_strlen((const char *)filename) + 1);
2555 POST_SYSCALL(fchmodat)(long res, long dfd, const void *filename, long mode) {}
2557 PRE_SYSCALL(fchownat)(long dfd, const void *filename, long user, long group,
2561 __sanitizer::internal_strlen((const char *)filename) + 1);
2564 POST_SYSCALL(fchownat)(long res, long dfd, const void *filename, long user,
2565 long group, long flag) {}
2567 PRE_SYSCALL(openat)(long dfd, const void *filename, long flags, long mode) {
2570 __sanitizer::internal_strlen((const char *)filename) + 1);
2573 POST_SYSCALL(openat)(long res, long dfd, const void *filename, long flags,
2576 PRE_SYSCALL(newfstatat)(long dfd, const void *filename, void *statbuf,
2580 __sanitizer::internal_strlen((const char *)filename) + 1);
2583 POST_SYSCALL(newfstatat)(long res, long dfd, const void *filename,
2584 void *statbuf, long flag) {
2586 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat_sz);
2590 PRE_SYSCALL(fstatat64)(long dfd, const void *filename, void *statbuf,
2594 __sanitizer::internal_strlen((const char *)filename) + 1);
2597 POST_SYSCALL(fstatat64)(long res, long dfd, const void *filename, void *statbuf,
2600 if (statbuf) POST_WRITE(statbuf, struct_kernel_stat64_sz);
2604 PRE_SYSCALL(readlinkat)(long dfd, const void *path, void *buf, long bufsiz) {
2606 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
2609 POST_SYSCALL(readlinkat)(long res, long dfd, const void *path, void *buf,
2613 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
2617 PRE_SYSCALL(utimensat)(long dfd, const void *filename, void *utimes,
2621 __sanitizer::internal_strlen((const char *)filename) + 1);
2624 POST_SYSCALL(utimensat)(long res, long dfd, const void *filename, void *utimes,
2627 if (utimes) POST_WRITE(utimes, struct_timespec_sz);
2631 PRE_SYSCALL(unshare)(long unshare_flags) {}
2633 POST_SYSCALL(unshare)(long res, long unshare_flags) {}
2635 PRE_SYSCALL(splice)(long fd_in, void *off_in, long fd_out, void *off_out,
2636 long len, long flags) {}
2638 POST_SYSCALL(splice)(long res, long fd_in, void *off_in, long fd_out,
2639 void *off_out, long len, long flags) {
2641 if (off_in) POST_WRITE(off_in, sizeof(long long));
2642 if (off_out) POST_WRITE(off_out, sizeof(long long));
2646 PRE_SYSCALL(vmsplice)(long fd, const __sanitizer_iovec *iov, long nr_segs,
2649 POST_SYSCALL(vmsplice)(long res, long fd, const __sanitizer_iovec *iov,
2650 long nr_segs, long flags) {
2652 if (iov) kernel_read_iovec(iov, nr_segs, res);
2656 PRE_SYSCALL(tee)(long fdin, long fdout, long len, long flags) {}
2658 POST_SYSCALL(tee)(long res, long fdin, long fdout, long len, long flags) {}
2660 PRE_SYSCALL(get_robust_list)(long pid, void *head_ptr, void *len_ptr) {}
2662 POST_SYSCALL(get_robust_list)(long res, long pid, void *head_ptr,
2665 PRE_SYSCALL(set_robust_list)(void *head, long len) {}
2667 POST_SYSCALL(set_robust_list)(long res, void *head, long len) {}
2669 PRE_SYSCALL(getcpu)(void *cpu, void *node, void *cache) {}
2671 POST_SYSCALL(getcpu)(long res, void *cpu, void *node, void *cache) {
2673 if (cpu) POST_WRITE(cpu, sizeof(unsigned));
2674 if (node) POST_WRITE(node, sizeof(unsigned));
2675 // The third argument to this system call is nowadays unused.
2679 PRE_SYSCALL(signalfd)(long ufd, void *user_mask, long sizemask) {}
2681 POST_SYSCALL(signalfd)(long res, long ufd, kernel_sigset_t *user_mask,
2684 if (user_mask) POST_WRITE(user_mask, sizemask);
2688 PRE_SYSCALL(signalfd4)(long ufd, void *user_mask, long sizemask, long flags) {}
2690 POST_SYSCALL(signalfd4)(long res, long ufd, kernel_sigset_t *user_mask,
2691 long sizemask, long flags) {
2693 if (user_mask) POST_WRITE(user_mask, sizemask);
2697 PRE_SYSCALL(timerfd_create)(long clockid, long flags) {}
2699 POST_SYSCALL(timerfd_create)(long res, long clockid, long flags) {}
2701 PRE_SYSCALL(timerfd_settime)(long ufd, long flags, const void *utmr,
2703 if (utmr) PRE_READ(utmr, struct_itimerspec_sz);
2706 POST_SYSCALL(timerfd_settime)(long res, long ufd, long flags, const void *utmr,
2709 if (otmr) POST_WRITE(otmr, struct_itimerspec_sz);
2713 PRE_SYSCALL(timerfd_gettime)(long ufd, void *otmr) {}
2715 POST_SYSCALL(timerfd_gettime)(long res, long ufd, void *otmr) {
2717 if (otmr) POST_WRITE(otmr, struct_itimerspec_sz);
2721 PRE_SYSCALL(eventfd)(long count) {}
2723 POST_SYSCALL(eventfd)(long res, long count) {}
2725 PRE_SYSCALL(eventfd2)(long count, long flags) {}
2727 POST_SYSCALL(eventfd2)(long res, long count, long flags) {}
2729 PRE_SYSCALL(old_readdir)(long arg0, void *arg1, long arg2) {}
2731 POST_SYSCALL(old_readdir)(long res, long arg0, void *arg1, long arg2) {
2732 // Missing definition of 'struct old_linux_dirent'.
2735 PRE_SYSCALL(pselect6)(long arg0, __sanitizer___kernel_fd_set *arg1,
2736 __sanitizer___kernel_fd_set *arg2,
2737 __sanitizer___kernel_fd_set *arg3, void *arg4,
2740 POST_SYSCALL(pselect6)(long res, long arg0, __sanitizer___kernel_fd_set *arg1,
2741 __sanitizer___kernel_fd_set *arg2,
2742 __sanitizer___kernel_fd_set *arg3, void *arg4,
2745 if (arg1) POST_WRITE(arg1, sizeof(*arg1));
2746 if (arg2) POST_WRITE(arg2, sizeof(*arg2));
2747 if (arg3) POST_WRITE(arg3, sizeof(*arg3));
2748 if (arg4) POST_WRITE(arg4, struct_timespec_sz);
2752 PRE_SYSCALL(ppoll)(__sanitizer_pollfd *arg0, long arg1, void *arg2,
2753 const kernel_sigset_t *arg3, long arg4) {
2754 if (arg3) PRE_READ(arg3, arg4);
2757 POST_SYSCALL(ppoll)(long res, __sanitizer_pollfd *arg0, long arg1, void *arg2,
2758 const void *arg3, long arg4) {
2760 if (arg0) POST_WRITE(arg0, sizeof(*arg0));
2761 if (arg2) POST_WRITE(arg2, struct_timespec_sz);
2765 PRE_SYSCALL(syncfs)(long fd) {}
2767 POST_SYSCALL(syncfs)(long res, long fd) {}
2769 PRE_SYSCALL(perf_event_open)(__sanitizer_perf_event_attr *attr_uptr, long pid,
2770 long cpu, long group_fd, long flags) {
2771 if (attr_uptr) PRE_READ(attr_uptr, attr_uptr->size);
2774 POST_SYSCALL(perf_event_open)(long res, __sanitizer_perf_event_attr *attr_uptr,
2775 long pid, long cpu, long group_fd, long flags) {}
2777 PRE_SYSCALL(mmap_pgoff)(long addr, long len, long prot, long flags, long fd,
2780 POST_SYSCALL(mmap_pgoff)(long res, long addr, long len, long prot, long flags,
2781 long fd, long pgoff) {}
2783 PRE_SYSCALL(old_mmap)(void *arg) {}
2785 POST_SYSCALL(old_mmap)(long res, void *arg) {}
2787 PRE_SYSCALL(name_to_handle_at)(long dfd, const void *name, void *handle,
2788 void *mnt_id, long flag) {}
2790 POST_SYSCALL(name_to_handle_at)(long res, long dfd, const void *name,
2791 void *handle, void *mnt_id, long flag) {}
2793 PRE_SYSCALL(open_by_handle_at)(long mountdirfd, void *handle, long flags) {}
2795 POST_SYSCALL(open_by_handle_at)(long res, long mountdirfd, void *handle,
2798 PRE_SYSCALL(setns)(long fd, long nstype) {}
2800 POST_SYSCALL(setns)(long res, long fd, long nstype) {}
2802 PRE_SYSCALL(process_vm_readv)(long pid, const __sanitizer_iovec *lvec,
2803 long liovcnt, const void *rvec, long riovcnt,
2806 POST_SYSCALL(process_vm_readv)(long res, long pid,
2807 const __sanitizer_iovec *lvec, long liovcnt,
2808 const void *rvec, long riovcnt, long flags) {
2810 if (lvec) kernel_write_iovec(lvec, liovcnt, res);
2814 PRE_SYSCALL(process_vm_writev)(long pid, const __sanitizer_iovec *lvec,
2815 long liovcnt, const void *rvec, long riovcnt,
2818 POST_SYSCALL(process_vm_writev)(long res, long pid,
2819 const __sanitizer_iovec *lvec, long liovcnt,
2820 const void *rvec, long riovcnt, long flags) {
2822 if (lvec) kernel_read_iovec(lvec, liovcnt, res);
2826 PRE_SYSCALL(fork)() {
2827 COMMON_SYSCALL_PRE_FORK();
2830 POST_SYSCALL(fork)(long res) {
2831 COMMON_SYSCALL_POST_FORK(res);
2834 PRE_SYSCALL(vfork)() {
2835 COMMON_SYSCALL_PRE_FORK();
2838 POST_SYSCALL(vfork)(long res) {
2839 COMMON_SYSCALL_POST_FORK(res);
2842 PRE_SYSCALL(sigaction)(long signum, const __sanitizer_kernel_sigaction_t *act,
2843 __sanitizer_kernel_sigaction_t *oldact) {
2845 PRE_READ(&act->sigaction, sizeof(act->sigaction));
2846 PRE_READ(&act->sa_flags, sizeof(act->sa_flags));
2847 PRE_READ(&act->sa_mask, sizeof(act->sa_mask));
2851 POST_SYSCALL(sigaction)(long res, long signum,
2852 const __sanitizer_kernel_sigaction_t *act,
2853 __sanitizer_kernel_sigaction_t *oldact) {
2854 if (res >= 0 && oldact) POST_WRITE(oldact, sizeof(*oldact));
2857 PRE_SYSCALL(rt_sigaction)(long signum,
2858 const __sanitizer_kernel_sigaction_t *act,
2859 __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) {
2861 PRE_READ(&act->sigaction, sizeof(act->sigaction));
2862 PRE_READ(&act->sa_flags, sizeof(act->sa_flags));
2863 PRE_READ(&act->sa_mask, sz);
2867 POST_SYSCALL(rt_sigaction)(long res, long signum,
2868 const __sanitizer_kernel_sigaction_t *act,
2869 __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) {
2870 if (res >= 0 && oldact) {
2871 SIZE_T oldact_sz = ((char *)&oldact->sa_mask) - ((char *)oldact) + sz;
2872 POST_WRITE(oldact, oldact_sz);
2884 #endif // SANITIZER_LINUX