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