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