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