1 //===-- sanitizer_common_syscalls.inc ---------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Common syscalls handlers for tools like AddressSanitizer,
10 // ThreadSanitizer, MemorySanitizer, etc.
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.
27 // COMMON_SYSCALL_ACQUIRE(addr)
28 // Acquire memory visibility from addr.
29 // COMMON_SYSCALL_RELEASE(addr)
30 // Release memory visibility to addr.
31 // COMMON_SYSCALL_FD_CLOSE(fd)
32 // Called before closing file descriptor fd.
33 // COMMON_SYSCALL_FD_ACQUIRE(fd)
34 // Acquire memory visibility from fd.
35 // COMMON_SYSCALL_FD_RELEASE(fd)
36 // Release memory visibility to fd.
37 // COMMON_SYSCALL_PRE_FORK()
38 // Called before fork syscall.
39 // COMMON_SYSCALL_POST_FORK(long res)
40 // Called after fork syscall.
41 //===----------------------------------------------------------------------===//
43 #include "sanitizer_platform.h"
46 # include "sanitizer_libc.h"
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)
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)
58 # ifndef COMMON_SYSCALL_ACQUIRE
59 # define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr))
62 # ifndef COMMON_SYSCALL_RELEASE
63 # define COMMON_SYSCALL_RELEASE(addr) ((void)(addr))
66 # ifndef COMMON_SYSCALL_FD_CLOSE
67 # define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd))
70 # ifndef COMMON_SYSCALL_FD_ACQUIRE
71 # define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd))
74 # ifndef COMMON_SYSCALL_FD_RELEASE
75 # define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd))
78 # ifndef COMMON_SYSCALL_PRE_FORK
79 # define COMMON_SYSCALL_PRE_FORK() \
83 # ifndef COMMON_SYSCALL_POST_FORK
84 # define COMMON_SYSCALL_POST_FORK(res) \
88 // FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such).
91 struct sanitizer_kernel_iovec {
93 unsigned long iov_len;
96 struct sanitizer_kernel_msghdr {
99 struct sanitizer_kernel_iovec *msg_iov;
100 unsigned long msg_iovlen;
102 unsigned long msg_controllen;
106 struct sanitizer_kernel_mmsghdr {
107 struct sanitizer_kernel_msghdr msg_hdr;
111 struct sanitizer_kernel_timespec {
116 struct sanitizer_kernel_timeval {
121 struct sanitizer_kernel_rusage {
122 struct sanitizer_kernel_timeval ru_timeval[2];
126 struct sanitizer_kernel_sockaddr {
127 unsigned short sa_family;
131 // Real sigset size is always passed as a syscall argument.
132 // Declare it "void" to catch sizeof(kernel_sigset_t).
133 typedef void kernel_sigset_t;
135 static void kernel_write_iovec(const __sanitizer_iovec *iovec, SIZE_T iovlen,
137 for (SIZE_T i = 0; i < iovlen && maxlen; ++i) {
138 SSIZE_T sz = Min(iovec[i].iov_len, maxlen);
139 POST_WRITE(iovec[i].iov_base, sz);
144 // This functions uses POST_READ, because it needs to run after syscall to know
145 // the real read range.
146 static void kernel_read_iovec(const __sanitizer_iovec *iovec, SIZE_T iovlen,
148 POST_READ(iovec, sizeof(*iovec) * iovlen);
149 for (SIZE_T i = 0; i < iovlen && maxlen; ++i) {
150 SSIZE_T sz = Min(iovec[i].iov_len, maxlen);
151 POST_READ(iovec[i].iov_base, sz);
156 PRE_SYSCALL(recvmsg)(long sockfd, sanitizer_kernel_msghdr *msg, long flags) {
157 PRE_READ(msg, sizeof(*msg));
160 POST_SYSCALL(recvmsg)
161 (long res, long sockfd, sanitizer_kernel_msghdr *msg, long flags) {
164 for (unsigned long i = 0; i < msg->msg_iovlen; ++i) {
165 POST_WRITE(msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
167 POST_WRITE(msg->msg_control, msg->msg_controllen);
172 PRE_SYSCALL(recvmmsg)
173 (long fd, sanitizer_kernel_mmsghdr *msg, long vlen, long flags, void *timeout) {
174 PRE_READ(msg, vlen * sizeof(*msg));
177 POST_SYSCALL(recvmmsg)
178 (long res, long fd, sanitizer_kernel_mmsghdr *msg, long vlen, long flags,
182 for (unsigned long i = 0; i < msg->msg_hdr.msg_iovlen; ++i) {
183 POST_WRITE(msg->msg_hdr.msg_iov[i].iov_base,
184 msg->msg_hdr.msg_iov[i].iov_len);
186 POST_WRITE(msg->msg_hdr.msg_control, msg->msg_hdr.msg_controllen);
187 POST_WRITE(&msg->msg_len, sizeof(msg->msg_len));
190 POST_WRITE(timeout, struct_timespec_sz);
194 PRE_SYSCALL(read)(long fd, void *buf, uptr count) {
196 PRE_WRITE(buf, count);
200 POST_SYSCALL(read)(long res, long fd, void *buf, uptr count) {
201 if (res > 0 && buf) {
202 POST_WRITE(buf, res);
206 PRE_SYSCALL(time)(void *tloc) {}
208 POST_SYSCALL(time)(long res, void *tloc) {
211 POST_WRITE(tloc, sizeof(long));
215 PRE_SYSCALL(stime)(void *tptr) {}
217 POST_SYSCALL(stime)(long res, void *tptr) {
220 POST_WRITE(tptr, sizeof(long));
224 PRE_SYSCALL(gettimeofday)(void *tv, void *tz) {}
226 POST_SYSCALL(gettimeofday)(long res, void *tv, void *tz) {
229 POST_WRITE(tv, timeval_sz);
231 POST_WRITE(tz, struct_timezone_sz);
235 PRE_SYSCALL(settimeofday)(void *tv, void *tz) {}
237 POST_SYSCALL(settimeofday)(long res, void *tv, void *tz) {
240 POST_WRITE(tv, timeval_sz);
242 POST_WRITE(tz, struct_timezone_sz);
246 # if !SANITIZER_ANDROID
247 PRE_SYSCALL(adjtimex)(void *txc_p) {}
249 POST_SYSCALL(adjtimex)(long res, void *txc_p) {
252 POST_WRITE(txc_p, struct_timex_sz);
257 PRE_SYSCALL(times)(void *tbuf) {}
259 POST_SYSCALL(times)(long res, void *tbuf) {
262 POST_WRITE(tbuf, struct_tms_sz);
266 PRE_SYSCALL(gettid)() {}
268 POST_SYSCALL(gettid)(long res) {}
270 PRE_SYSCALL(nanosleep)(void *rqtp, void *rmtp) {}
272 POST_SYSCALL(nanosleep)(long res, void *rqtp, void *rmtp) {
275 POST_WRITE(rqtp, struct_timespec_sz);
277 POST_WRITE(rmtp, struct_timespec_sz);
281 PRE_SYSCALL(alarm)(long seconds) {}
283 POST_SYSCALL(alarm)(long res, long seconds) {}
285 PRE_SYSCALL(getpid)() {}
287 POST_SYSCALL(getpid)(long res) {}
289 PRE_SYSCALL(getppid)() {}
291 POST_SYSCALL(getppid)(long res) {}
293 PRE_SYSCALL(getuid)() {}
295 POST_SYSCALL(getuid)(long res) {}
297 PRE_SYSCALL(geteuid)() {}
299 POST_SYSCALL(geteuid)(long res) {}
301 PRE_SYSCALL(getgid)() {}
303 POST_SYSCALL(getgid)(long res) {}
305 PRE_SYSCALL(getegid)() {}
307 POST_SYSCALL(getegid)(long res) {}
309 PRE_SYSCALL(getresuid)(void *ruid, void *euid, void *suid) {}
311 POST_SYSCALL(getresuid)(long res, void *ruid, void *euid, void *suid) {
314 POST_WRITE(ruid, sizeof(unsigned));
316 POST_WRITE(euid, sizeof(unsigned));
318 POST_WRITE(suid, sizeof(unsigned));
322 PRE_SYSCALL(getresgid)(void *rgid, void *egid, void *sgid) {}
324 POST_SYSCALL(getresgid)(long res, void *rgid, void *egid, void *sgid) {
327 POST_WRITE(rgid, sizeof(unsigned));
329 POST_WRITE(egid, sizeof(unsigned));
331 POST_WRITE(sgid, sizeof(unsigned));
335 PRE_SYSCALL(getpgid)(long pid) {}
337 POST_SYSCALL(getpgid)(long res, long pid) {}
339 PRE_SYSCALL(getpgrp)() {}
341 POST_SYSCALL(getpgrp)(long res) {}
343 PRE_SYSCALL(getsid)(long pid) {}
345 POST_SYSCALL(getsid)(long res, long pid) {}
347 PRE_SYSCALL(getgroups)(long gidsetsize, void *grouplist) {}
349 POST_SYSCALL(getgroups)
350 (long res, long gidsetsize, __sanitizer___kernel_gid_t *grouplist) {
353 POST_WRITE(grouplist, res * sizeof(*grouplist));
357 PRE_SYSCALL(setregid)(long rgid, long egid) {}
359 POST_SYSCALL(setregid)(long res, long rgid, long egid) {}
361 PRE_SYSCALL(setgid)(long gid) {}
363 POST_SYSCALL(setgid)(long res, long gid) {}
365 PRE_SYSCALL(setreuid)(long ruid, long euid) {}
367 POST_SYSCALL(setreuid)(long res, long ruid, long euid) {}
369 PRE_SYSCALL(setuid)(long uid) {}
371 POST_SYSCALL(setuid)(long res, long uid) {}
373 PRE_SYSCALL(setresuid)(long ruid, long euid, long suid) {}
375 POST_SYSCALL(setresuid)(long res, long ruid, long euid, long suid) {}
377 PRE_SYSCALL(setresgid)(long rgid, long egid, long sgid) {}
379 POST_SYSCALL(setresgid)(long res, long rgid, long egid, long sgid) {}
381 PRE_SYSCALL(setfsuid)(long uid) {}
383 POST_SYSCALL(setfsuid)(long res, long uid) {}
385 PRE_SYSCALL(setfsgid)(long gid) {}
387 POST_SYSCALL(setfsgid)(long res, long gid) {}
389 PRE_SYSCALL(setpgid)(long pid, long pgid) {}
391 POST_SYSCALL(setpgid)(long res, long pid, long pgid) {}
393 PRE_SYSCALL(setsid)() {}
395 POST_SYSCALL(setsid)(long res) {}
397 PRE_SYSCALL(setgroups)(long gidsetsize, __sanitizer___kernel_gid_t *grouplist) {
399 POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
402 POST_SYSCALL(setgroups)
403 (long res, long gidsetsize, __sanitizer___kernel_gid_t *grouplist) {}
405 PRE_SYSCALL(acct)(const void *name) {
407 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
410 POST_SYSCALL(acct)(long res, const void *name) {}
412 PRE_SYSCALL(capget)(void *header, void *dataptr) {
414 PRE_READ(header, __user_cap_header_struct_sz);
417 POST_SYSCALL(capget)(long res, void *header, void *dataptr) {
420 POST_WRITE(dataptr, __user_cap_data_struct_sz(header));
423 PRE_SYSCALL(capset)(void *header, const void *data) {
425 PRE_READ(header, __user_cap_header_struct_sz);
427 PRE_READ(data, __user_cap_data_struct_sz(header));
430 POST_SYSCALL(capset)(long res, void *header, const void *data) {}
432 PRE_SYSCALL(personality)(long personality) {}
434 POST_SYSCALL(personality)(long res, long personality) {}
436 PRE_SYSCALL(sigpending)(void *set) {}
438 POST_SYSCALL(sigpending)(long res, void *set) {
441 POST_WRITE(set, old_sigset_t_sz);
445 PRE_SYSCALL(sigprocmask)(long how, void *set, void *oset) {}
447 POST_SYSCALL(sigprocmask)(long res, long how, void *set, void *oset) {
450 POST_WRITE(set, old_sigset_t_sz);
452 POST_WRITE(oset, old_sigset_t_sz);
456 PRE_SYSCALL(getitimer)(long which, void *value) {}
458 POST_SYSCALL(getitimer)(long res, long which, void *value) {
461 POST_WRITE(value, struct_itimerval_sz);
465 PRE_SYSCALL(setitimer)(long which, void *value, void *ovalue) {}
467 POST_SYSCALL(setitimer)(long res, long which, void *value, void *ovalue) {
470 POST_WRITE(value, struct_itimerval_sz);
472 POST_WRITE(ovalue, struct_itimerval_sz);
476 PRE_SYSCALL(timer_create)
477 (long which_clock, void *timer_event_spec, void *created_timer_id) {}
479 POST_SYSCALL(timer_create)
480 (long res, long which_clock, void *timer_event_spec, void *created_timer_id) {
482 if (timer_event_spec)
483 POST_WRITE(timer_event_spec, struct_sigevent_sz);
484 if (created_timer_id)
485 POST_WRITE(created_timer_id, sizeof(long));
489 PRE_SYSCALL(timer_gettime)(long timer_id, void *setting) {}
491 POST_SYSCALL(timer_gettime)(long res, long timer_id, void *setting) {
494 POST_WRITE(setting, struct_itimerspec_sz);
498 PRE_SYSCALL(timer_getoverrun)(long timer_id) {}
500 POST_SYSCALL(timer_getoverrun)(long res, long timer_id) {}
502 PRE_SYSCALL(timer_settime)
503 (long timer_id, long flags, const void *new_setting, void *old_setting) {
505 PRE_READ(new_setting, struct_itimerspec_sz);
508 POST_SYSCALL(timer_settime)
509 (long res, long timer_id, long flags, const void *new_setting,
513 POST_WRITE(old_setting, struct_itimerspec_sz);
517 PRE_SYSCALL(timer_delete)(long timer_id) {}
519 POST_SYSCALL(timer_delete)(long res, long timer_id) {}
521 PRE_SYSCALL(clock_settime)(long which_clock, const void *tp) {
523 PRE_READ(tp, struct_timespec_sz);
526 POST_SYSCALL(clock_settime)(long res, long which_clock, const void *tp) {}
528 PRE_SYSCALL(clock_gettime)(long which_clock, void *tp) {}
530 POST_SYSCALL(clock_gettime)(long res, long which_clock, void *tp) {
533 POST_WRITE(tp, struct_timespec_sz);
537 # if !SANITIZER_ANDROID
538 PRE_SYSCALL(clock_adjtime)(long which_clock, void *tx) {}
540 POST_SYSCALL(clock_adjtime)(long res, long which_clock, void *tx) {
543 POST_WRITE(tx, struct_timex_sz);
548 PRE_SYSCALL(clock_getres)(long which_clock, void *tp) {}
550 POST_SYSCALL(clock_getres)(long res, long which_clock, void *tp) {
553 POST_WRITE(tp, struct_timespec_sz);
557 PRE_SYSCALL(clock_nanosleep)
558 (long which_clock, long flags, const void *rqtp, void *rmtp) {
560 PRE_READ(rqtp, struct_timespec_sz);
563 POST_SYSCALL(clock_nanosleep)
564 (long res, long which_clock, long flags, const void *rqtp, void *rmtp) {
567 POST_WRITE(rmtp, struct_timespec_sz);
571 PRE_SYSCALL(nice)(long increment) {}
573 POST_SYSCALL(nice)(long res, long increment) {}
575 PRE_SYSCALL(sched_setscheduler)(long pid, long policy, void *param) {}
577 POST_SYSCALL(sched_setscheduler)(long res, long pid, long policy, void *param) {
580 POST_WRITE(param, struct_sched_param_sz);
584 PRE_SYSCALL(sched_setparam)(long pid, void *param) {
586 PRE_READ(param, struct_sched_param_sz);
589 POST_SYSCALL(sched_setparam)(long res, long pid, void *param) {}
591 PRE_SYSCALL(sched_getscheduler)(long pid) {}
593 POST_SYSCALL(sched_getscheduler)(long res, long pid) {}
595 PRE_SYSCALL(sched_getparam)(long pid, void *param) {}
597 POST_SYSCALL(sched_getparam)(long res, long pid, void *param) {
600 POST_WRITE(param, struct_sched_param_sz);
604 PRE_SYSCALL(sched_setaffinity)(long pid, long len, void *user_mask_ptr) {
606 PRE_READ(user_mask_ptr, len);
609 POST_SYSCALL(sched_setaffinity)
610 (long res, long pid, long len, void *user_mask_ptr) {}
612 PRE_SYSCALL(sched_getaffinity)(long pid, long len, void *user_mask_ptr) {}
614 POST_SYSCALL(sched_getaffinity)
615 (long res, long pid, long len, void *user_mask_ptr) {
618 POST_WRITE(user_mask_ptr, len);
622 PRE_SYSCALL(sched_yield)() {}
624 POST_SYSCALL(sched_yield)(long res) {}
626 PRE_SYSCALL(sched_get_priority_max)(long policy) {}
628 POST_SYSCALL(sched_get_priority_max)(long res, long policy) {}
630 PRE_SYSCALL(sched_get_priority_min)(long policy) {}
632 POST_SYSCALL(sched_get_priority_min)(long res, long policy) {}
634 PRE_SYSCALL(sched_rr_get_interval)(long pid, void *interval) {}
636 POST_SYSCALL(sched_rr_get_interval)(long res, long pid, void *interval) {
639 POST_WRITE(interval, struct_timespec_sz);
643 PRE_SYSCALL(setpriority)(long which, long who, long niceval) {}
645 POST_SYSCALL(setpriority)(long res, long which, long who, long niceval) {}
647 PRE_SYSCALL(getpriority)(long which, long who) {}
649 POST_SYSCALL(getpriority)(long res, long which, long who) {}
651 PRE_SYSCALL(shutdown)(long arg0, long arg1) {}
653 POST_SYSCALL(shutdown)(long res, long arg0, long arg1) {}
655 PRE_SYSCALL(reboot)(long magic1, long magic2, long cmd, void *arg) {}
657 POST_SYSCALL(reboot)(long res, long magic1, long magic2, long cmd, void *arg) {}
659 PRE_SYSCALL(restart_syscall)() {}
661 POST_SYSCALL(restart_syscall)(long res) {}
663 PRE_SYSCALL(kexec_load)
664 (long entry, long nr_segments, void *segments, long flags) {}
666 POST_SYSCALL(kexec_load)
667 (long res, long entry, long nr_segments, void *segments, long flags) {
670 POST_WRITE(segments, struct_kexec_segment_sz);
674 PRE_SYSCALL(exit)(long error_code) {}
676 POST_SYSCALL(exit)(long res, long error_code) {}
678 PRE_SYSCALL(exit_group)(long error_code) {}
680 POST_SYSCALL(exit_group)(long res, long error_code) {}
682 PRE_SYSCALL(wait4)(long pid, void *stat_addr, long options, void *ru) {}
685 (long res, long pid, void *stat_addr, long options, void *ru) {
688 POST_WRITE(stat_addr, sizeof(int));
690 POST_WRITE(ru, struct_rusage_sz);
695 (long which, long pid, void *infop, long options, void *ru) {}
698 (long res, long which, long pid, void *infop, long options, void *ru) {
701 POST_WRITE(infop, siginfo_t_sz);
703 POST_WRITE(ru, struct_rusage_sz);
707 PRE_SYSCALL(waitpid)(long pid, void *stat_addr, long options) {}
709 POST_SYSCALL(waitpid)(long res, long pid, void *stat_addr, long options) {
712 POST_WRITE(stat_addr, sizeof(int));
716 PRE_SYSCALL(set_tid_address)(void *tidptr) {}
718 POST_SYSCALL(set_tid_address)(long res, void *tidptr) {
721 POST_WRITE(tidptr, sizeof(int));
725 PRE_SYSCALL(init_module)(void *umod, long len, const void *uargs) {
727 PRE_READ(uargs, __sanitizer::internal_strlen((const char *)uargs) + 1);
730 POST_SYSCALL(init_module)(long res, void *umod, long len, const void *uargs) {}
732 PRE_SYSCALL(delete_module)(const void *name_user, long flags) {
735 __sanitizer::internal_strlen((const char *)name_user) + 1);
738 POST_SYSCALL(delete_module)(long res, const void *name_user, long flags) {}
740 PRE_SYSCALL(rt_sigprocmask)(long how, void *set, void *oset, long sigsetsize) {}
742 POST_SYSCALL(rt_sigprocmask)
743 (long res, long how, kernel_sigset_t *set, kernel_sigset_t *oset,
747 POST_WRITE(set, sigsetsize);
749 POST_WRITE(oset, sigsetsize);
753 PRE_SYSCALL(rt_sigpending)(void *set, long sigsetsize) {}
755 POST_SYSCALL(rt_sigpending)(long res, kernel_sigset_t *set, long sigsetsize) {
758 POST_WRITE(set, sigsetsize);
762 PRE_SYSCALL(rt_sigtimedwait)
763 (const kernel_sigset_t *uthese, void *uinfo, const void *uts, long sigsetsize) {
765 PRE_READ(uthese, sigsetsize);
767 PRE_READ(uts, struct_timespec_sz);
770 POST_SYSCALL(rt_sigtimedwait)
771 (long res, const void *uthese, void *uinfo, const void *uts, long sigsetsize) {
774 POST_WRITE(uinfo, siginfo_t_sz);
778 PRE_SYSCALL(rt_tgsigqueueinfo)(long tgid, long pid, long sig, void *uinfo) {}
780 POST_SYSCALL(rt_tgsigqueueinfo)
781 (long res, long tgid, long pid, long sig, void *uinfo) {
784 POST_WRITE(uinfo, siginfo_t_sz);
788 PRE_SYSCALL(kill)(long pid, long sig) {}
790 POST_SYSCALL(kill)(long res, long pid, long sig) {}
792 PRE_SYSCALL(tgkill)(long tgid, long pid, long sig) {}
794 POST_SYSCALL(tgkill)(long res, long tgid, long pid, long sig) {}
796 PRE_SYSCALL(tkill)(long pid, long sig) {}
798 POST_SYSCALL(tkill)(long res, long pid, long sig) {}
800 PRE_SYSCALL(rt_sigqueueinfo)(long pid, long sig, void *uinfo) {}
802 POST_SYSCALL(rt_sigqueueinfo)(long res, long pid, long sig, void *uinfo) {
805 POST_WRITE(uinfo, siginfo_t_sz);
809 PRE_SYSCALL(sgetmask)() {}
811 POST_SYSCALL(sgetmask)(long res) {}
813 PRE_SYSCALL(ssetmask)(long newmask) {}
815 POST_SYSCALL(ssetmask)(long res, long newmask) {}
817 PRE_SYSCALL(signal)(long sig, long handler) {}
819 POST_SYSCALL(signal)(long res, long sig, long handler) {}
821 PRE_SYSCALL(pause)() {}
823 POST_SYSCALL(pause)(long res) {}
825 PRE_SYSCALL(sync)() {}
827 POST_SYSCALL(sync)(long res) {}
829 PRE_SYSCALL(fsync)(long fd) {}
831 POST_SYSCALL(fsync)(long res, long fd) {}
833 PRE_SYSCALL(fdatasync)(long fd) {}
835 POST_SYSCALL(fdatasync)(long res, long fd) {}
837 PRE_SYSCALL(bdflush)(long func, long data) {}
839 POST_SYSCALL(bdflush)(long res, long func, long data) {}
842 (void *dev_name, void *dir_name, void *type, long flags, void *data) {}
845 (long res, void *dev_name, void *dir_name, void *type, long flags, void *data) {
849 __sanitizer::internal_strlen((const char *)dev_name) + 1);
852 __sanitizer::internal_strlen((const char *)dir_name) + 1);
854 POST_WRITE(type, __sanitizer::internal_strlen((const char *)type) + 1);
858 PRE_SYSCALL(umount)(void *name, long flags) {}
860 POST_SYSCALL(umount)(long res, void *name, long flags) {
863 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
867 PRE_SYSCALL(oldumount)(void *name) {}
869 POST_SYSCALL(oldumount)(long res, void *name) {
872 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
876 PRE_SYSCALL(truncate)(const void *path, long length) {
878 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
881 POST_SYSCALL(truncate)(long res, const void *path, long length) {}
883 PRE_SYSCALL(ftruncate)(long fd, long length) {}
885 POST_SYSCALL(ftruncate)(long res, long fd, long length) {}
887 PRE_SYSCALL(stat)(const void *filename, void *statbuf) {
890 __sanitizer::internal_strlen((const char *)filename) + 1);
893 POST_SYSCALL(stat)(long res, const void *filename, void *statbuf) {
896 POST_WRITE(statbuf, struct___old_kernel_stat_sz);
900 # if !SANITIZER_ANDROID
901 PRE_SYSCALL(statfs)(const void *path, void *buf) {
903 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
906 POST_SYSCALL(statfs)(long res, const void *path, void *buf) {
909 POST_WRITE(buf, struct_statfs_sz);
913 PRE_SYSCALL(fstatfs)(long fd, void *buf) {}
915 POST_SYSCALL(fstatfs)(long res, long fd, void *buf) {
918 POST_WRITE(buf, struct_statfs_sz);
921 # endif // !SANITIZER_ANDROID
924 PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) {
926 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
929 POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) {
932 POST_WRITE(buf, struct_statfs64_sz);
936 PRE_SYSCALL(fstatfs64)(long fd, long sz, void *buf) {}
938 POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) {
941 POST_WRITE(buf, struct_statfs64_sz);
944 # endif // SANITIZER_GLIBC
946 PRE_SYSCALL(lstat)(const void *filename, void *statbuf) {
949 __sanitizer::internal_strlen((const char *)filename) + 1);
952 POST_SYSCALL(lstat)(long res, const void *filename, void *statbuf) {
955 POST_WRITE(statbuf, struct___old_kernel_stat_sz);
959 PRE_SYSCALL(fstat)(long fd, void *statbuf) {}
961 POST_SYSCALL(fstat)(long res, long fd, void *statbuf) {
964 POST_WRITE(statbuf, struct___old_kernel_stat_sz);
968 PRE_SYSCALL(newstat)(const void *filename, void *statbuf) {
971 __sanitizer::internal_strlen((const char *)filename) + 1);
974 POST_SYSCALL(newstat)(long res, const void *filename, void *statbuf) {
977 POST_WRITE(statbuf, struct_kernel_stat_sz);
981 PRE_SYSCALL(newlstat)(const void *filename, void *statbuf) {
984 __sanitizer::internal_strlen((const char *)filename) + 1);
987 POST_SYSCALL(newlstat)(long res, const void *filename, void *statbuf) {
990 POST_WRITE(statbuf, struct_kernel_stat_sz);
994 PRE_SYSCALL(newfstat)(long fd, void *statbuf) {}
996 POST_SYSCALL(newfstat)(long res, long fd, void *statbuf) {
999 POST_WRITE(statbuf, struct_kernel_stat_sz);
1003 # if SANITIZER_GLIBC
1004 PRE_SYSCALL(ustat)(long dev, void *ubuf) {}
1006 POST_SYSCALL(ustat)(long res, long dev, void *ubuf) {
1009 POST_WRITE(ubuf, struct_ustat_sz);
1012 # endif // SANITIZER_GLIBC
1014 PRE_SYSCALL(stat64)(const void *filename, void *statbuf) {
1017 __sanitizer::internal_strlen((const char *)filename) + 1);
1020 POST_SYSCALL(stat64)(long res, const void *filename, void *statbuf) {
1023 POST_WRITE(statbuf, struct_kernel_stat64_sz);
1027 PRE_SYSCALL(fstat64)(long fd, void *statbuf) {}
1029 POST_SYSCALL(fstat64)(long res, long fd, void *statbuf) {
1032 POST_WRITE(statbuf, struct_kernel_stat64_sz);
1036 PRE_SYSCALL(lstat64)(const void *filename, void *statbuf) {
1039 __sanitizer::internal_strlen((const char *)filename) + 1);
1042 POST_SYSCALL(lstat64)(long res, const void *filename, void *statbuf) {
1045 POST_WRITE(statbuf, struct_kernel_stat64_sz);
1049 PRE_SYSCALL(setxattr)
1050 (const void *path, const void *name, const void *value, long size, long flags) {
1052 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1054 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1056 PRE_READ(value, size);
1059 POST_SYSCALL(setxattr)
1060 (long res, const void *path, const void *name, const void *value, long size,
1063 PRE_SYSCALL(lsetxattr)
1064 (const void *path, const void *name, const void *value, long size, long flags) {
1066 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1068 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1070 PRE_READ(value, size);
1073 POST_SYSCALL(lsetxattr)
1074 (long res, const void *path, const void *name, const void *value, long size,
1077 PRE_SYSCALL(fsetxattr)
1078 (long fd, const void *name, const void *value, long size, long flags) {
1080 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1082 PRE_READ(value, size);
1085 POST_SYSCALL(fsetxattr)
1086 (long res, long fd, const void *name, const void *value, long size,
1089 PRE_SYSCALL(getxattr)
1090 (const void *path, const void *name, void *value, long size) {
1092 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1094 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1097 POST_SYSCALL(getxattr)
1098 (long res, const void *path, const void *name, void *value, long size) {
1099 if (size && res > 0) {
1101 POST_WRITE(value, res);
1105 PRE_SYSCALL(lgetxattr)
1106 (const void *path, const void *name, void *value, long size) {
1108 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1110 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1113 POST_SYSCALL(lgetxattr)
1114 (long res, const void *path, const void *name, void *value, long size) {
1115 if (size && res > 0) {
1117 POST_WRITE(value, res);
1121 PRE_SYSCALL(fgetxattr)(long fd, const void *name, void *value, long size) {
1123 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1126 POST_SYSCALL(fgetxattr)
1127 (long res, long fd, const void *name, void *value, long size) {
1128 if (size && res > 0) {
1130 POST_WRITE(value, res);
1134 PRE_SYSCALL(listxattr)(const void *path, void *list, long size) {
1136 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1139 POST_SYSCALL(listxattr)(long res, const void *path, void *list, long size) {
1140 if (size && res > 0) {
1142 POST_WRITE(list, res);
1146 PRE_SYSCALL(llistxattr)(const void *path, void *list, long size) {
1148 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1151 POST_SYSCALL(llistxattr)(long res, const void *path, void *list, long size) {
1152 if (size && res > 0) {
1154 POST_WRITE(list, res);
1158 PRE_SYSCALL(flistxattr)(long fd, void *list, long size) {}
1160 POST_SYSCALL(flistxattr)(long res, long fd, void *list, long size) {
1161 if (size && res > 0) {
1163 POST_WRITE(list, res);
1167 PRE_SYSCALL(removexattr)(const void *path, const void *name) {
1169 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1171 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1174 POST_SYSCALL(removexattr)(long res, const void *path, const void *name) {}
1176 PRE_SYSCALL(lremovexattr)(const void *path, const void *name) {
1178 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1180 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1183 POST_SYSCALL(lremovexattr)(long res, const void *path, const void *name) {}
1185 PRE_SYSCALL(fremovexattr)(long fd, const void *name) {
1187 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
1190 POST_SYSCALL(fremovexattr)(long res, long fd, const void *name) {}
1192 PRE_SYSCALL(brk)(long brk) {}
1194 POST_SYSCALL(brk)(long res, long brk) {}
1196 PRE_SYSCALL(mprotect)(long start, long len, long prot) {}
1198 POST_SYSCALL(mprotect)(long res, long start, long len, long prot) {}
1201 (long addr, long old_len, long new_len, long flags, long new_addr) {}
1203 POST_SYSCALL(mremap)
1204 (long res, long addr, long old_len, long new_len, long flags, long new_addr) {}
1206 PRE_SYSCALL(remap_file_pages)
1207 (long start, long size, long prot, long pgoff, long flags) {}
1209 POST_SYSCALL(remap_file_pages)
1210 (long res, long start, long size, long prot, long pgoff, long flags) {}
1212 PRE_SYSCALL(msync)(long start, long len, long flags) {}
1214 POST_SYSCALL(msync)(long res, long start, long len, long flags) {}
1216 PRE_SYSCALL(munmap)(long addr, long len) {}
1218 POST_SYSCALL(munmap)(long res, long addr, long len) {}
1220 PRE_SYSCALL(mlock)(long start, long len) {}
1222 POST_SYSCALL(mlock)(long res, long start, long len) {}
1224 PRE_SYSCALL(munlock)(long start, long len) {}
1226 POST_SYSCALL(munlock)(long res, long start, long len) {}
1228 PRE_SYSCALL(mlockall)(long flags) {}
1230 POST_SYSCALL(mlockall)(long res, long flags) {}
1232 PRE_SYSCALL(munlockall)() {}
1234 POST_SYSCALL(munlockall)(long res) {}
1236 PRE_SYSCALL(madvise)(long start, long len, long behavior) {}
1238 POST_SYSCALL(madvise)(long res, long start, long len, long behavior) {}
1240 PRE_SYSCALL(mincore)(long start, long len, void *vec) {}
1242 POST_SYSCALL(mincore)(long res, long start, long len, void *vec) {
1245 POST_WRITE(vec, (len + GetPageSizeCached() - 1) / GetPageSizeCached());
1250 PRE_SYSCALL(pivot_root)(const void *new_root, const void *put_old) {
1253 __sanitizer::internal_strlen((const char *)new_root) + 1);
1255 PRE_READ(put_old, __sanitizer::internal_strlen((const char *)put_old) + 1);
1258 POST_SYSCALL(pivot_root)(long res, const void *new_root, const void *put_old) {}
1260 PRE_SYSCALL(chroot)(const void *filename) {
1263 __sanitizer::internal_strlen((const char *)filename) + 1);
1266 POST_SYSCALL(chroot)(long res, const void *filename) {}
1268 PRE_SYSCALL(mknod)(const void *filename, long mode, long dev) {
1271 __sanitizer::internal_strlen((const char *)filename) + 1);
1274 POST_SYSCALL(mknod)(long res, const void *filename, long mode, long dev) {}
1276 PRE_SYSCALL(link)(const void *oldname, const void *newname) {
1278 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
1280 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
1283 POST_SYSCALL(link)(long res, const void *oldname, const void *newname) {}
1285 PRE_SYSCALL(symlink)(const void *old, const void *new_) {
1287 PRE_READ(old, __sanitizer::internal_strlen((const char *)old) + 1);
1289 PRE_READ(new_, __sanitizer::internal_strlen((const char *)new_) + 1);
1292 POST_SYSCALL(symlink)(long res, const void *old, const void *new_) {}
1294 PRE_SYSCALL(unlink)(const void *pathname) {
1297 __sanitizer::internal_strlen((const char *)pathname) + 1);
1300 POST_SYSCALL(unlink)(long res, const void *pathname) {}
1302 PRE_SYSCALL(rename)(const void *oldname, const void *newname) {
1304 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
1306 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
1309 POST_SYSCALL(rename)(long res, const void *oldname, const void *newname) {}
1311 PRE_SYSCALL(chmod)(const void *filename, long mode) {
1314 __sanitizer::internal_strlen((const char *)filename) + 1);
1317 POST_SYSCALL(chmod)(long res, const void *filename, long mode) {}
1319 PRE_SYSCALL(fchmod)(long fd, long mode) {}
1321 POST_SYSCALL(fchmod)(long res, long fd, long mode) {}
1323 PRE_SYSCALL(fcntl)(long fd, long cmd, long arg) {}
1325 POST_SYSCALL(fcntl)(long res, long fd, long cmd, long arg) {}
1327 PRE_SYSCALL(fcntl64)(long fd, long cmd, long arg) {}
1329 POST_SYSCALL(fcntl64)(long res, long fd, long cmd, long arg) {}
1331 PRE_SYSCALL(pipe)(void *fildes) {}
1333 POST_SYSCALL(pipe)(long res, void *fildes) {
1336 POST_WRITE(fildes, sizeof(int) * 2);
1339 PRE_SYSCALL(pipe2)(void *fildes, long flags) {}
1341 POST_SYSCALL(pipe2)(long res, void *fildes, long flags) {
1344 POST_WRITE(fildes, sizeof(int) * 2);
1347 PRE_SYSCALL(dup)(long fildes) {}
1349 POST_SYSCALL(dup)(long res, long fildes) {}
1351 PRE_SYSCALL(dup2)(long oldfd, long newfd) {}
1353 POST_SYSCALL(dup2)(long res, long oldfd, long newfd) {}
1355 PRE_SYSCALL(dup3)(long oldfd, long newfd, long flags) {}
1357 POST_SYSCALL(dup3)(long res, long oldfd, long newfd, long flags) {}
1359 PRE_SYSCALL(ioperm)(long from, long num, long on) {}
1361 POST_SYSCALL(ioperm)(long res, long from, long num, long on) {}
1363 PRE_SYSCALL(ioctl)(long fd, long cmd, long arg) {}
1365 POST_SYSCALL(ioctl)(long res, long fd, long cmd, long arg) {}
1367 PRE_SYSCALL(flock)(long fd, long cmd) {}
1369 POST_SYSCALL(flock)(long res, long fd, long cmd) {}
1371 PRE_SYSCALL(io_setup)(long nr_reqs, void **ctx) {
1373 PRE_WRITE(ctx, sizeof(*ctx));
1376 POST_SYSCALL(io_setup)(long res, long nr_reqs, void **ctx) {
1377 if (res >= 0 && ctx) {
1378 POST_WRITE(ctx, sizeof(*ctx));
1379 // (*ctx) is actually a pointer to a kernel mapped page, and there are
1380 // people out there who are crazy enough to peek into that page's 32-byte
1383 POST_WRITE(*ctx, 32);
1387 PRE_SYSCALL(io_destroy)(long ctx) {}
1389 POST_SYSCALL(io_destroy)(long res, long ctx) {}
1391 PRE_SYSCALL(io_getevents)
1392 (long ctx_id, long min_nr, long nr, __sanitizer_io_event *ioevpp,
1395 PRE_READ(timeout, struct_timespec_sz);
1398 POST_SYSCALL(io_getevents)
1399 (long res, long ctx_id, long min_nr, long nr, __sanitizer_io_event *ioevpp,
1403 POST_WRITE(ioevpp, res * sizeof(*ioevpp));
1405 POST_WRITE(timeout, struct_timespec_sz);
1407 for (long i = 0; i < res; i++) {
1408 // We synchronize io_submit -> io_getevents/io_cancel using the
1409 // user-provided data context. Data is not necessary a pointer, it can be
1410 // an int, 0 or whatever; acquire/release will correctly handle this.
1411 // This scheme can lead to false negatives, e.g. when all operations
1412 // synchronize on 0. But there does not seem to be a better solution
1413 // (except wrapping all operations in own context, which is unreliable).
1414 // We can not reliably extract fildes in io_getevents.
1415 COMMON_SYSCALL_ACQUIRE((void *)ioevpp[i].data);
1419 PRE_SYSCALL(io_submit)(long ctx_id, long nr, __sanitizer_iocb **iocbpp) {
1420 for (long i = 0; i < nr; ++i) {
1421 uptr op = iocbpp[i]->aio_lio_opcode;
1422 void *data = (void *)iocbpp[i]->aio_data;
1423 void *buf = (void *)iocbpp[i]->aio_buf;
1424 uptr len = (uptr)iocbpp[i]->aio_nbytes;
1425 if (op == iocb_cmd_pwrite && buf && len) {
1427 } else if (op == iocb_cmd_pread && buf && len) {
1428 POST_WRITE(buf, len);
1429 } else if (op == iocb_cmd_pwritev) {
1430 __sanitizer_iovec *iovec = (__sanitizer_iovec *)buf;
1431 for (uptr v = 0; v < len; v++)
1432 PRE_READ(iovec[v].iov_base, iovec[v].iov_len);
1433 } else if (op == iocb_cmd_preadv) {
1434 __sanitizer_iovec *iovec = (__sanitizer_iovec *)buf;
1435 for (uptr v = 0; v < len; v++)
1436 POST_WRITE(iovec[v].iov_base, iovec[v].iov_len);
1438 // See comment in io_getevents.
1439 COMMON_SYSCALL_RELEASE(data);
1443 POST_SYSCALL(io_submit)
1444 (long res, long ctx_id, long nr, __sanitizer_iocb **iocbpp) {}
1446 PRE_SYSCALL(io_cancel)
1447 (long ctx_id, __sanitizer_iocb *iocb, __sanitizer_io_event *result) {}
1449 POST_SYSCALL(io_cancel)
1450 (long res, long ctx_id, __sanitizer_iocb *iocb, __sanitizer_io_event *result) {
1453 // See comment in io_getevents.
1454 COMMON_SYSCALL_ACQUIRE((void *)result->data);
1455 POST_WRITE(result, sizeof(*result));
1458 POST_WRITE(iocb, sizeof(*iocb));
1462 PRE_SYSCALL(sendfile)(long out_fd, long in_fd, void *offset, long count) {}
1464 POST_SYSCALL(sendfile)
1465 (long res, long out_fd, long in_fd, __sanitizer___kernel_off_t *offset,
1469 POST_WRITE(offset, sizeof(*offset));
1473 PRE_SYSCALL(sendfile64)(long out_fd, long in_fd, void *offset, long count) {}
1475 POST_SYSCALL(sendfile64)
1476 (long res, long out_fd, long in_fd, __sanitizer___kernel_loff_t *offset,
1480 POST_WRITE(offset, sizeof(*offset));
1484 PRE_SYSCALL(readlink)(const void *path, void *buf, long bufsiz) {
1486 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
1489 POST_SYSCALL(readlink)(long res, const void *path, void *buf, long bufsiz) {
1492 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1496 PRE_SYSCALL(creat)(const void *pathname, long mode) {
1499 __sanitizer::internal_strlen((const char *)pathname) + 1);
1502 POST_SYSCALL(creat)(long res, const void *pathname, long mode) {}
1504 PRE_SYSCALL(open)(const void *filename, long flags, long mode) {
1507 __sanitizer::internal_strlen((const char *)filename) + 1);
1510 POST_SYSCALL(open)(long res, const void *filename, long flags, long mode) {}
1512 PRE_SYSCALL(close)(long fd) { COMMON_SYSCALL_FD_CLOSE((int)fd); }
1514 POST_SYSCALL(close)(long res, long fd) {}
1516 PRE_SYSCALL(access)(const void *filename, long mode) {
1519 __sanitizer::internal_strlen((const char *)filename) + 1);
1522 POST_SYSCALL(access)(long res, const void *filename, long mode) {}
1524 PRE_SYSCALL(vhangup)() {}
1526 POST_SYSCALL(vhangup)(long res) {}
1528 PRE_SYSCALL(chown)(const void *filename, long user, long group) {
1531 __sanitizer::internal_strlen((const char *)filename) + 1);
1534 POST_SYSCALL(chown)(long res, const void *filename, long user, long group) {}
1536 PRE_SYSCALL(lchown)(const void *filename, long user, long group) {
1539 __sanitizer::internal_strlen((const char *)filename) + 1);
1542 POST_SYSCALL(lchown)(long res, const void *filename, long user, long group) {}
1544 PRE_SYSCALL(fchown)(long fd, long user, long group) {}
1546 POST_SYSCALL(fchown)(long res, long fd, long user, long group) {}
1548 # if SANITIZER_USES_UID16_SYSCALLS
1549 PRE_SYSCALL(chown16)(const void *filename, long user, long group) {
1552 __sanitizer::internal_strlen((const char *)filename) + 1);
1555 POST_SYSCALL(chown16)(long res, const void *filename, long user, long group) {}
1557 PRE_SYSCALL(lchown16)(const void *filename, long user, long group) {
1560 __sanitizer::internal_strlen((const char *)filename) + 1);
1563 POST_SYSCALL(lchown16)(long res, const void *filename, long user, long group) {}
1565 PRE_SYSCALL(fchown16)(long fd, long user, long group) {}
1567 POST_SYSCALL(fchown16)(long res, long fd, long user, long group) {}
1569 PRE_SYSCALL(setregid16)(long rgid, long egid) {}
1571 POST_SYSCALL(setregid16)(long res, long rgid, long egid) {}
1573 PRE_SYSCALL(setgid16)(long gid) {}
1575 POST_SYSCALL(setgid16)(long res, long gid) {}
1577 PRE_SYSCALL(setreuid16)(long ruid, long euid) {}
1579 POST_SYSCALL(setreuid16)(long res, long ruid, long euid) {}
1581 PRE_SYSCALL(setuid16)(long uid) {}
1583 POST_SYSCALL(setuid16)(long res, long uid) {}
1585 PRE_SYSCALL(setresuid16)(long ruid, long euid, long suid) {}
1587 POST_SYSCALL(setresuid16)(long res, long ruid, long euid, long suid) {}
1589 PRE_SYSCALL(getresuid16)(void *ruid, void *euid, void *suid) {}
1591 POST_SYSCALL(getresuid16)
1592 (long res, __sanitizer___kernel_old_uid_t *ruid,
1593 __sanitizer___kernel_old_uid_t *euid, __sanitizer___kernel_old_uid_t *suid) {
1596 POST_WRITE(ruid, sizeof(*ruid));
1598 POST_WRITE(euid, sizeof(*euid));
1600 POST_WRITE(suid, sizeof(*suid));
1604 PRE_SYSCALL(setresgid16)(long rgid, long egid, long sgid) {}
1606 POST_SYSCALL(setresgid16)(long res, long rgid, long egid, long sgid) {}
1608 PRE_SYSCALL(getresgid16)(void *rgid, void *egid, void *sgid) {}
1610 POST_SYSCALL(getresgid16)
1611 (long res, __sanitizer___kernel_old_gid_t *rgid,
1612 __sanitizer___kernel_old_gid_t *egid, __sanitizer___kernel_old_gid_t *sgid) {
1615 POST_WRITE(rgid, sizeof(*rgid));
1617 POST_WRITE(egid, sizeof(*egid));
1619 POST_WRITE(sgid, sizeof(*sgid));
1623 PRE_SYSCALL(setfsuid16)(long uid) {}
1625 POST_SYSCALL(setfsuid16)(long res, long uid) {}
1627 PRE_SYSCALL(setfsgid16)(long gid) {}
1629 POST_SYSCALL(setfsgid16)(long res, long gid) {}
1631 PRE_SYSCALL(getgroups16)
1632 (long gidsetsize, __sanitizer___kernel_old_gid_t *grouplist) {}
1634 POST_SYSCALL(getgroups16)
1635 (long res, long gidsetsize, __sanitizer___kernel_old_gid_t *grouplist) {
1638 POST_WRITE(grouplist, res * sizeof(*grouplist));
1642 PRE_SYSCALL(setgroups16)
1643 (long gidsetsize, __sanitizer___kernel_old_gid_t *grouplist) {
1645 POST_WRITE(grouplist, gidsetsize * sizeof(*grouplist));
1648 POST_SYSCALL(setgroups16)
1649 (long res, long gidsetsize, __sanitizer___kernel_old_gid_t *grouplist) {}
1651 PRE_SYSCALL(getuid16)() {}
1653 POST_SYSCALL(getuid16)(long res) {}
1655 PRE_SYSCALL(geteuid16)() {}
1657 POST_SYSCALL(geteuid16)(long res) {}
1659 PRE_SYSCALL(getgid16)() {}
1661 POST_SYSCALL(getgid16)(long res) {}
1663 PRE_SYSCALL(getegid16)() {}
1665 POST_SYSCALL(getegid16)(long res) {}
1666 # endif // SANITIZER_USES_UID16_SYSCALLS
1668 PRE_SYSCALL(utime)(void *filename, void *times) {}
1670 POST_SYSCALL(utime)(long res, void *filename, void *times) {
1673 POST_WRITE(filename,
1674 __sanitizer::internal_strlen((const char *)filename) + 1);
1676 POST_WRITE(times, struct_utimbuf_sz);
1680 PRE_SYSCALL(utimes)(void *filename, void *utimes) {}
1682 POST_SYSCALL(utimes)(long res, void *filename, void *utimes) {
1685 POST_WRITE(filename,
1686 __sanitizer::internal_strlen((const char *)filename) + 1);
1688 POST_WRITE(utimes, timeval_sz);
1692 PRE_SYSCALL(lseek)(long fd, long offset, long origin) {}
1694 POST_SYSCALL(lseek)(long res, long fd, long offset, long origin) {}
1697 (long fd, long offset_high, long offset_low, void *result, long origin) {}
1699 POST_SYSCALL(llseek)
1700 (long res, long fd, long offset_high, long offset_low, void *result,
1704 POST_WRITE(result, sizeof(long long));
1708 PRE_SYSCALL(readv)(long fd, const __sanitizer_iovec *vec, long vlen) {}
1711 (long res, long fd, const __sanitizer_iovec *vec, long vlen) {
1714 kernel_write_iovec(vec, vlen, res);
1718 PRE_SYSCALL(write)(long fd, const void *buf, long count) {
1720 PRE_READ(buf, count);
1723 POST_SYSCALL(write)(long res, long fd, const void *buf, long count) {}
1725 PRE_SYSCALL(writev)(long fd, const __sanitizer_iovec *vec, long vlen) {}
1727 POST_SYSCALL(writev)
1728 (long res, long fd, const __sanitizer_iovec *vec, long vlen) {
1731 kernel_read_iovec(vec, vlen, res);
1736 PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos) {}
1738 POST_SYSCALL(pread64)(long res, long fd, void *buf, long count, long pos) {
1741 POST_WRITE(buf, res);
1745 PRE_SYSCALL(pwrite64)(long fd, const void *buf, long count, long pos) {
1747 PRE_READ(buf, count);
1750 POST_SYSCALL(pwrite64)
1751 (long res, long fd, const void *buf, long count, long pos) {}
1753 PRE_SYSCALL(pread64)(long fd, void *buf, long count, long pos0, long pos1) {}
1755 POST_SYSCALL(pread64)
1756 (long res, long fd, void *buf, long count, long pos0, long pos1) {
1759 POST_WRITE(buf, res);
1763 PRE_SYSCALL(pwrite64)
1764 (long fd, const void *buf, long count, long pos0, long pos1) {
1766 PRE_READ(buf, count);
1769 POST_SYSCALL(pwrite64)
1770 (long res, long fd, const void *buf, long count, long pos0, long pos1) {}
1774 (long fd, const __sanitizer_iovec *vec, long vlen, long pos_l, long pos_h) {}
1776 POST_SYSCALL(preadv)
1777 (long res, long fd, const __sanitizer_iovec *vec, long vlen, long pos_l,
1781 kernel_write_iovec(vec, vlen, res);
1785 PRE_SYSCALL(pwritev)
1786 (long fd, const __sanitizer_iovec *vec, long vlen, long pos_l, long pos_h) {}
1788 POST_SYSCALL(pwritev)
1789 (long res, long fd, const __sanitizer_iovec *vec, long vlen, long pos_l,
1793 kernel_read_iovec(vec, vlen, res);
1797 PRE_SYSCALL(getcwd)(void *buf, long size) {}
1799 POST_SYSCALL(getcwd)(long res, void *buf, long size) {
1802 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1806 PRE_SYSCALL(mkdir)(const void *pathname, long mode) {
1809 __sanitizer::internal_strlen((const char *)pathname) + 1);
1812 POST_SYSCALL(mkdir)(long res, const void *pathname, long mode) {}
1814 PRE_SYSCALL(chdir)(const void *filename) {
1817 __sanitizer::internal_strlen((const char *)filename) + 1);
1820 POST_SYSCALL(chdir)(long res, const void *filename) {}
1822 PRE_SYSCALL(fchdir)(long fd) {}
1824 POST_SYSCALL(fchdir)(long res, long fd) {}
1826 PRE_SYSCALL(rmdir)(const void *pathname) {
1829 __sanitizer::internal_strlen((const char *)pathname) + 1);
1832 POST_SYSCALL(rmdir)(long res, const void *pathname) {}
1834 PRE_SYSCALL(lookup_dcookie)(u64 cookie64, void *buf, long len) {}
1836 POST_SYSCALL(lookup_dcookie)(long res, u64 cookie64, void *buf, long len) {
1839 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
1843 PRE_SYSCALL(quotactl)(long cmd, const void *special, long id, void *addr) {
1845 PRE_READ(special, __sanitizer::internal_strlen((const char *)special) + 1);
1848 POST_SYSCALL(quotactl)
1849 (long res, long cmd, const void *special, long id, void *addr) {}
1851 PRE_SYSCALL(getdents)(long fd, void *dirent, long count) {}
1853 POST_SYSCALL(getdents)(long res, long fd, void *dirent, long count) {
1856 POST_WRITE(dirent, res);
1860 PRE_SYSCALL(getdents64)(long fd, void *dirent, long count) {}
1862 POST_SYSCALL(getdents64)(long res, long fd, void *dirent, long count) {
1865 POST_WRITE(dirent, res);
1869 PRE_SYSCALL(setsockopt)
1870 (long fd, long level, long optname, void *optval, long optlen) {}
1872 POST_SYSCALL(setsockopt)
1873 (long res, long fd, long level, long optname, void *optval, long optlen) {
1877 __sanitizer::internal_strlen((const char *)optval) + 1);
1881 PRE_SYSCALL(getsockopt)
1882 (long fd, long level, long optname, void *optval, void *optlen) {}
1884 POST_SYSCALL(getsockopt)
1885 (long res, long fd, long level, long optname, void *optval, void *optlen) {
1889 __sanitizer::internal_strlen((const char *)optval) + 1);
1891 POST_WRITE(optlen, sizeof(int));
1895 PRE_SYSCALL(bind)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {}
1898 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {
1901 POST_WRITE(arg1, sizeof(*arg1));
1905 PRE_SYSCALL(connect)(long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {}
1907 POST_SYSCALL(connect)
1908 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, long arg2) {
1911 POST_WRITE(arg1, sizeof(*arg1));
1915 PRE_SYSCALL(accept)(long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {}
1917 POST_SYSCALL(accept)
1918 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {
1921 POST_WRITE(arg1, sizeof(*arg1));
1923 POST_WRITE(arg2, sizeof(unsigned));
1927 PRE_SYSCALL(accept4)
1928 (long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2, long arg3) {}
1930 POST_SYSCALL(accept4)
1931 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2, long arg3) {
1934 POST_WRITE(arg1, sizeof(*arg1));
1936 POST_WRITE(arg2, sizeof(unsigned));
1940 PRE_SYSCALL(getsockname)
1941 (long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {}
1943 POST_SYSCALL(getsockname)
1944 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {
1947 POST_WRITE(arg1, sizeof(*arg1));
1949 POST_WRITE(arg2, sizeof(unsigned));
1953 PRE_SYSCALL(getpeername)
1954 (long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {}
1956 POST_SYSCALL(getpeername)
1957 (long res, long arg0, sanitizer_kernel_sockaddr *arg1, void *arg2) {
1960 POST_WRITE(arg1, sizeof(*arg1));
1962 POST_WRITE(arg2, sizeof(unsigned));
1966 PRE_SYSCALL(send)(long arg0, void *arg1, long arg2, long arg3) {}
1968 POST_SYSCALL(send)(long res, long arg0, void *arg1, long arg2, long arg3) {
1971 POST_READ(arg1, res);
1976 (long arg0, void *arg1, long arg2, long arg3, sanitizer_kernel_sockaddr *arg4,
1979 POST_SYSCALL(sendto)
1980 (long res, long arg0, void *arg1, long arg2, long arg3,
1981 sanitizer_kernel_sockaddr *arg4, long arg5) {
1984 POST_READ(arg1, res);
1986 POST_WRITE(arg4, sizeof(*arg4));
1990 PRE_SYSCALL(sendmsg)(long fd, void *msg, long flags) {}
1992 POST_SYSCALL(sendmsg)(long res, long fd, void *msg, long flags) {
1996 PRE_SYSCALL(sendmmsg)(long fd, void *msg, long vlen, long flags) {}
1998 POST_SYSCALL(sendmmsg)(long res, long fd, void *msg, long vlen, long flags) {
2002 PRE_SYSCALL(recv)(long arg0, void *buf, long len, long flags) {}
2004 POST_SYSCALL(recv)(long res, void *buf, long len, long flags) {
2007 POST_WRITE(buf, res);
2011 PRE_SYSCALL(recvfrom)
2012 (long arg0, void *buf, long len, long flags, sanitizer_kernel_sockaddr *arg4,
2015 POST_SYSCALL(recvfrom)
2016 (long res, long arg0, void *buf, long len, long flags,
2017 sanitizer_kernel_sockaddr *arg4, void *arg5) {
2020 POST_WRITE(buf, res);
2022 POST_WRITE(arg4, sizeof(*arg4));
2024 POST_WRITE(arg5, sizeof(int));
2028 PRE_SYSCALL(socket)(long arg0, long arg1, long arg2) {}
2030 POST_SYSCALL(socket)(long res, long arg0, long arg1, long arg2) {}
2032 PRE_SYSCALL(socketpair)(long arg0, long arg1, long arg2, int *sv) {}
2034 POST_SYSCALL(socketpair)(long res, long arg0, long arg1, long arg2, int *sv) {
2037 POST_WRITE(sv, sizeof(int) * 2);
2040 PRE_SYSCALL(socketcall)(long call, void *args) {}
2042 POST_SYSCALL(socketcall)(long res, long call, void *args) {
2045 POST_WRITE(args, sizeof(long));
2049 PRE_SYSCALL(listen)(long arg0, long arg1) {}
2051 POST_SYSCALL(listen)(long res, long arg0, long arg1) {}
2053 PRE_SYSCALL(poll)(void *ufds, long nfds, long timeout) {}
2056 (long res, __sanitizer_pollfd *ufds, long nfds, long timeout) {
2059 POST_WRITE(ufds, nfds * sizeof(*ufds));
2064 (long n, __sanitizer___kernel_fd_set *inp, __sanitizer___kernel_fd_set *outp,
2065 __sanitizer___kernel_fd_set *exp, void *tvp) {}
2067 POST_SYSCALL(select)
2068 (long res, long n, __sanitizer___kernel_fd_set *inp,
2069 __sanitizer___kernel_fd_set *outp, __sanitizer___kernel_fd_set *exp,
2073 POST_WRITE(inp, sizeof(*inp));
2075 POST_WRITE(outp, sizeof(*outp));
2077 POST_WRITE(exp, sizeof(*exp));
2079 POST_WRITE(tvp, timeval_sz);
2083 PRE_SYSCALL(old_select)(void *arg) {}
2085 POST_SYSCALL(old_select)(long res, void *arg) {}
2087 PRE_SYSCALL(epoll_create)(long size) {}
2089 POST_SYSCALL(epoll_create)(long res, long size) {}
2091 PRE_SYSCALL(epoll_create1)(long flags) {}
2093 POST_SYSCALL(epoll_create1)(long res, long flags) {}
2095 PRE_SYSCALL(epoll_ctl)(long epfd, long op, long fd, void *event) {}
2097 POST_SYSCALL(epoll_ctl)(long res, long epfd, long op, long fd, void *event) {
2100 POST_WRITE(event, struct_epoll_event_sz);
2104 PRE_SYSCALL(epoll_wait)
2105 (long epfd, void *events, long maxevents, long timeout) {}
2107 POST_SYSCALL(epoll_wait)
2108 (long res, long epfd, void *events, long maxevents, long timeout) {
2110 COMMON_SYSCALL_FD_ACQUIRE(epfd);
2112 POST_WRITE(events, res * struct_epoll_event_sz);
2116 PRE_SYSCALL(epoll_pwait)
2117 (long epfd, void *events, long maxevents, long timeout,
2118 const kernel_sigset_t *sigmask, long sigsetsize) {
2120 PRE_READ(sigmask, sigsetsize);
2123 POST_SYSCALL(epoll_pwait)
2124 (long res, long epfd, void *events, long maxevents, long timeout,
2125 const void *sigmask, long sigsetsize) {
2127 COMMON_SYSCALL_FD_ACQUIRE(epfd);
2129 POST_WRITE(events, res * struct_epoll_event_sz);
2133 PRE_SYSCALL(epoll_pwait2)
2134 (long epfd, void *events, long maxevents,
2135 const sanitizer_kernel_timespec *timeout, const kernel_sigset_t *sigmask,
2138 PRE_READ(timeout, sizeof(*timeout));
2140 PRE_READ(sigmask, sigsetsize);
2143 POST_SYSCALL(epoll_pwait2)
2144 (long res, long epfd, void *events, long maxevents,
2145 const sanitizer_kernel_timespec *timeout, const void *sigmask,
2148 COMMON_SYSCALL_FD_ACQUIRE(epfd);
2150 POST_WRITE(events, res * struct_epoll_event_sz);
2154 PRE_SYSCALL(gethostname)(void *name, long len) {}
2156 POST_SYSCALL(gethostname)(long res, void *name, long len) {
2159 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
2163 PRE_SYSCALL(sethostname)(void *name, long len) {}
2165 POST_SYSCALL(sethostname)(long res, void *name, long len) {
2168 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
2172 PRE_SYSCALL(setdomainname)(void *name, long len) {}
2174 POST_SYSCALL(setdomainname)(long res, void *name, long len) {
2177 POST_WRITE(name, __sanitizer::internal_strlen((const char *)name) + 1);
2181 PRE_SYSCALL(newuname)(void *name) {}
2183 POST_SYSCALL(newuname)(long res, void *name) {
2186 POST_WRITE(name, struct_new_utsname_sz);
2190 PRE_SYSCALL(uname)(void *arg0) {}
2192 POST_SYSCALL(uname)(long res, void *arg0) {
2195 POST_WRITE(arg0, struct_old_utsname_sz);
2199 PRE_SYSCALL(olduname)(void *arg0) {}
2201 POST_SYSCALL(olduname)(long res, void *arg0) {
2204 POST_WRITE(arg0, struct_oldold_utsname_sz);
2208 PRE_SYSCALL(getrlimit)(long resource, void *rlim) {}
2210 POST_SYSCALL(getrlimit)(long res, long resource, void *rlim) {
2213 POST_WRITE(rlim, struct_rlimit_sz);
2217 PRE_SYSCALL(old_getrlimit)(long resource, void *rlim) {}
2219 POST_SYSCALL(old_getrlimit)(long res, long resource, void *rlim) {
2222 POST_WRITE(rlim, struct_rlimit_sz);
2226 PRE_SYSCALL(setrlimit)(long resource, void *rlim) {}
2228 POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
2231 POST_WRITE(rlim, struct_rlimit_sz);
2235 # if SANITIZER_GLIBC
2236 PRE_SYSCALL(prlimit64)
2237 (long pid, long resource, const void *new_rlim, void *old_rlim) {
2239 PRE_READ(new_rlim, struct_rlimit64_sz);
2242 POST_SYSCALL(prlimit64)
2243 (long res, long pid, long resource, const void *new_rlim, void *old_rlim) {
2246 POST_WRITE(old_rlim, struct_rlimit64_sz);
2251 PRE_SYSCALL(getrusage)(long who, void *ru) {}
2253 POST_SYSCALL(getrusage)(long res, long who, void *ru) {
2256 POST_WRITE(ru, struct_rusage_sz);
2260 PRE_SYSCALL(umask)(long mask) {}
2262 POST_SYSCALL(umask)(long res, long mask) {}
2264 PRE_SYSCALL(msgget)(long key, long msgflg) {}
2266 POST_SYSCALL(msgget)(long res, long key, long msgflg) {}
2268 PRE_SYSCALL(msgsnd)(long msqid, void *msgp, long msgsz, long msgflg) {
2270 PRE_READ(msgp, msgsz);
2273 POST_SYSCALL(msgsnd)
2274 (long res, long msqid, void *msgp, long msgsz, long msgflg) {}
2277 (long msqid, void *msgp, long msgsz, long msgtyp, long msgflg) {}
2279 POST_SYSCALL(msgrcv)
2280 (long res, long msqid, void *msgp, long msgsz, long msgtyp, long msgflg) {
2283 POST_WRITE(msgp, res);
2287 # if !SANITIZER_ANDROID
2288 PRE_SYSCALL(msgctl)(long msqid, long cmd, void *buf) {}
2290 POST_SYSCALL(msgctl)(long res, long msqid, long cmd, void *buf) {
2293 POST_WRITE(buf, struct_msqid_ds_sz);
2298 PRE_SYSCALL(semget)(long key, long nsems, long semflg) {}
2300 POST_SYSCALL(semget)(long res, long key, long nsems, long semflg) {}
2302 PRE_SYSCALL(semop)(long semid, void *sops, long nsops) {}
2304 POST_SYSCALL(semop)(long res, long semid, void *sops, long nsops) {}
2306 PRE_SYSCALL(semctl)(long semid, long semnum, long cmd, void *arg) {}
2308 POST_SYSCALL(semctl)(long res, long semid, long semnum, long cmd, void *arg) {}
2310 PRE_SYSCALL(semtimedop)
2311 (long semid, void *sops, long nsops, const void *timeout) {
2313 PRE_READ(timeout, struct_timespec_sz);
2316 POST_SYSCALL(semtimedop)
2317 (long res, long semid, void *sops, long nsops, const void *timeout) {}
2319 PRE_SYSCALL(shmat)(long shmid, void *shmaddr, long shmflg) {}
2321 POST_SYSCALL(shmat)(long res, long shmid, void *shmaddr, long shmflg) {
2325 __sanitizer::internal_strlen((const char *)shmaddr) + 1);
2329 PRE_SYSCALL(shmget)(long key, long size, long flag) {}
2331 POST_SYSCALL(shmget)(long res, long key, long size, long flag) {}
2333 PRE_SYSCALL(shmdt)(void *shmaddr) {}
2335 POST_SYSCALL(shmdt)(long res, void *shmaddr) {
2339 __sanitizer::internal_strlen((const char *)shmaddr) + 1);
2344 (long call, long first, long second, long third, void *ptr, long fifth) {}
2347 (long res, long call, long first, long second, long third, void *ptr,
2350 # if !SANITIZER_ANDROID
2351 PRE_SYSCALL(shmctl)(long shmid, long cmd, void *buf) {}
2353 POST_SYSCALL(shmctl)(long res, long shmid, long cmd, void *buf) {
2356 POST_WRITE(buf, sizeof(__sanitizer_shmid_ds));
2360 PRE_SYSCALL(mq_open)(const void *name, long oflag, long mode, void *attr) {
2362 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2365 POST_SYSCALL(mq_open)
2366 (long res, const void *name, long oflag, long mode, void *attr) {
2369 POST_WRITE(attr, struct_mq_attr_sz);
2373 PRE_SYSCALL(mq_unlink)(const void *name) {
2375 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2378 POST_SYSCALL(mq_unlink)(long res, const void *name) {}
2380 PRE_SYSCALL(mq_timedsend)
2381 (long mqdes, const void *msg_ptr, long msg_len, long msg_prio,
2382 const void *abs_timeout) {
2384 PRE_READ(msg_ptr, msg_len);
2386 PRE_READ(abs_timeout, struct_timespec_sz);
2389 POST_SYSCALL(mq_timedsend)
2390 (long res, long mqdes, const void *msg_ptr, long msg_len, long msg_prio,
2391 const void *abs_timeout) {}
2393 PRE_SYSCALL(mq_timedreceive)
2394 (long mqdes, void *msg_ptr, long msg_len, void *msg_prio,
2395 const void *abs_timeout) {
2397 PRE_READ(abs_timeout, struct_timespec_sz);
2400 POST_SYSCALL(mq_timedreceive)
2401 (long res, long mqdes, void *msg_ptr, long msg_len, int *msg_prio,
2402 const void *abs_timeout) {
2405 POST_WRITE(msg_ptr, res);
2407 POST_WRITE(msg_prio, sizeof(*msg_prio));
2411 PRE_SYSCALL(mq_notify)(long mqdes, const void *notification) {
2413 PRE_READ(notification, struct_sigevent_sz);
2416 POST_SYSCALL(mq_notify)(long res, long mqdes, const void *notification) {}
2418 PRE_SYSCALL(mq_getsetattr)(long mqdes, const void *mqstat, void *omqstat) {
2420 PRE_READ(mqstat, struct_mq_attr_sz);
2423 POST_SYSCALL(mq_getsetattr)
2424 (long res, long mqdes, const void *mqstat, void *omqstat) {
2427 POST_WRITE(omqstat, struct_mq_attr_sz);
2430 # endif // SANITIZER_ANDROID
2432 PRE_SYSCALL(pciconfig_iobase)(long which, long bus, long devfn) {}
2434 POST_SYSCALL(pciconfig_iobase)(long res, long which, long bus, long devfn) {}
2436 PRE_SYSCALL(pciconfig_read)
2437 (long bus, long dfn, long off, long len, void *buf) {}
2439 POST_SYSCALL(pciconfig_read)
2440 (long res, long bus, long dfn, long off, long len, void *buf) {}
2442 PRE_SYSCALL(pciconfig_write)
2443 (long bus, long dfn, long off, long len, void *buf) {}
2445 POST_SYSCALL(pciconfig_write)
2446 (long res, long bus, long dfn, long off, long len, void *buf) {}
2448 PRE_SYSCALL(swapon)(const void *specialfile, long swap_flags) {
2450 PRE_READ(specialfile,
2451 __sanitizer::internal_strlen((const char *)specialfile) + 1);
2454 POST_SYSCALL(swapon)(long res, const void *specialfile, long swap_flags) {}
2456 PRE_SYSCALL(swapoff)(const void *specialfile) {
2458 PRE_READ(specialfile,
2459 __sanitizer::internal_strlen((const char *)specialfile) + 1);
2462 POST_SYSCALL(swapoff)(long res, const void *specialfile) {}
2464 PRE_SYSCALL(sysctl)(__sanitizer___sysctl_args *args) {
2467 PRE_READ(args->name, args->nlen * sizeof(*args->name));
2469 PRE_READ(args->name, args->newlen);
2473 POST_SYSCALL(sysctl)(long res, __sanitizer___sysctl_args *args) {
2475 if (args && args->oldval && args->oldlenp) {
2476 POST_WRITE(args->oldlenp, sizeof(*args->oldlenp));
2477 POST_WRITE(args->oldval, *args->oldlenp);
2482 PRE_SYSCALL(sysinfo)(void *info) {}
2484 POST_SYSCALL(sysinfo)(long res, void *info) {
2487 POST_WRITE(info, struct_sysinfo_sz);
2491 PRE_SYSCALL(sysfs)(long option, long arg1, long arg2) {}
2493 POST_SYSCALL(sysfs)(long res, long option, long arg1, long arg2) {}
2495 PRE_SYSCALL(syslog)(long type, void *buf, long len) {}
2497 POST_SYSCALL(syslog)(long res, long type, void *buf, long len) {
2500 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
2504 PRE_SYSCALL(uselib)(const void *library) {
2506 PRE_READ(library, __sanitizer::internal_strlen((const char *)library) + 1);
2509 POST_SYSCALL(uselib)(long res, const void *library) {}
2511 PRE_SYSCALL(ni_syscall)() {}
2513 POST_SYSCALL(ni_syscall)(long res) {}
2515 PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) {
2516 # if !SANITIZER_ANDROID && \
2517 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
2518 defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__) || \
2519 defined(__loongarch__) || SANITIZER_RISCV64)
2521 if (request == ptrace_setregs) {
2522 PRE_READ((void *)data, struct_user_regs_struct_sz);
2523 } else if (request == ptrace_setfpregs) {
2524 PRE_READ((void *)data, struct_user_fpregs_struct_sz);
2525 } else if (request == ptrace_setfpxregs) {
2526 PRE_READ((void *)data, struct_user_fpxregs_struct_sz);
2527 } else if (request == ptrace_setsiginfo) {
2528 PRE_READ((void *)data, siginfo_t_sz);
2529 } else if (request == ptrace_setregset) {
2530 __sanitizer_iovec *iov = (__sanitizer_iovec *)data;
2531 PRE_READ(iov->iov_base, iov->iov_len);
2537 POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) {
2538 # if !SANITIZER_ANDROID && \
2539 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
2540 defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__) || \
2541 defined(__loongarch__) || SANITIZER_RISCV64)
2542 if (res >= 0 && data) {
2543 // Note that this is different from the interceptor in
2544 // sanitizer_common_interceptors.inc.
2545 // PEEK* requests return resulting values through data pointer.
2546 if (request == ptrace_getregs) {
2547 POST_WRITE((void *)data, struct_user_regs_struct_sz);
2548 } else if (request == ptrace_getfpregs) {
2549 POST_WRITE((void *)data, struct_user_fpregs_struct_sz);
2550 } else if (request == ptrace_getfpxregs) {
2551 POST_WRITE((void *)data, struct_user_fpxregs_struct_sz);
2552 } else if (request == ptrace_getsiginfo) {
2553 POST_WRITE((void *)data, siginfo_t_sz);
2554 } else if (request == ptrace_getregset) {
2555 __sanitizer_iovec *iov = (__sanitizer_iovec *)data;
2556 POST_WRITE(iov->iov_base, iov->iov_len);
2557 } else if (request == ptrace_peekdata || request == ptrace_peektext ||
2558 request == ptrace_peekuser) {
2559 POST_WRITE((void *)data, sizeof(void *));
2565 PRE_SYSCALL(add_key)
2566 (const void *_type, const void *_description, const void *_payload, long plen,
2569 PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1);
2571 PRE_READ(_description,
2572 __sanitizer::internal_strlen((const char *)_description) + 1);
2575 POST_SYSCALL(add_key)
2576 (long res, const void *_type, const void *_description, const void *_payload,
2577 long plen, long destringid) {}
2579 PRE_SYSCALL(request_key)
2580 (const void *_type, const void *_description, const void *_callout_info,
2583 PRE_READ(_type, __sanitizer::internal_strlen((const char *)_type) + 1);
2585 PRE_READ(_description,
2586 __sanitizer::internal_strlen((const char *)_description) + 1);
2588 PRE_READ(_callout_info,
2589 __sanitizer::internal_strlen((const char *)_callout_info) + 1);
2592 POST_SYSCALL(request_key)
2593 (long res, const void *_type, const void *_description,
2594 const void *_callout_info, long destringid) {}
2596 PRE_SYSCALL(keyctl)(long cmd, long arg2, long arg3, long arg4, long arg5) {}
2598 POST_SYSCALL(keyctl)
2599 (long res, long cmd, long arg2, long arg3, long arg4, long arg5) {}
2601 PRE_SYSCALL(ioprio_set)(long which, long who, long ioprio) {}
2603 POST_SYSCALL(ioprio_set)(long res, long which, long who, long ioprio) {}
2605 PRE_SYSCALL(ioprio_get)(long which, long who) {}
2607 POST_SYSCALL(ioprio_get)(long res, long which, long who) {}
2609 PRE_SYSCALL(set_mempolicy)(long mode, void *nmask, long maxnode) {}
2611 POST_SYSCALL(set_mempolicy)(long res, long mode, void *nmask, long maxnode) {
2614 POST_WRITE(nmask, sizeof(long));
2618 PRE_SYSCALL(migrate_pages)
2619 (long pid, long maxnode, const void *from, const void *to) {
2621 PRE_READ(from, sizeof(long));
2623 PRE_READ(to, sizeof(long));
2626 POST_SYSCALL(migrate_pages)
2627 (long res, long pid, long maxnode, const void *from, const void *to) {}
2629 PRE_SYSCALL(move_pages)
2630 (long pid, long nr_pages, const void **pages, const int *nodes, int *status,
2633 PRE_READ(pages, nr_pages * sizeof(*pages));
2635 PRE_READ(nodes, nr_pages * sizeof(*nodes));
2638 POST_SYSCALL(move_pages)
2639 (long res, long pid, long nr_pages, const void **pages, const int *nodes,
2640 int *status, long flags) {
2643 POST_WRITE(status, nr_pages * sizeof(*status));
2648 (long start, long len, long mode, void *nmask, long maxnode, long flags) {}
2651 (long res, long start, long len, long mode, void *nmask, long maxnode,
2655 POST_WRITE(nmask, sizeof(long));
2659 PRE_SYSCALL(get_mempolicy)
2660 (void *policy, void *nmask, long maxnode, long addr, long flags) {}
2662 POST_SYSCALL(get_mempolicy)
2663 (long res, void *policy, void *nmask, long maxnode, long addr, long flags) {
2666 POST_WRITE(policy, sizeof(int));
2668 POST_WRITE(nmask, sizeof(long));
2672 PRE_SYSCALL(inotify_init)() {}
2674 POST_SYSCALL(inotify_init)(long res) {}
2676 PRE_SYSCALL(inotify_init1)(long flags) {}
2678 POST_SYSCALL(inotify_init1)(long res, long flags) {}
2680 PRE_SYSCALL(inotify_add_watch)(long fd, const void *path, long mask) {
2682 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
2685 POST_SYSCALL(inotify_add_watch)
2686 (long res, long fd, const void *path, long mask) {}
2688 PRE_SYSCALL(inotify_rm_watch)(long fd, long wd) {}
2690 POST_SYSCALL(inotify_rm_watch)(long res, long fd, long wd) {}
2692 PRE_SYSCALL(spu_run)(long fd, void *unpc, void *ustatus) {}
2694 POST_SYSCALL(spu_run)(long res, long fd, unsigned *unpc, unsigned *ustatus) {
2697 POST_WRITE(unpc, sizeof(*unpc));
2699 POST_WRITE(ustatus, sizeof(*ustatus));
2703 PRE_SYSCALL(spu_create)(const void *name, long flags, long mode, long fd) {
2705 PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1);
2708 POST_SYSCALL(spu_create)
2709 (long res, const void *name, long flags, long mode, long fd) {}
2711 PRE_SYSCALL(mknodat)(long dfd, const void *filename, long mode, long dev) {
2714 __sanitizer::internal_strlen((const char *)filename) + 1);
2717 POST_SYSCALL(mknodat)
2718 (long res, long dfd, const void *filename, long mode, long dev) {}
2720 PRE_SYSCALL(mkdirat)(long dfd, const void *pathname, long mode) {
2723 __sanitizer::internal_strlen((const char *)pathname) + 1);
2726 POST_SYSCALL(mkdirat)(long res, long dfd, const void *pathname, long mode) {}
2728 PRE_SYSCALL(unlinkat)(long dfd, const void *pathname, long flag) {
2731 __sanitizer::internal_strlen((const char *)pathname) + 1);
2734 POST_SYSCALL(unlinkat)(long res, long dfd, const void *pathname, long flag) {}
2736 PRE_SYSCALL(symlinkat)(const void *oldname, long newdfd, const void *newname) {
2738 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2740 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2743 POST_SYSCALL(symlinkat)
2744 (long res, const void *oldname, long newdfd, const void *newname) {}
2747 (long olddfd, const void *oldname, long newdfd, const void *newname,
2750 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2752 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2755 POST_SYSCALL(linkat)
2756 (long res, long olddfd, const void *oldname, long newdfd, const void *newname,
2759 PRE_SYSCALL(renameat)
2760 (long olddfd, const void *oldname, long newdfd, const void *newname) {
2762 PRE_READ(oldname, __sanitizer::internal_strlen((const char *)oldname) + 1);
2764 PRE_READ(newname, __sanitizer::internal_strlen((const char *)newname) + 1);
2767 POST_SYSCALL(renameat)
2768 (long res, long olddfd, const void *oldname, long newdfd, const void *newname) {
2771 PRE_SYSCALL(futimesat)(long dfd, const void *filename, void *utimes) {
2774 __sanitizer::internal_strlen((const char *)filename) + 1);
2777 POST_SYSCALL(futimesat)
2778 (long res, long dfd, const void *filename, void *utimes) {
2781 POST_WRITE(utimes, timeval_sz);
2785 PRE_SYSCALL(faccessat)(long dfd, const void *filename, long mode) {
2788 __sanitizer::internal_strlen((const char *)filename) + 1);
2791 POST_SYSCALL(faccessat)(long res, long dfd, const void *filename, long mode) {}
2793 PRE_SYSCALL(fchmodat)(long dfd, const void *filename, long mode) {
2796 __sanitizer::internal_strlen((const char *)filename) + 1);
2799 POST_SYSCALL(fchmodat)(long res, long dfd, const void *filename, long mode) {}
2801 PRE_SYSCALL(fchownat)
2802 (long dfd, const void *filename, long user, long group, long flag) {
2805 __sanitizer::internal_strlen((const char *)filename) + 1);
2808 POST_SYSCALL(fchownat)
2809 (long res, long dfd, const void *filename, long user, long group, long flag) {}
2811 PRE_SYSCALL(openat)(long dfd, const void *filename, long flags, long mode) {
2814 __sanitizer::internal_strlen((const char *)filename) + 1);
2817 POST_SYSCALL(openat)
2818 (long res, long dfd, const void *filename, long flags, long mode) {}
2820 PRE_SYSCALL(newfstatat)
2821 (long dfd, const void *filename, void *statbuf, long flag) {
2824 __sanitizer::internal_strlen((const char *)filename) + 1);
2827 POST_SYSCALL(newfstatat)
2828 (long res, long dfd, const void *filename, void *statbuf, long flag) {
2831 POST_WRITE(statbuf, struct_kernel_stat_sz);
2835 PRE_SYSCALL(fstatat64)
2836 (long dfd, const void *filename, void *statbuf, long flag) {
2839 __sanitizer::internal_strlen((const char *)filename) + 1);
2842 POST_SYSCALL(fstatat64)
2843 (long res, long dfd, const void *filename, void *statbuf, long flag) {
2846 POST_WRITE(statbuf, struct_kernel_stat64_sz);
2850 PRE_SYSCALL(readlinkat)(long dfd, const void *path, void *buf, long bufsiz) {
2852 PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
2855 POST_SYSCALL(readlinkat)
2856 (long res, long dfd, const void *path, void *buf, long bufsiz) {
2859 POST_WRITE(buf, __sanitizer::internal_strlen((const char *)buf) + 1);
2863 PRE_SYSCALL(utimensat)
2864 (long dfd, const void *filename, void *utimes, long flags) {
2867 __sanitizer::internal_strlen((const char *)filename) + 1);
2870 POST_SYSCALL(utimensat)
2871 (long res, long dfd, const void *filename, void *utimes, long flags) {
2874 POST_WRITE(utimes, struct_timespec_sz);
2878 PRE_SYSCALL(unshare)(long unshare_flags) {}
2880 POST_SYSCALL(unshare)(long res, long unshare_flags) {}
2883 (long fd_in, void *off_in, long fd_out, void *off_out, long len, long flags) {}
2885 POST_SYSCALL(splice)
2886 (long res, long fd_in, void *off_in, long fd_out, void *off_out, long len,
2890 POST_WRITE(off_in, sizeof(long long));
2892 POST_WRITE(off_out, sizeof(long long));
2896 PRE_SYSCALL(vmsplice)
2897 (long fd, const __sanitizer_iovec *iov, long nr_segs, long flags) {}
2899 POST_SYSCALL(vmsplice)
2900 (long res, long fd, const __sanitizer_iovec *iov, long nr_segs, long flags) {
2903 kernel_read_iovec(iov, nr_segs, res);
2907 PRE_SYSCALL(tee)(long fdin, long fdout, long len, long flags) {}
2909 POST_SYSCALL(tee)(long res, long fdin, long fdout, long len, long flags) {}
2911 PRE_SYSCALL(get_robust_list)(long pid, void *head_ptr, void *len_ptr) {}
2913 POST_SYSCALL(get_robust_list)
2914 (long res, long pid, void *head_ptr, void *len_ptr) {}
2916 PRE_SYSCALL(set_robust_list)(void *head, long len) {}
2918 POST_SYSCALL(set_robust_list)(long res, void *head, long len) {}
2920 PRE_SYSCALL(getcpu)(void *cpu, void *node, void *cache) {}
2922 POST_SYSCALL(getcpu)(long res, void *cpu, void *node, void *cache) {
2925 POST_WRITE(cpu, sizeof(unsigned));
2927 POST_WRITE(node, sizeof(unsigned));
2928 // The third argument to this system call is nowadays unused.
2932 PRE_SYSCALL(signalfd)(long ufd, void *user_mask, long sizemask) {}
2934 POST_SYSCALL(signalfd)
2935 (long res, long ufd, kernel_sigset_t *user_mask, long sizemask) {
2938 POST_WRITE(user_mask, sizemask);
2942 PRE_SYSCALL(signalfd4)(long ufd, void *user_mask, long sizemask, long flags) {}
2944 POST_SYSCALL(signalfd4)
2945 (long res, long ufd, kernel_sigset_t *user_mask, long sizemask, long flags) {
2948 POST_WRITE(user_mask, sizemask);
2952 PRE_SYSCALL(timerfd_create)(long clockid, long flags) {}
2954 POST_SYSCALL(timerfd_create)(long res, long clockid, long flags) {}
2956 PRE_SYSCALL(timerfd_settime)
2957 (long ufd, long flags, const void *utmr, void *otmr) {
2959 PRE_READ(utmr, struct_itimerspec_sz);
2962 POST_SYSCALL(timerfd_settime)
2963 (long res, long ufd, long flags, const void *utmr, void *otmr) {
2966 POST_WRITE(otmr, struct_itimerspec_sz);
2970 PRE_SYSCALL(timerfd_gettime)(long ufd, void *otmr) {}
2972 POST_SYSCALL(timerfd_gettime)(long res, long ufd, void *otmr) {
2975 POST_WRITE(otmr, struct_itimerspec_sz);
2979 PRE_SYSCALL(eventfd)(long count) {}
2981 POST_SYSCALL(eventfd)(long res, long count) {}
2983 PRE_SYSCALL(eventfd2)(long count, long flags) {}
2985 POST_SYSCALL(eventfd2)(long res, long count, long flags) {}
2987 PRE_SYSCALL(old_readdir)(long arg0, void *arg1, long arg2) {}
2989 POST_SYSCALL(old_readdir)(long res, long arg0, void *arg1, long arg2) {
2990 // Missing definition of 'struct old_linux_dirent'.
2993 PRE_SYSCALL(pselect6)
2994 (long arg0, __sanitizer___kernel_fd_set *arg1,
2995 __sanitizer___kernel_fd_set *arg2, __sanitizer___kernel_fd_set *arg3,
2996 void *arg4, void *arg5) {}
2998 POST_SYSCALL(pselect6)
2999 (long res, long arg0, __sanitizer___kernel_fd_set *arg1,
3000 __sanitizer___kernel_fd_set *arg2, __sanitizer___kernel_fd_set *arg3,
3001 void *arg4, void *arg5) {
3004 POST_WRITE(arg1, sizeof(*arg1));
3006 POST_WRITE(arg2, sizeof(*arg2));
3008 POST_WRITE(arg3, sizeof(*arg3));
3010 POST_WRITE(arg4, struct_timespec_sz);
3015 (__sanitizer_pollfd *arg0, long arg1, void *arg2, const kernel_sigset_t *arg3,
3018 PRE_READ(arg3, arg4);
3022 (long res, __sanitizer_pollfd *arg0, long arg1, void *arg2, const void *arg3,
3026 POST_WRITE(arg0, sizeof(*arg0));
3028 POST_WRITE(arg2, struct_timespec_sz);
3032 PRE_SYSCALL(syncfs)(long fd) {}
3034 POST_SYSCALL(syncfs)(long res, long fd) {}
3036 PRE_SYSCALL(perf_event_open)
3037 (__sanitizer_perf_event_attr *attr_uptr, long pid, long cpu, long group_fd,
3040 PRE_READ(attr_uptr, attr_uptr->size);
3043 POST_SYSCALL(perf_event_open)
3044 (long res, __sanitizer_perf_event_attr *attr_uptr, long pid, long cpu,
3045 long group_fd, long flags) {}
3047 PRE_SYSCALL(mmap_pgoff)
3048 (long addr, long len, long prot, long flags, long fd, long pgoff) {}
3050 POST_SYSCALL(mmap_pgoff)
3051 (long res, long addr, long len, long prot, long flags, long fd, long pgoff) {}
3053 PRE_SYSCALL(old_mmap)(void *arg) {}
3055 POST_SYSCALL(old_mmap)(long res, void *arg) {}
3057 PRE_SYSCALL(name_to_handle_at)
3058 (long dfd, const void *name, void *handle, void *mnt_id, long flag) {}
3060 POST_SYSCALL(name_to_handle_at)
3061 (long res, long dfd, const void *name, void *handle, void *mnt_id, long flag) {}
3063 PRE_SYSCALL(open_by_handle_at)(long mountdirfd, void *handle, long flags) {}
3065 POST_SYSCALL(open_by_handle_at)
3066 (long res, long mountdirfd, void *handle, long flags) {}
3068 PRE_SYSCALL(setns)(long fd, long nstype) {}
3070 POST_SYSCALL(setns)(long res, long fd, long nstype) {}
3072 PRE_SYSCALL(process_vm_readv)
3073 (long pid, const __sanitizer_iovec *lvec, long liovcnt, const void *rvec,
3074 long riovcnt, long flags) {}
3076 POST_SYSCALL(process_vm_readv)
3077 (long res, long pid, const __sanitizer_iovec *lvec, long liovcnt,
3078 const void *rvec, long riovcnt, long flags) {
3081 kernel_write_iovec(lvec, liovcnt, res);
3085 PRE_SYSCALL(process_vm_writev)
3086 (long pid, const __sanitizer_iovec *lvec, long liovcnt, const void *rvec,
3087 long riovcnt, long flags) {}
3089 POST_SYSCALL(process_vm_writev)
3090 (long res, long pid, const __sanitizer_iovec *lvec, long liovcnt,
3091 const void *rvec, long riovcnt, long flags) {
3094 kernel_read_iovec(lvec, liovcnt, res);
3098 PRE_SYSCALL(fork)() { COMMON_SYSCALL_PRE_FORK(); }
3100 POST_SYSCALL(fork)(long res) { COMMON_SYSCALL_POST_FORK(res); }
3102 PRE_SYSCALL(vfork)() { COMMON_SYSCALL_PRE_FORK(); }
3104 POST_SYSCALL(vfork)(long res) { COMMON_SYSCALL_POST_FORK(res); }
3106 PRE_SYSCALL(sigaction)
3107 (long signum, const __sanitizer_kernel_sigaction_t *act,
3108 __sanitizer_kernel_sigaction_t *oldact) {
3110 PRE_READ(&act->sigaction, sizeof(act->sigaction));
3111 PRE_READ(&act->sa_flags, sizeof(act->sa_flags));
3112 PRE_READ(&act->sa_mask, sizeof(act->sa_mask));
3116 POST_SYSCALL(sigaction)
3117 (long res, long signum, const __sanitizer_kernel_sigaction_t *act,
3118 __sanitizer_kernel_sigaction_t *oldact) {
3119 if (res >= 0 && oldact)
3120 POST_WRITE(oldact, sizeof(*oldact));
3123 PRE_SYSCALL(rt_sigaction)
3124 (long signum, const __sanitizer_kernel_sigaction_t *act,
3125 __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) {
3127 PRE_READ(&act->sigaction, sizeof(act->sigaction));
3128 PRE_READ(&act->sa_flags, sizeof(act->sa_flags));
3129 PRE_READ(&act->sa_mask, sz);
3133 POST_SYSCALL(rt_sigaction)
3134 (long res, long signum, const __sanitizer_kernel_sigaction_t *act,
3135 __sanitizer_kernel_sigaction_t *oldact, SIZE_T sz) {
3136 if (res >= 0 && oldact) {
3137 SIZE_T oldact_sz = ((char *)&oldact->sa_mask) - ((char *)oldact) + sz;
3138 POST_WRITE(oldact, oldact_sz);
3142 PRE_SYSCALL(getrandom)(void *buf, uptr count, long flags) {
3144 PRE_WRITE(buf, count);
3148 POST_SYSCALL(getrandom)(long res, void *buf, uptr count, long flags) {
3149 if (res > 0 && buf) {
3150 POST_WRITE(buf, res);
3154 PRE_SYSCALL(sigaltstack)(const void *ss, void *oss) {
3155 if (ss != nullptr) {
3156 PRE_READ(ss, struct_stack_t_sz);
3158 if (oss != nullptr) {
3159 PRE_WRITE(oss, struct_stack_t_sz);
3163 POST_SYSCALL(sigaltstack)(long res, void *ss, void *oss) {
3165 if (oss != nullptr) {
3166 POST_WRITE(oss, struct_stack_t_sz);
3175 # undef POST_SYSCALL
3179 #endif // SANITIZER_LINUX