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