1#!/usr/bin/awk -f 2 3#===-- generate_netbsd_syscalls.awk ----------------------------------------===# 4# 5# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 6# See https://llvm.org/LICENSE.txt for license information. 7# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8# 9#===------------------------------------------------------------------------===# 10# 11# This file is a generator of: 12# - include/sanitizer/netbsd_syscall_hooks.h 13# - lib/sanitizer_common/sanitizer_syscalls_netbsd.inc 14# 15# This script accepts on the input syscalls.master by default located in the 16# /usr/src/sys/kern/syscalls.master path in the NetBSD distribution. 17# 18# This script shall be executed only on the newest NetBSD version. 19# This script will emit compat code for the older releases. 20# 21# NetBSD minimal version supported 9.0. 22# NetBSD current version supported 9.99.17. 23# 24#===------------------------------------------------------------------------===# 25 26BEGIN { 27 # harcode the script name 28 script_name = "generate_netbsd_syscalls.awk" 29 outputh = "../include/sanitizer/netbsd_syscall_hooks.h" 30 outputinc = "../lib/sanitizer_common/sanitizer_syscalls_netbsd.inc" 31 32 # assert that we are in the directory with scripts 33 in_utils = system("test -f " script_name " && exit 1 || exit 0") 34 if (in_utils == 0) { 35 usage() 36 } 37 38 # assert 1 argument passed 39 if (ARGC != 2) { 40 usage() 41 } 42 43 # assert argument is a valid file path to syscall.master 44 if (system("test -f " ARGV[1]) != 0) { 45 usage() 46 } 47 48 # sanity check that the path ends with "syscall.master" 49 if (ARGV[1] !~ /syscalls\.master$/) { 50 usage() 51 } 52 53 # accept overloading CLANGFORMAT from environment 54 clangformat = "clang-format" 55 if ("CLANGFORMAT" in ENVIRON) { 56 clangformat = ENVIRON["CLANGFORMAT"] 57 } 58 59 # parsing specific symbols 60 parsingheader=1 61 62 parsedsyscalls=0 63 64 # Hardcoded in algorithm 65 SYS_MAXSYSARGS=8 66} 67 68# Parse the RCS ID from syscall.master 69parsingheader == 1 && NR == 1 { 70 if (match($0, /\$[^$]+\$/)) { 71 # trim initial 'NetBSD: ' and trailing ' $' 72 syscallmasterversion = substr($0, RSTART + 9, RLENGTH - 11) 73 } else { 74 # wrong file? 75 usage() 76 } 77} 78 79# skip the following lines 80# - empty 81NF == 0 { 82 next 83} 84# - comment 85$1 == ";" { 86 next 87} 88 89# separator between the header and table with syscalls 90$0 == "%%" { 91 parsingheader = 0 92 next 93} 94 95# preserve 'if/elif/else/endif' C preprocessor as-is 96parsingheader == 0 && $0 ~ /^#/ { 97 if (parsedsyscalls in ifelifelseendif) { 98 ifelifelseendif[parsedsyscalls] = ifelifelseendif[parsedsyscalls] "\n" $0 99 } else { 100 ifelifelseendif[parsedsyscalls] = $0 101 } 102 next 103} 104 105# parsing of syscall definitions 106parsingheader == 0 && $1 ~ /^[0-9]+$/ { 107 # first join multiple lines into single one 108 while (sub(/\\$/, "")) { 109 getline line 110 $0 = $0 "" line 111 } 112 113 # Skip unwanted syscalls 114 skip=0 115 if ($0 ~ /OBSOL/ || $0 ~ /EXCL/ || $0 ~ /UNIMPL/) { 116 skip=1 117 } 118 119 # Compose the syscall name 120 # - compat? 121 compat="" 122 if (match($0, /COMPAT_[0-9]+/)) { 123 compat = tolower(substr($0, RSTART, RLENGTH)) 124 } 125 # - alias name? 126 alias="" 127 if ($(NF) != "}" && !skip) { 128 alias = alias "" $(NF) 129 } 130 # - compat version? 131 compatver="" 132 if (match($0, /\|[0-9]+\|/)) { 133 compatver = tolower(substr($0, RSTART + 1, RLENGTH - 2)) 134 } 135 # - basename? 136 basename="" 137 if (skip) { 138 basename = $1 139 } else { 140 if (match($0, /\|[_a-z0-9]+\(/)) { 141 basename = tolower(substr($0, RSTART + 1, RLENGTH - 2)) 142 } 143 } 144 145 syscallname="" 146 147 if (skip) { 148 syscallname= syscallname "$" 149 } 150 151 if (length(compat) > 0) { 152 syscallname = syscallname "" compat "_" 153 } 154 if (length(alias) > 0) { 155 syscallname = syscallname "" alias 156 } else { 157 if (length(compatver) > 0) { 158 syscallname = syscallname "__" basename "" compatver 159 } else { 160 syscallname = syscallname "" basename 161 } 162 } 163 164 # Store the syscallname 165 syscalls[parsedsyscalls]=syscallname 166 167 # Extract syscall arguments 168 if (match($0, /\([^)]+\)/)) { 169 args = substr($0, RSTART + 1, RLENGTH - 2) 170 171 if (args == "void") { 172 syscallargs[parsedsyscalls] = "void" 173 syscallfullargs[parsedsyscalls] = "void" 174 } else { 175 # Normalize 'type * argument' to 'type *argument' 176 gsub("\\*[ \t]+", "*", args) 177 178 n = split(args, a, ",") 179 180 # Handle the first argument 181 match(a[1], /[*_a-z0-9\[\]]+$/) 182 syscallfullargs[parsedsyscalls] = substr(a[1], RSTART) "_" 183 184 gsub(".+[ *]", "", a[1]) 185 syscallargs[parsedsyscalls] = a[1] 186 187 # Handle the rest of arguments 188 for (i = 2; i <= n; i++) { 189 match(a[i], /[*_a-zA-Z0-9\[\]]+$/) 190 fs = substr(a[i], RSTART) 191 if (fs ~ /\[/) { 192 sub(/\[/, "_[", fs) 193 } else { 194 fs = fs "_" 195 } 196 syscallfullargs[parsedsyscalls] = syscallfullargs[parsedsyscalls] "$" fs 197 gsub(".+[ *]", "", a[i]) 198 syscallargs[parsedsyscalls] = syscallargs[parsedsyscalls] "$" a[i] 199 } 200 201 # Handle array arguments for syscall(2) and __syscall(2) 202 nargs = "arg0$arg1$arg2$arg3$arg4$arg5$arg6$arg7" 203 gsub(/args\[SYS_MAXSYSARGS\]/, nargs, syscallargs[parsedsyscalls]) 204 } 205 } 206 207 parsedsyscalls++ 208 209 # Done with this line 210 next 211} 212 213 214END { 215 # empty file? 216 if (NR < 1 && !abnormal_exit) { 217 usage() 218 } 219 220 # Handle abnormal exit 221 if (abnormal_exit) { 222 exit(abnormal_exit) 223 } 224 225 # Generate sanitizer_syscalls_netbsd.inc 226 227 # open pipe 228 cmd = clangformat " > " outputh 229 230 pcmd("//===-- netbsd_syscall_hooks.h --------------------------------------------===//") 231 pcmd("//") 232 pcmd("// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.") 233 pcmd("// See https://llvm.org/LICENSE.txt for license information.") 234 pcmd("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception") 235 pcmd("//") 236 pcmd("//===----------------------------------------------------------------------===//") 237 pcmd("//") 238 pcmd("// This file is a part of public sanitizer interface.") 239 pcmd("//") 240 pcmd("// System call handlers.") 241 pcmd("//") 242 pcmd("// Interface methods declared in this header implement pre- and post- syscall") 243 pcmd("// actions for the active sanitizer.") 244 pcmd("// Usage:") 245 pcmd("// __sanitizer_syscall_pre_getfoo(...args...);") 246 pcmd("// long long res = syscall(SYS_getfoo, ...args...);") 247 pcmd("// __sanitizer_syscall_post_getfoo(res, ...args...);") 248 pcmd("//") 249 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!") 250 pcmd("//") 251 pcmd("// Generated with: " script_name) 252 pcmd("// Generated date: " strftime("%F")) 253 pcmd("// Generated from: " syscallmasterversion) 254 pcmd("//") 255 pcmd("//===----------------------------------------------------------------------===//") 256 pcmd("#ifndef SANITIZER_NETBSD_SYSCALL_HOOKS_H") 257 pcmd("#define SANITIZER_NETBSD_SYSCALL_HOOKS_H") 258 pcmd("") 259 260 for (i = 0; i < parsedsyscalls; i++) { 261 262 if (i in ifelifelseendif) { 263 pcmd(ifelifelseendif[i]) 264 } 265 266 sn = syscalls[i] 267 268 if (sn ~ /^\$/) { 269 pcmd("/* syscall " substr(sn,2) " has been skipped */") 270 continue 271 } 272 273 inargs = "" 274 275 if (syscallargs[i] != "void") { 276 inargs = syscallargs[i] 277 gsub(/\$/, ", ", inargs) 278 } 279 280 outargs = "" 281 282 if (syscallargs[i] != "void") { 283 outargs = "(long long)(" syscallargs[i] ")" 284 gsub(/\$/, "), (long long)(", outargs) 285 } 286 287 pcmd("#define __sanitizer_syscall_pre_" sn "(" inargs ") \\") 288 pcmd(" __sanitizer_syscall_pre_impl_" sn "(" outargs ")") 289 290 if (inargs == "") { 291 inargs = "res" 292 } else { 293 inargs = "res, " inargs 294 } 295 296 if (outargs == "") { 297 outargs = "res" 298 } else { 299 outargs = "res, " outargs 300 } 301 302 pcmd("#define __sanitizer_syscall_post_" sn "(" inargs ") \\") 303 pcmd(" __sanitizer_syscall_post_impl_" sn "(" outargs ")") 304 } 305 306 pcmd("") 307 pcmd("/* Compat with older releases */") 308 pcmd("#define __sanitizer_syscall_pre_getvfsstat __sanitizer_syscall_pre_compat_90_getvfsstat") 309 pcmd("#define __sanitizer_syscall_post_getvfsstat __sanitizer_syscall_post_compat_90_getvfsstat") 310 pcmd("") 311 pcmd("#define __sanitizer_syscall_pre_statvfs1 __sanitizer_syscall_pre_compat_90_statvfs1") 312 pcmd("#define __sanitizer_syscall_post_statvfs1 __sanitizer_syscall_post_compat_90_statvfs1") 313 pcmd("") 314 pcmd("#define __sanitizer_syscall_pre_fstatvfs1 __sanitizer_syscall_pre_compat_90_fstatvfs1") 315 pcmd("#define __sanitizer_syscall_post_fstatvfs1 __sanitizer_syscall_post_compat_90_fstatvfs1") 316 pcmd("") 317 pcmd("#define __sanitizer_syscall_pre___fhstatvfs140 __sanitizer_syscall_pre_compat_90_fhstatvfs1") 318 pcmd("#define __sanitizer_syscall_post___fhstatvfs140 __sanitizer_syscall_post_compat_90_fhstatvfs1") 319 320 pcmd("") 321 pcmd("#ifdef __cplusplus") 322 pcmd("extern \"C\" {") 323 pcmd("#endif") 324 pcmd("") 325 pcmd("// Private declarations. Do not call directly from user code. Use macros above.") 326 pcmd("") 327 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!") 328 pcmd("") 329 330 for (i = 0; i < parsedsyscalls; i++) { 331 332 if (i in ifelifelseendif) { 333 pcmd(ifelifelseendif[i]) 334 } 335 336 sn = syscalls[i] 337 338 if (sn ~ /^\$/) { 339 pcmd("/* syscall " substr(sn,2) " has been skipped */") 340 continue 341 } 342 343 preargs = syscallargs[i] 344 345 if (preargs != "void") { 346 preargs = "long long " preargs 347 gsub(/\$/, ", long long ", preargs) 348 } 349 350 if (preargs == "void") { 351 postargs = "long long res" 352 } else { 353 postargs = "long long res, " preargs 354 } 355 356 pcmd("void __sanitizer_syscall_pre_impl_" sn "(" preargs ");") 357 pcmd("void __sanitizer_syscall_post_impl_" sn "(" postargs ");") 358 } 359 360 pcmd("") 361 pcmd("#ifdef __cplusplus") 362 pcmd("} // extern \"C\"") 363 pcmd("#endif") 364 365 pcmd("") 366 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!") 367 pcmd("") 368 369 pcmd("#endif // SANITIZER_NETBSD_SYSCALL_HOOKS_H") 370 371 close(cmd) 372 373 # Generate sanitizer_syscalls_netbsd.inc 374 375 # open pipe 376 cmd = clangformat " > " outputinc 377 378 pcmd("//===-- sanitizer_syscalls_netbsd.inc ---------------------------*- C++ -*-===//") 379 pcmd("//") 380 pcmd("// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.") 381 pcmd("// See https://llvm.org/LICENSE.txt for license information.") 382 pcmd("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception") 383 pcmd("//") 384 pcmd("//===----------------------------------------------------------------------===//") 385 pcmd("//") 386 pcmd("// Common syscalls handlers for tools like AddressSanitizer,") 387 pcmd("// ThreadSanitizer, MemorySanitizer, etc.") 388 pcmd("//") 389 pcmd("// This file should be included into the tool's interceptor file,") 390 pcmd("// which has to define it's own macros:") 391 pcmd("// COMMON_SYSCALL_PRE_READ_RANGE") 392 pcmd("// Called in prehook for regions that will be read by the kernel and") 393 pcmd("// must be initialized.") 394 pcmd("// COMMON_SYSCALL_PRE_WRITE_RANGE") 395 pcmd("// Called in prehook for regions that will be written to by the kernel") 396 pcmd("// and must be addressable. The actual write range may be smaller than") 397 pcmd("// reported in the prehook. See POST_WRITE_RANGE.") 398 pcmd("// COMMON_SYSCALL_POST_READ_RANGE") 399 pcmd("// Called in posthook for regions that were read by the kernel. Does") 400 pcmd("// not make much sense.") 401 pcmd("// COMMON_SYSCALL_POST_WRITE_RANGE") 402 pcmd("// Called in posthook for regions that were written to by the kernel") 403 pcmd("// and are now initialized.") 404 pcmd("// COMMON_SYSCALL_ACQUIRE(addr)") 405 pcmd("// Acquire memory visibility from addr.") 406 pcmd("// COMMON_SYSCALL_RELEASE(addr)") 407 pcmd("// Release memory visibility to addr.") 408 pcmd("// COMMON_SYSCALL_FD_CLOSE(fd)") 409 pcmd("// Called before closing file descriptor fd.") 410 pcmd("// COMMON_SYSCALL_FD_ACQUIRE(fd)") 411 pcmd("// Acquire memory visibility from fd.") 412 pcmd("// COMMON_SYSCALL_FD_RELEASE(fd)") 413 pcmd("// Release memory visibility to fd.") 414 pcmd("// COMMON_SYSCALL_PRE_FORK()") 415 pcmd("// Called before fork syscall.") 416 pcmd("// COMMON_SYSCALL_POST_FORK(long long res)") 417 pcmd("// Called after fork syscall.") 418 pcmd("//") 419 pcmd("// DO NOT EDIT! THIS FILE HAS BEEN GENERATED!") 420 pcmd("//") 421 pcmd("// Generated with: " script_name) 422 pcmd("// Generated date: " strftime("%F")) 423 pcmd("// Generated from: " syscallmasterversion) 424 pcmd("//") 425 pcmd("//===----------------------------------------------------------------------===//") 426 pcmd("") 427 pcmd("#include \"sanitizer_platform.h\"") 428 pcmd("#if SANITIZER_NETBSD") 429 pcmd("") 430 pcmd("#include \"sanitizer_libc.h\"") 431 pcmd("") 432 pcmd("#define PRE_SYSCALL(name) \\") 433 pcmd(" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name") 434 pcmd("#define PRE_READ(p, s) COMMON_SYSCALL_PRE_READ_RANGE(p, s)") 435 pcmd("#define PRE_WRITE(p, s) COMMON_SYSCALL_PRE_WRITE_RANGE(p, s)") 436 pcmd("") 437 pcmd("#define POST_SYSCALL(name) \\") 438 pcmd(" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_post_impl_##name") 439 pcmd("#define POST_READ(p, s) COMMON_SYSCALL_POST_READ_RANGE(p, s)") 440 pcmd("#define POST_WRITE(p, s) COMMON_SYSCALL_POST_WRITE_RANGE(p, s)") 441 pcmd("") 442 pcmd("#ifndef COMMON_SYSCALL_ACQUIRE") 443 pcmd("# define COMMON_SYSCALL_ACQUIRE(addr) ((void)(addr))") 444 pcmd("#endif") 445 pcmd("") 446 pcmd("#ifndef COMMON_SYSCALL_RELEASE") 447 pcmd("# define COMMON_SYSCALL_RELEASE(addr) ((void)(addr))") 448 pcmd("#endif") 449 pcmd("") 450 pcmd("#ifndef COMMON_SYSCALL_FD_CLOSE") 451 pcmd("# define COMMON_SYSCALL_FD_CLOSE(fd) ((void)(fd))") 452 pcmd("#endif") 453 pcmd("") 454 pcmd("#ifndef COMMON_SYSCALL_FD_ACQUIRE") 455 pcmd("# define COMMON_SYSCALL_FD_ACQUIRE(fd) ((void)(fd))") 456 pcmd("#endif") 457 pcmd("") 458 pcmd("#ifndef COMMON_SYSCALL_FD_RELEASE") 459 pcmd("# define COMMON_SYSCALL_FD_RELEASE(fd) ((void)(fd))") 460 pcmd("#endif") 461 pcmd("") 462 pcmd("#ifndef COMMON_SYSCALL_PRE_FORK") 463 pcmd("# define COMMON_SYSCALL_PRE_FORK() {}") 464 pcmd("#endif") 465 pcmd("") 466 pcmd("#ifndef COMMON_SYSCALL_POST_FORK") 467 pcmd("# define COMMON_SYSCALL_POST_FORK(res) {}") 468 pcmd("#endif") 469 pcmd("") 470 pcmd("// FIXME: do some kind of PRE_READ for all syscall arguments (int(s) and such).") 471 pcmd("") 472 pcmd("extern \"C\" {") 473 pcmd("#define SYS_MAXSYSARGS " SYS_MAXSYSARGS) 474 475 for (i = 0; i < parsedsyscalls; i++) { 476 477 if (i in ifelifelseendif) { 478 pcmd(ifelifelseendif[i]) 479 } 480 481 sn = syscalls[i] 482 483 if (sn ~ /^\$/) { 484 pcmd("/* syscall " substr(sn,2) " has been skipped */") 485 continue 486 } 487 488 preargs = syscallfullargs[i] 489 490 if (preargs != "void") { 491 preargs = "long long " preargs 492 gsub(/\$/, ", long long ", preargs) 493 gsub(/long long \*/, "void *", preargs) 494 } 495 496 if (preargs == "void") { 497 postargs = "long long res" 498 } else { 499 postargs = "long long res, " preargs 500 } 501 502 pcmd("PRE_SYSCALL(" sn ")(" preargs ")") 503 pcmd("{") 504 syscall_body(sn, "pre") 505 pcmd("}") 506 507 pcmd("POST_SYSCALL(" sn ")(" postargs ")") 508 pcmd("{") 509 syscall_body(sn, "post") 510 pcmd("}") 511 } 512 513 pcmd("#undef SYS_MAXSYSARGS") 514 pcmd("} // extern \"C\"") 515 pcmd("") 516 pcmd("#undef PRE_SYSCALL") 517 pcmd("#undef PRE_READ") 518 pcmd("#undef PRE_WRITE") 519 pcmd("#undef POST_SYSCALL") 520 pcmd("#undef POST_READ") 521 pcmd("#undef POST_WRITE") 522 pcmd("") 523 pcmd("#endif // SANITIZER_NETBSD") 524 525 close(cmd) 526 527 # Hack for preprocessed code 528 system("sed -i 's,^ \\([^ ]\\), \\1,' " outputinc) 529} 530 531function usage() 532{ 533 print "Usage: " script_name " syscalls.master" 534 abnormal_exit = 1 535 exit 1 536} 537 538function pcmd(string) 539{ 540 print string | cmd 541} 542 543function syscall_body(syscall, mode) 544{ 545 # Hardcode sanitizing rules here 546 # These syscalls don't change often so they are hand coded 547 if (syscall == "syscall") { 548 pcmd("/* Nothing to do */") 549 } else if (syscall == "exit") { 550 pcmd("/* Nothing to do */") 551 } else if (syscall == "fork") { 552 if (mode == "pre") { 553 pcmd("COMMON_SYSCALL_PRE_FORK();") 554 } else { 555 pcmd("COMMON_SYSCALL_POST_FORK(res);") 556 } 557 } else if (syscall == "read") { 558 if (mode == "pre") { 559 pcmd("if (buf_) {") 560 pcmd(" PRE_WRITE(buf_, nbyte_);") 561 pcmd("}") 562 } else { 563 pcmd("if (res > 0) {") 564 pcmd(" POST_WRITE(buf_, res);") 565 pcmd("}") 566 } 567 } else if (syscall == "write") { 568 if (mode == "pre") { 569 pcmd("if (buf_) {") 570 pcmd(" PRE_READ(buf_, nbyte_);") 571 pcmd("}") 572 } else { 573 pcmd("if (res > 0) {") 574 pcmd(" POST_READ(buf_, res);") 575 pcmd("}") 576 } 577 } else if (syscall == "open") { 578 if (mode == "pre") { 579 pcmd("const char *path = (const char *)path_;") 580 pcmd("if (path) {") 581 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 582 pcmd("}") 583 } else { 584 pcmd("if (res > 0) {") 585 pcmd(" const char *path = (const char *)path_;") 586 pcmd(" if (path) {") 587 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 588 pcmd(" }") 589 pcmd("}") 590 } 591 } else if (syscall == "close") { 592 if (mode == "pre") { 593 pcmd("COMMON_SYSCALL_FD_CLOSE((int)fd_);") 594 } else { 595 pcmd("/* Nothing to do */") 596 } 597 } else if (syscall == "compat_50_wait4") { 598 pcmd("/* TODO */") 599 } else if (syscall == "compat_43_ocreat") { 600 pcmd("/* TODO */") 601 } else if (syscall == "link") { 602 if (mode == "pre") { 603 pcmd("const char *path = (const char *)path_;") 604 pcmd("const char *link = (const char *)link_;") 605 pcmd("if (path) {") 606 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 607 pcmd("}") 608 pcmd("if (link) {") 609 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(link) + 1);") 610 pcmd("}") 611 } else { 612 pcmd("if (res == 0) {") 613 pcmd(" const char *path = (const char *)path_;") 614 pcmd(" const char *link = (const char *)link_;") 615 pcmd(" if (path) {") 616 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 617 pcmd(" }") 618 pcmd(" if (link) {") 619 pcmd(" POST_READ(path, __sanitizer::internal_strlen(link) + 1);") 620 pcmd(" }") 621 pcmd("}") 622 } 623 } else if (syscall == "unlink") { 624 if (mode == "pre") { 625 pcmd("const char *path = (const char *)path_;") 626 pcmd("if (path) {") 627 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 628 pcmd("}") 629 } else { 630 pcmd("if (res == 0) {") 631 pcmd(" const char *path = (const char *)path_;") 632 pcmd(" if (path) {") 633 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 634 pcmd(" }") 635 pcmd("}") 636 } 637 } else if (syscall == "chdir") { 638 if (mode == "pre") { 639 pcmd("const char *path = (const char *)path_;") 640 pcmd("if (path) {") 641 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 642 pcmd("}") 643 } else { 644 pcmd("if (res == 0) {") 645 pcmd(" const char *path = (const char *)path_;") 646 pcmd(" if (path) {") 647 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 648 pcmd(" }") 649 pcmd("}") 650 } 651 } else if (syscall == "fchdir") { 652 pcmd("/* Nothing to do */") 653 } else if (syscall == "compat_50_mknod") { 654 pcmd("/* TODO */") 655 } else if (syscall == "chmod") { 656 if (mode == "pre") { 657 pcmd("const char *path = (const char *)path_;") 658 pcmd("if (path) {") 659 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 660 pcmd("}") 661 } else { 662 pcmd("if (res == 0) {") 663 pcmd(" const char *path = (const char *)path_;") 664 pcmd(" if (path) {") 665 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 666 pcmd(" }") 667 pcmd("}") 668 } 669 } else if (syscall == "chown") { 670 if (mode == "pre") { 671 pcmd("const char *path = (const char *)path_;") 672 pcmd("if (path) {") 673 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 674 pcmd("}") 675 } else { 676 pcmd("if (res == 0) {") 677 pcmd(" const char *path = (const char *)path_;") 678 pcmd(" if (path) {") 679 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 680 pcmd(" }") 681 pcmd("}") 682 } 683 } else if (syscall == "break") { 684 pcmd("/* Nothing to do */") 685 } else if (syscall == "compat_20_getfsstat") { 686 pcmd("/* TODO */") 687 } else if (syscall == "compat_43_olseek") { 688 pcmd("/* TODO */") 689 } else if (syscall == "getpid") { 690 pcmd("/* Nothing to do */") 691 } else if (syscall == "compat_40_mount") { 692 pcmd("/* TODO */") 693 } else if (syscall == "unmount") { 694 if (mode == "pre") { 695 pcmd("const char *path = (const char *)path_;") 696 pcmd("if (path) {") 697 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 698 pcmd("}") 699 } else { 700 pcmd("if (res == 0) {") 701 pcmd(" const char *path = (const char *)path_;") 702 pcmd(" if (path) {") 703 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 704 pcmd(" }") 705 pcmd("}") 706 } 707 } else if (syscall == "setuid") { 708 pcmd("/* Nothing to do */") 709 } else if (syscall == "getuid") { 710 pcmd("/* Nothing to do */") 711 } else if (syscall == "geteuid") { 712 pcmd("/* Nothing to do */") 713 } else if (syscall == "ptrace") { 714 if (mode == "pre") { 715 pcmd("if (req_ == ptrace_pt_io) {") 716 pcmd(" struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;") 717 pcmd(" PRE_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);") 718 pcmd(" if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {") 719 pcmd(" PRE_READ(addr->piod_addr, addr->piod_len);") 720 pcmd(" }") 721 pcmd(" if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {") 722 pcmd(" PRE_WRITE(addr->piod_addr, addr->piod_len);") 723 pcmd(" }") 724 pcmd("} else if (req_ == ptrace_pt_lwpinfo) {") 725 pcmd(" struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;") 726 pcmd(" PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 727 pcmd(" PRE_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);") 728 pcmd("} else if (req_ == ptrace_pt_set_event_mask) {") 729 pcmd(" PRE_READ(addr_, struct_ptrace_ptrace_event_struct_sz);") 730 pcmd("} else if (req_ == ptrace_pt_get_event_mask) {") 731 pcmd(" PRE_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);") 732 pcmd("} else if (req_ == ptrace_pt_set_siginfo) {") 733 pcmd(" PRE_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 734 pcmd("} else if (req_ == ptrace_pt_get_siginfo) {") 735 pcmd(" PRE_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 736 pcmd("} else if (req_ == ptrace_pt_setregs) {") 737 pcmd(" PRE_READ(addr_, struct_ptrace_reg_struct_sz);") 738 pcmd("} else if (req_ == ptrace_pt_getregs) {") 739 pcmd(" PRE_WRITE(addr_, struct_ptrace_reg_struct_sz);") 740 pcmd("} else if (req_ == ptrace_pt_setfpregs) {") 741 pcmd(" PRE_READ(addr_, struct_ptrace_fpreg_struct_sz);") 742 pcmd("} else if (req_ == ptrace_pt_getfpregs) {") 743 pcmd(" PRE_WRITE(addr_, struct_ptrace_fpreg_struct_sz);") 744 pcmd("} else if (req_ == ptrace_pt_setdbregs) {") 745 pcmd(" PRE_READ(addr_, struct_ptrace_dbreg_struct_sz);") 746 pcmd("} else if (req_ == ptrace_pt_getdbregs) {") 747 pcmd(" PRE_WRITE(addr_, struct_ptrace_dbreg_struct_sz);") 748 pcmd("}") 749 } else { 750 pcmd("if (res == 0) {") 751 pcmd(" if (req_ == ptrace_pt_io) {") 752 pcmd(" struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;") 753 pcmd(" POST_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);") 754 pcmd(" if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {") 755 pcmd(" POST_READ(addr->piod_addr, addr->piod_len);") 756 pcmd(" }") 757 pcmd(" if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {") 758 pcmd(" POST_WRITE(addr->piod_addr, addr->piod_len);") 759 pcmd(" }") 760 pcmd(" } else if (req_ == ptrace_pt_lwpinfo) {") 761 pcmd(" struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;") 762 pcmd(" POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 763 pcmd(" POST_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);") 764 pcmd(" } else if (req_ == ptrace_pt_set_event_mask) {") 765 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_event_struct_sz);") 766 pcmd(" } else if (req_ == ptrace_pt_get_event_mask) {") 767 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);") 768 pcmd(" } else if (req_ == ptrace_pt_set_siginfo) {") 769 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 770 pcmd(" } else if (req_ == ptrace_pt_get_siginfo) {") 771 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 772 pcmd(" } else if (req_ == ptrace_pt_setregs) {") 773 pcmd(" POST_READ(addr_, struct_ptrace_reg_struct_sz);") 774 pcmd(" } else if (req_ == ptrace_pt_getregs) {") 775 pcmd(" POST_WRITE(addr_, struct_ptrace_reg_struct_sz);") 776 pcmd(" } else if (req_ == ptrace_pt_setfpregs) {") 777 pcmd(" POST_READ(addr_, struct_ptrace_fpreg_struct_sz);") 778 pcmd(" } else if (req_ == ptrace_pt_getfpregs) {") 779 pcmd(" POST_WRITE(addr_, struct_ptrace_fpreg_struct_sz);") 780 pcmd(" } else if (req_ == ptrace_pt_setdbregs) {") 781 pcmd(" POST_READ(addr_, struct_ptrace_dbreg_struct_sz);") 782 pcmd(" } else if (req_ == ptrace_pt_getdbregs) {") 783 pcmd(" POST_WRITE(addr_, struct_ptrace_dbreg_struct_sz);") 784 pcmd(" }") 785 pcmd("}") 786 } 787 } else if (syscall == "recvmsg") { 788 if (mode == "pre") { 789 pcmd("PRE_WRITE(msg_, sizeof(__sanitizer_msghdr));") 790 } else { 791 pcmd("if (res > 0) {") 792 pcmd(" POST_WRITE(msg_, sizeof(__sanitizer_msghdr));") 793 pcmd("}") 794 } 795 } else if (syscall == "sendmsg") { 796 if (mode == "pre") { 797 pcmd("PRE_READ(msg_, sizeof(__sanitizer_msghdr));") 798 } else { 799 pcmd("if (res > 0) {") 800 pcmd(" POST_READ(msg_, sizeof(__sanitizer_msghdr));") 801 pcmd("}") 802 } 803 } else if (syscall == "recvfrom") { 804 if (mode == "pre") { 805 pcmd("PRE_WRITE(buf_, len_);") 806 pcmd("PRE_WRITE(from_, struct_sockaddr_sz);") 807 pcmd("PRE_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));") 808 } else { 809 pcmd("if (res >= 0) {") 810 pcmd(" POST_WRITE(buf_, res);") 811 pcmd(" POST_WRITE(from_, struct_sockaddr_sz);") 812 pcmd(" POST_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));") 813 pcmd("}") 814 } 815 } else if (syscall == "accept") { 816 if (mode == "pre") { 817 pcmd("PRE_WRITE(name_, struct_sockaddr_sz);") 818 pcmd("PRE_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));") 819 } else { 820 pcmd("if (res == 0) {") 821 pcmd(" POST_WRITE(name_, struct_sockaddr_sz);") 822 pcmd(" POST_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));") 823 pcmd("}") 824 } 825 } else if (syscall == "getpeername") { 826 if (mode == "pre") { 827 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);") 828 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 829 } else { 830 pcmd("if (res == 0) {") 831 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);") 832 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 833 pcmd("}") 834 } 835 } else if (syscall == "getsockname") { 836 if (mode == "pre") { 837 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);") 838 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 839 } else { 840 pcmd("if (res == 0) {") 841 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);") 842 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 843 pcmd("}") 844 } 845 } else if (syscall == "access") { 846 if (mode == "pre") { 847 pcmd("const char *path = (const char *)path_;") 848 pcmd("if (path) {") 849 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 850 pcmd("}") 851 } else { 852 pcmd("if (res == 0) {") 853 pcmd(" const char *path = (const char *)path_;") 854 pcmd(" if (path) {") 855 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 856 pcmd(" }") 857 pcmd("}") 858 } 859 } else if (syscall == "chflags") { 860 if (mode == "pre") { 861 pcmd("const char *path = (const char *)path_;") 862 pcmd("if (path) {") 863 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 864 pcmd("}") 865 } else { 866 pcmd("if (res == 0) {") 867 pcmd(" const char *path = (const char *)path_;") 868 pcmd(" if (path) {") 869 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 870 pcmd(" }") 871 pcmd("}") 872 } 873 } else if (syscall == "fchflags") { 874 pcmd("/* Nothing to do */") 875 } else if (syscall == "sync") { 876 pcmd("/* Nothing to do */") 877 } else if (syscall == "kill") { 878 pcmd("/* Nothing to do */") 879 } else if (syscall == "compat_43_stat43") { 880 pcmd("/* TODO */") 881 } else if (syscall == "getppid") { 882 pcmd("/* Nothing to do */") 883 } else if (syscall == "compat_43_lstat43") { 884 pcmd("/* TODO */") 885 } else if (syscall == "dup") { 886 pcmd("/* Nothing to do */") 887 } else if (syscall == "pipe") { 888 pcmd("/* pipe returns two descriptors through two returned values */") 889 } else if (syscall == "getegid") { 890 pcmd("/* Nothing to do */") 891 } else if (syscall == "profil") { 892 if (mode == "pre") { 893 pcmd("if (samples_) {") 894 pcmd(" PRE_WRITE(samples_, size_);") 895 pcmd("}") 896 } else { 897 pcmd("if (res == 0) {") 898 pcmd(" if (samples_) {") 899 pcmd(" POST_WRITE(samples_, size_);") 900 pcmd(" }") 901 pcmd("}") 902 } 903 } else if (syscall == "ktrace") { 904 if (mode == "pre") { 905 pcmd("const char *fname = (const char *)fname_;") 906 pcmd("if (fname) {") 907 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 908 pcmd("}") 909 } else { 910 pcmd("const char *fname = (const char *)fname_;") 911 pcmd("if (res == 0) {") 912 pcmd(" if (fname) {") 913 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 914 pcmd(" }") 915 pcmd("}") 916 } 917 } else if (syscall == "compat_13_sigaction13") { 918 pcmd("/* TODO */") 919 } else if (syscall == "getgid") { 920 pcmd("/* Nothing to do */") 921 } else if (syscall == "compat_13_sigprocmask13") { 922 pcmd("/* TODO */") 923 } else if (syscall == "__getlogin") { 924 if (mode == "pre") { 925 pcmd("if (namebuf_) {") 926 pcmd(" PRE_WRITE(namebuf_, namelen_);") 927 pcmd("}") 928 } else { 929 pcmd("if (res == 0) {") 930 pcmd(" if (namebuf_) {") 931 pcmd(" POST_WRITE(namebuf_, namelen_);") 932 pcmd(" }") 933 pcmd("}") 934 } 935 } else if (syscall == "__setlogin") { 936 if (mode == "pre") { 937 pcmd("const char *namebuf = (const char *)namebuf_;") 938 pcmd("if (namebuf) {") 939 pcmd(" PRE_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);") 940 pcmd("}") 941 } else { 942 pcmd("if (res == 0) {") 943 pcmd(" const char *namebuf = (const char *)namebuf_;") 944 pcmd(" if (namebuf) {") 945 pcmd(" POST_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);") 946 pcmd(" }") 947 pcmd("}") 948 } 949 } else if (syscall == "acct") { 950 if (mode == "pre") { 951 pcmd("const char *path = (const char *)path_;") 952 pcmd("if (path) {") 953 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 954 pcmd("}") 955 } else { 956 pcmd("if (res == 0) {") 957 pcmd(" const char *path = (const char *)path_;") 958 pcmd(" if (path) {") 959 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 960 pcmd(" }") 961 pcmd("}") 962 } 963 } else if (syscall == "compat_13_sigpending13") { 964 pcmd("/* TODO */") 965 } else if (syscall == "compat_13_sigaltstack13") { 966 pcmd("/* TODO */") 967 } else if (syscall == "ioctl") { 968 pcmd("/* Nothing to do */") 969 } else if (syscall == "compat_12_oreboot") { 970 pcmd("/* TODO */") 971 } else if (syscall == "revoke") { 972 if (mode == "pre") { 973 pcmd("const char *path = (const char *)path_;") 974 pcmd("if (path) {") 975 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 976 pcmd("}") 977 } else { 978 pcmd("if (res == 0) {") 979 pcmd(" const char *path = (const char *)path_;") 980 pcmd(" if (path) {") 981 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 982 pcmd(" }") 983 pcmd("}") 984 } 985 } else if (syscall == "symlink") { 986 if (mode == "pre") { 987 pcmd("const char *path = (const char *)path_;") 988 pcmd("const char *link = (const char *)link_;") 989 pcmd("if (path) {") 990 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 991 pcmd("}") 992 pcmd("if (link) {") 993 pcmd(" PRE_READ(link, __sanitizer::internal_strlen(link) + 1);") 994 pcmd("}") 995 } else { 996 pcmd("if (res == 0) {") 997 pcmd(" const char *path = (const char *)path_;") 998 pcmd(" const char *link = (const char *)link_;") 999 pcmd(" if (path) {") 1000 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1001 pcmd(" }") 1002 pcmd(" if (link) {") 1003 pcmd(" POST_READ(link, __sanitizer::internal_strlen(link) + 1);") 1004 pcmd(" }") 1005 pcmd("}") 1006 } 1007 } else if (syscall == "readlink") { 1008 if (mode == "pre") { 1009 pcmd("const char *path = (const char *)path_;") 1010 pcmd("if (path) {") 1011 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1012 pcmd("}") 1013 pcmd("if (buf_) {") 1014 pcmd(" PRE_WRITE(buf_, count_);") 1015 pcmd("}") 1016 } else { 1017 pcmd("if (res > 0) {") 1018 pcmd(" const char *path = (const char *)path_;") 1019 pcmd(" if (path) {") 1020 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1021 pcmd(" }") 1022 pcmd(" if (buf_) {") 1023 pcmd(" PRE_WRITE(buf_, res);") 1024 pcmd(" }") 1025 pcmd("}") 1026 } 1027 } else if (syscall == "execve") { 1028 if (mode == "pre") { 1029 pcmd("const char *path = (const char *)path_;") 1030 pcmd("char **argp = (char **)argp_;") 1031 pcmd("char **envp = (char **)envp_;") 1032 pcmd("if (path) {") 1033 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1034 pcmd("}") 1035 pcmd("if (argp && argp[0]) {") 1036 pcmd(" char *a = argp[0];") 1037 pcmd(" while (a++) {") 1038 pcmd(" PRE_READ(a, __sanitizer::internal_strlen(a) + 1);") 1039 pcmd(" }") 1040 pcmd("}") 1041 pcmd("if (envp && envp[0]) {") 1042 pcmd(" char *e = envp[0];") 1043 pcmd(" while (e++) {") 1044 pcmd(" PRE_READ(e, __sanitizer::internal_strlen(e) + 1);") 1045 pcmd(" }") 1046 pcmd("}") 1047 } else { 1048 pcmd("/* If we are here, something went wrong */") 1049 pcmd("const char *path = (const char *)path_;") 1050 pcmd("char **argp = (char **)argp_;") 1051 pcmd("char **envp = (char **)envp_;") 1052 pcmd("if (path) {") 1053 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1054 pcmd("}") 1055 pcmd("if (argp && argp[0]) {") 1056 pcmd(" char *a = argp[0];") 1057 pcmd(" while (a++) {") 1058 pcmd(" POST_READ(a, __sanitizer::internal_strlen(a) + 1);") 1059 pcmd(" }") 1060 pcmd("}") 1061 pcmd("if (envp && envp[0]) {") 1062 pcmd(" char *e = envp[0];") 1063 pcmd(" while (e++) {") 1064 pcmd(" POST_READ(e, __sanitizer::internal_strlen(e) + 1);") 1065 pcmd(" }") 1066 pcmd("}") 1067 } 1068 } else if (syscall == "umask") { 1069 pcmd("/* Nothing to do */") 1070 } else if (syscall == "chroot") { 1071 if (mode == "pre") { 1072 pcmd("const char *path = (const char *)path_;") 1073 pcmd("if (path) {") 1074 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1075 pcmd("}") 1076 } else { 1077 pcmd("if (res == 0) {") 1078 pcmd(" const char *path = (const char *)path_;") 1079 pcmd(" if (path) {") 1080 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1081 pcmd(" }") 1082 pcmd("}") 1083 } 1084 } else if (syscall == "compat_43_fstat43") { 1085 pcmd("/* TODO */") 1086 } else if (syscall == "compat_43_ogetkerninfo") { 1087 pcmd("/* TODO */") 1088 } else if (syscall == "compat_43_ogetpagesize") { 1089 pcmd("/* TODO */") 1090 } else if (syscall == "compat_12_msync") { 1091 pcmd("/* TODO */") 1092 } else if (syscall == "vfork") { 1093 pcmd("/* Nothing to do */") 1094 } else if (syscall == "compat_43_ommap") { 1095 pcmd("/* TODO */") 1096 } else if (syscall == "vadvise") { 1097 pcmd("/* Nothing to do */") 1098 } else if (syscall == "munmap") { 1099 pcmd("/* Nothing to do */") 1100 } else if (syscall == "mprotect") { 1101 pcmd("/* Nothing to do */") 1102 } else if (syscall == "madvise") { 1103 pcmd("/* Nothing to do */") 1104 } else if (syscall == "mincore") { 1105 pcmd("/* Nothing to do */") 1106 } else if (syscall == "getgroups") { 1107 if (mode == "pre") { 1108 pcmd("unsigned int *gidset = (unsigned int *)gidset_;") 1109 pcmd("if (gidset) {") 1110 pcmd(" PRE_WRITE(gidset, sizeof(*gidset) * gidsetsize_);") 1111 pcmd("}") 1112 } else { 1113 pcmd("if (res == 0) {") 1114 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;") 1115 pcmd(" if (gidset) {") 1116 pcmd(" POST_WRITE(gidset, sizeof(*gidset) * gidsetsize_);") 1117 pcmd(" }") 1118 pcmd("}") 1119 } 1120 } else if (syscall == "setgroups") { 1121 if (mode == "pre") { 1122 pcmd("unsigned int *gidset = (unsigned int *)gidset_;") 1123 pcmd("if (gidset) {") 1124 pcmd(" PRE_READ(gidset, sizeof(*gidset) * gidsetsize_);") 1125 pcmd("}") 1126 } else { 1127 pcmd("if (res == 0) {") 1128 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;") 1129 pcmd(" if (gidset) {") 1130 pcmd(" POST_READ(gidset, sizeof(*gidset) * gidsetsize_);") 1131 pcmd(" }") 1132 pcmd("}") 1133 } 1134 } else if (syscall == "getpgrp") { 1135 pcmd("/* Nothing to do */") 1136 } else if (syscall == "setpgid") { 1137 pcmd("/* Nothing to do */") 1138 } else if (syscall == "compat_50_setitimer") { 1139 pcmd("/* TODO */") 1140 } else if (syscall == "compat_43_owait") { 1141 pcmd("/* TODO */") 1142 } else if (syscall == "compat_12_oswapon") { 1143 pcmd("/* TODO */") 1144 } else if (syscall == "compat_50_getitimer") { 1145 pcmd("/* TODO */") 1146 } else if (syscall == "compat_43_ogethostname") { 1147 pcmd("/* TODO */") 1148 } else if (syscall == "compat_43_osethostname") { 1149 pcmd("/* TODO */") 1150 } else if (syscall == "compat_43_ogetdtablesize") { 1151 pcmd("/* TODO */") 1152 } else if (syscall == "dup2") { 1153 pcmd("/* Nothing to do */") 1154 } else if (syscall == "fcntl") { 1155 pcmd("/* Nothing to do */") 1156 } else if (syscall == "compat_50_select") { 1157 pcmd("/* TODO */") 1158 } else if (syscall == "fsync") { 1159 pcmd("/* Nothing to do */") 1160 } else if (syscall == "setpriority") { 1161 pcmd("/* Nothing to do */") 1162 } else if (syscall == "compat_30_socket") { 1163 pcmd("/* TODO */") 1164 } else if (syscall == "connect") { 1165 if (mode == "pre") { 1166 pcmd("PRE_READ(name_, namelen_);") 1167 } else { 1168 pcmd("if (res == 0) {") 1169 pcmd(" POST_READ(name_, namelen_);") 1170 pcmd("}") 1171 } 1172 } else if (syscall == "compat_43_oaccept") { 1173 pcmd("/* TODO */") 1174 } else if (syscall == "getpriority") { 1175 pcmd("/* Nothing to do */") 1176 } else if (syscall == "compat_43_osend") { 1177 pcmd("/* TODO */") 1178 } else if (syscall == "compat_43_orecv") { 1179 pcmd("/* TODO */") 1180 } else if (syscall == "compat_13_sigreturn13") { 1181 pcmd("/* TODO */") 1182 } else if (syscall == "bind") { 1183 if (mode == "pre") { 1184 pcmd("PRE_READ(name_, namelen_);") 1185 } else { 1186 pcmd("if (res == 0) {") 1187 pcmd(" PRE_READ(name_, namelen_);") 1188 pcmd("}") 1189 } 1190 } else if (syscall == "setsockopt") { 1191 if (mode == "pre") { 1192 pcmd("if (val_) {") 1193 pcmd(" PRE_READ(val_, valsize_);") 1194 pcmd("}") 1195 } else { 1196 pcmd("if (res == 0) {") 1197 pcmd(" if (val_) {") 1198 pcmd(" POST_READ(val_, valsize_);") 1199 pcmd(" }") 1200 pcmd("}") 1201 } 1202 } else if (syscall == "listen") { 1203 pcmd("/* Nothing to do */") 1204 } else if (syscall == "compat_43_osigvec") { 1205 pcmd("/* TODO */") 1206 } else if (syscall == "compat_43_osigblock") { 1207 pcmd("/* TODO */") 1208 } else if (syscall == "compat_43_osigsetmask") { 1209 pcmd("/* TODO */") 1210 } else if (syscall == "compat_13_sigsuspend13") { 1211 pcmd("/* TODO */") 1212 } else if (syscall == "compat_43_osigstack") { 1213 pcmd("/* TODO */") 1214 } else if (syscall == "compat_43_orecvmsg") { 1215 pcmd("/* TODO */") 1216 } else if (syscall == "compat_43_osendmsg") { 1217 pcmd("/* TODO */") 1218 } else if (syscall == "compat_50_gettimeofday") { 1219 pcmd("/* TODO */") 1220 } else if (syscall == "compat_50_getrusage") { 1221 pcmd("/* TODO */") 1222 } else if (syscall == "getsockopt") { 1223 pcmd("/* TODO */") 1224 } else if (syscall == "readv") { 1225 if (mode == "pre") { 1226 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1227 pcmd("int i;") 1228 pcmd("if (iovp) {") 1229 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1230 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1231 pcmd(" PRE_WRITE(iovp[i].iov_base, iovp[i].iov_len);") 1232 pcmd(" }") 1233 pcmd("}") 1234 } else { 1235 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1236 pcmd("int i;") 1237 pcmd("uptr m, n = res;") 1238 pcmd("if (res > 0) {") 1239 pcmd(" if (iovp) {") 1240 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1241 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1242 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1243 pcmd(" POST_WRITE(iovp[i].iov_base, m);") 1244 pcmd(" n -= m;") 1245 pcmd(" }") 1246 pcmd(" }") 1247 pcmd("}") 1248 } 1249 } else if (syscall == "writev") { 1250 if (mode == "pre") { 1251 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1252 pcmd("int i;") 1253 pcmd("if (iovp) {") 1254 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1255 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1256 pcmd(" PRE_READ(iovp[i].iov_base, iovp[i].iov_len);") 1257 pcmd(" }") 1258 pcmd("}") 1259 } else { 1260 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1261 pcmd("int i;") 1262 pcmd("uptr m, n = res;") 1263 pcmd("if (res > 0) {") 1264 pcmd(" if (iovp) {") 1265 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1266 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1267 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1268 pcmd(" POST_READ(iovp[i].iov_base, m);") 1269 pcmd(" n -= m;") 1270 pcmd(" }") 1271 pcmd(" }") 1272 pcmd("}") 1273 } 1274 } else if (syscall == "compat_50_settimeofday") { 1275 pcmd("/* TODO */") 1276 } else if (syscall == "fchown") { 1277 pcmd("/* Nothing to do */") 1278 } else if (syscall == "fchmod") { 1279 pcmd("/* Nothing to do */") 1280 } else if (syscall == "compat_43_orecvfrom") { 1281 pcmd("/* TODO */") 1282 } else if (syscall == "setreuid") { 1283 pcmd("/* Nothing to do */") 1284 } else if (syscall == "setregid") { 1285 pcmd("/* Nothing to do */") 1286 } else if (syscall == "rename") { 1287 if (mode == "pre") { 1288 pcmd("const char *from = (const char *)from_;") 1289 pcmd("const char *to = (const char *)to_;") 1290 pcmd("if (from) {") 1291 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1292 pcmd("}") 1293 pcmd("if (to) {") 1294 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1295 pcmd("}") 1296 } else { 1297 pcmd("if (res == 0) {") 1298 pcmd(" const char *from = (const char *)from_;") 1299 pcmd(" const char *to = (const char *)to_;") 1300 pcmd(" if (from) {") 1301 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1302 pcmd(" }") 1303 pcmd(" if (to) {") 1304 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1305 pcmd(" }") 1306 pcmd("}") 1307 } 1308 } else if (syscall == "compat_43_otruncate") { 1309 pcmd("/* TODO */") 1310 } else if (syscall == "compat_43_oftruncate") { 1311 pcmd("/* TODO */") 1312 } else if (syscall == "flock") { 1313 pcmd("/* Nothing to do */") 1314 } else if (syscall == "mkfifo") { 1315 if (mode == "pre") { 1316 pcmd("const char *path = (const char *)path_;") 1317 pcmd("if (path) {") 1318 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1319 pcmd("}") 1320 } else { 1321 pcmd("if (res == 0) {") 1322 pcmd(" const char *path = (const char *)path_;") 1323 pcmd(" if (path) {") 1324 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1325 pcmd(" }") 1326 pcmd("}") 1327 } 1328 } else if (syscall == "sendto") { 1329 if (mode == "pre") { 1330 pcmd("PRE_READ(buf_, len_);") 1331 pcmd("PRE_READ(to_, tolen_);") 1332 } else { 1333 pcmd("if (res >= 0) {") 1334 pcmd(" POST_READ(buf_, len_);") 1335 pcmd(" POST_READ(to_, tolen_);") 1336 pcmd("}") 1337 } 1338 } else if (syscall == "shutdown") { 1339 pcmd("/* Nothing to do */") 1340 } else if (syscall == "socketpair") { 1341 if (mode == "pre") { 1342 pcmd("PRE_WRITE(rsv_, 2 * sizeof(int));") 1343 } else { 1344 pcmd("if (res == 0) {") 1345 pcmd(" POST_WRITE(rsv_, 2 * sizeof(int));") 1346 pcmd("}") 1347 } 1348 } else if (syscall == "mkdir") { 1349 if (mode == "pre") { 1350 pcmd("const char *path = (const char *)path_;") 1351 pcmd("if (path) {") 1352 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1353 pcmd("}") 1354 } else { 1355 pcmd("if (res == 0) {") 1356 pcmd(" const char *path = (const char *)path_;") 1357 pcmd(" if (path) {") 1358 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1359 pcmd(" }") 1360 pcmd("}") 1361 } 1362 } else if (syscall == "rmdir") { 1363 if (mode == "pre") { 1364 pcmd("const char *path = (const char *)path_;") 1365 pcmd("if (path) {") 1366 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1367 pcmd("}") 1368 } else { 1369 pcmd("if (res == 0) {") 1370 pcmd(" const char *path = (const char *)path_;") 1371 pcmd(" if (path) {") 1372 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1373 pcmd(" }") 1374 pcmd("}") 1375 } 1376 } else if (syscall == "compat_50_utimes") { 1377 pcmd("/* TODO */") 1378 } else if (syscall == "compat_50_adjtime") { 1379 pcmd("/* TODO */") 1380 } else if (syscall == "compat_43_ogetpeername") { 1381 pcmd("/* TODO */") 1382 } else if (syscall == "compat_43_ogethostid") { 1383 pcmd("/* TODO */") 1384 } else if (syscall == "compat_43_osethostid") { 1385 pcmd("/* TODO */") 1386 } else if (syscall == "compat_43_ogetrlimit") { 1387 pcmd("/* TODO */") 1388 } else if (syscall == "compat_43_osetrlimit") { 1389 pcmd("/* TODO */") 1390 } else if (syscall == "compat_43_okillpg") { 1391 pcmd("/* TODO */") 1392 } else if (syscall == "setsid") { 1393 pcmd("/* Nothing to do */") 1394 } else if (syscall == "compat_50_quotactl") { 1395 pcmd("/* TODO */") 1396 } else if (syscall == "compat_43_oquota") { 1397 pcmd("/* TODO */") 1398 } else if (syscall == "compat_43_ogetsockname") { 1399 pcmd("/* TODO */") 1400 } else if (syscall == "nfssvc") { 1401 pcmd("/* Nothing to do */") 1402 } else if (syscall == "compat_43_ogetdirentries") { 1403 pcmd("/* TODO */") 1404 } else if (syscall == "compat_20_statfs") { 1405 pcmd("/* TODO */") 1406 } else if (syscall == "compat_20_fstatfs") { 1407 pcmd("/* TODO */") 1408 } else if (syscall == "compat_30_getfh") { 1409 pcmd("/* TODO */") 1410 } else if (syscall == "compat_09_ogetdomainname") { 1411 pcmd("/* TODO */") 1412 } else if (syscall == "compat_09_osetdomainname") { 1413 pcmd("/* TODO */") 1414 } else if (syscall == "compat_09_ouname") { 1415 pcmd("/* TODO */") 1416 } else if (syscall == "sysarch") { 1417 pcmd("/* TODO */") 1418 } else if (syscall == "compat_10_osemsys") { 1419 pcmd("/* TODO */") 1420 } else if (syscall == "compat_10_omsgsys") { 1421 pcmd("/* TODO */") 1422 } else if (syscall == "compat_10_oshmsys") { 1423 pcmd("/* TODO */") 1424 } else if (syscall == "pread") { 1425 if (mode == "pre") { 1426 pcmd("if (buf_) {") 1427 pcmd(" PRE_WRITE(buf_, nbyte_);") 1428 pcmd("}") 1429 } else { 1430 pcmd("if (res > 0) {") 1431 pcmd(" POST_WRITE(buf_, res);") 1432 pcmd("}") 1433 } 1434 } else if (syscall == "pwrite") { 1435 if (mode == "pre") { 1436 pcmd("if (buf_) {") 1437 pcmd(" PRE_READ(buf_, nbyte_);") 1438 pcmd("}") 1439 } else { 1440 pcmd("if (res > 0) {") 1441 pcmd(" POST_READ(buf_, res);") 1442 pcmd("}") 1443 } 1444 } else if (syscall == "compat_30_ntp_gettime") { 1445 pcmd("/* TODO */") 1446 } else if (syscall == "ntp_adjtime") { 1447 pcmd("/* Nothing to do */") 1448 } else if (syscall == "setgid") { 1449 pcmd("/* Nothing to do */") 1450 } else if (syscall == "setegid") { 1451 pcmd("/* Nothing to do */") 1452 } else if (syscall == "seteuid") { 1453 pcmd("/* Nothing to do */") 1454 } else if (syscall == "lfs_bmapv") { 1455 pcmd("/* TODO */") 1456 } else if (syscall == "lfs_markv") { 1457 pcmd("/* TODO */") 1458 } else if (syscall == "lfs_segclean") { 1459 pcmd("/* TODO */") 1460 } else if (syscall == "compat_50_lfs_segwait") { 1461 pcmd("/* TODO */") 1462 } else if (syscall == "compat_12_stat12") { 1463 pcmd("/* TODO */") 1464 } else if (syscall == "compat_12_fstat12") { 1465 pcmd("/* TODO */") 1466 } else if (syscall == "compat_12_lstat12") { 1467 pcmd("/* TODO */") 1468 } else if (syscall == "pathconf") { 1469 if (mode == "pre") { 1470 pcmd("const char *path = (const char *)path_;") 1471 pcmd("if (path) {") 1472 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1473 pcmd("}") 1474 } else { 1475 pcmd("if (res != -1) {") 1476 pcmd(" const char *path = (const char *)path_;") 1477 pcmd(" if (path) {") 1478 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1479 pcmd(" }") 1480 pcmd("}") 1481 } 1482 } else if (syscall == "getsockopt2") { 1483 pcmd("/* TODO */") 1484 } else if (syscall == "fpathconf") { 1485 pcmd("/* Nothing to do */") 1486 } else if (syscall == "getrlimit") { 1487 if (mode == "pre") { 1488 pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);") 1489 } else { 1490 pcmd("if (res == 0) {") 1491 pcmd(" POST_WRITE(rlp_, struct_rlimit_sz);") 1492 pcmd("}") 1493 } 1494 } else if (syscall == "setrlimit") { 1495 if (mode == "pre") { 1496 pcmd("PRE_READ(rlp_, struct_rlimit_sz);") 1497 } else { 1498 pcmd("if (res == 0) {") 1499 pcmd(" POST_READ(rlp_, struct_rlimit_sz);") 1500 pcmd("}") 1501 } 1502 } else if (syscall == "compat_12_getdirentries") { 1503 pcmd("/* TODO */") 1504 } else if (syscall == "mmap") { 1505 pcmd("/* Nothing to do */") 1506 } else if (syscall == "__syscall") { 1507 pcmd("/* Nothing to do */") 1508 } else if (syscall == "lseek") { 1509 pcmd("/* Nothing to do */") 1510 } else if (syscall == "truncate") { 1511 if (mode == "pre") { 1512 pcmd("const char *path = (const char *)path_;") 1513 pcmd("if (path) {") 1514 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1515 pcmd("}") 1516 } else { 1517 pcmd("if (res == 0) {") 1518 pcmd(" const char *path = (const char *)path_;") 1519 pcmd(" if (path) {") 1520 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1521 pcmd(" }") 1522 pcmd("}") 1523 } 1524 } else if (syscall == "ftruncate") { 1525 pcmd("/* Nothing to do */") 1526 } else if (syscall == "__sysctl") { 1527 if (mode == "pre") { 1528 pcmd("const int *name = (const int *)name_;") 1529 pcmd("if (name) {") 1530 pcmd(" PRE_READ(name, namelen_ * sizeof(*name));") 1531 pcmd("}") 1532 pcmd("if (newv_) {") 1533 pcmd(" PRE_READ(name, newlen_);") 1534 pcmd("}") 1535 } else { 1536 pcmd("if (res == 0) {") 1537 pcmd(" const int *name = (const int *)name_;") 1538 pcmd(" if (name) {") 1539 pcmd(" POST_READ(name, namelen_ * sizeof(*name));") 1540 pcmd(" }") 1541 pcmd(" if (newv_) {") 1542 pcmd(" POST_READ(name, newlen_);") 1543 pcmd(" }") 1544 pcmd("}") 1545 } 1546 } else if (syscall == "mlock") { 1547 pcmd("/* Nothing to do */") 1548 } else if (syscall == "munlock") { 1549 pcmd("/* Nothing to do */") 1550 } else if (syscall == "undelete") { 1551 if (mode == "pre") { 1552 pcmd("const char *path = (const char *)path_;") 1553 pcmd("if (path) {") 1554 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1555 pcmd("}") 1556 } else { 1557 pcmd("if (res == 0) {") 1558 pcmd(" const char *path = (const char *)path_;") 1559 pcmd(" if (path) {") 1560 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1561 pcmd(" }") 1562 pcmd("}") 1563 } 1564 } else if (syscall == "compat_50_futimes") { 1565 pcmd("/* TODO */") 1566 } else if (syscall == "getpgid") { 1567 pcmd("/* Nothing to do */") 1568 } else if (syscall == "reboot") { 1569 if (mode == "pre") { 1570 pcmd("const char *bootstr = (const char *)bootstr_;") 1571 pcmd("if (bootstr) {") 1572 pcmd(" PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1573 pcmd("}") 1574 } else { 1575 pcmd("/* This call should never return */") 1576 pcmd("const char *bootstr = (const char *)bootstr_;") 1577 pcmd("if (bootstr) {") 1578 pcmd(" POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1579 pcmd("}") 1580 } 1581 } else if (syscall == "poll") { 1582 pcmd("/* Nothing to do */") 1583 } else if (syscall == "afssys") { 1584 pcmd("/* TODO */") 1585 } else if (syscall == "compat_14___semctl") { 1586 pcmd("/* TODO */") 1587 } else if (syscall == "semget") { 1588 pcmd("/* Nothing to do */") 1589 } else if (syscall == "semop") { 1590 if (mode == "pre") { 1591 pcmd("if (sops_) {") 1592 pcmd(" PRE_READ(sops_, nsops_ * struct_sembuf_sz);") 1593 pcmd("}") 1594 } else { 1595 pcmd("if (res == 0) {") 1596 pcmd(" if (sops_) {") 1597 pcmd(" POST_READ(sops_, nsops_ * struct_sembuf_sz);") 1598 pcmd(" }") 1599 pcmd("}") 1600 } 1601 } else if (syscall == "semconfig") { 1602 pcmd("/* Nothing to do */") 1603 } else if (syscall == "compat_14_msgctl") { 1604 pcmd("/* TODO */") 1605 } else if (syscall == "msgget") { 1606 pcmd("/* Nothing to do */") 1607 } else if (syscall == "msgsnd") { 1608 if (mode == "pre") { 1609 pcmd("if (msgp_) {") 1610 pcmd(" PRE_READ(msgp_, msgsz_);") 1611 pcmd("}") 1612 } else { 1613 pcmd("if (res == 0) {") 1614 pcmd(" if (msgp_) {") 1615 pcmd(" POST_READ(msgp_, msgsz_);") 1616 pcmd(" }") 1617 pcmd("}") 1618 } 1619 } else if (syscall == "msgrcv") { 1620 pcmd("/* Nothing to do */") 1621 } else if (syscall == "shmat") { 1622 pcmd("/* Nothing to do */") 1623 } else if (syscall == "compat_14_shmctl") { 1624 pcmd("/* TODO */") 1625 } else if (syscall == "shmdt") { 1626 pcmd("/* Nothing to do */") 1627 } else if (syscall == "shmget") { 1628 pcmd("/* Nothing to do */") 1629 } else if (syscall == "compat_50_clock_gettime") { 1630 pcmd("/* TODO */") 1631 } else if (syscall == "compat_50_clock_settime") { 1632 pcmd("/* TODO */") 1633 } else if (syscall == "compat_50_clock_getres") { 1634 pcmd("/* TODO */") 1635 } else if (syscall == "timer_create") { 1636 pcmd("/* Nothing to do */") 1637 } else if (syscall == "timer_delete") { 1638 pcmd("/* Nothing to do */") 1639 } else if (syscall == "compat_50_timer_settime") { 1640 pcmd("/* TODO */") 1641 } else if (syscall == "compat_50_timer_gettime") { 1642 pcmd("/* TODO */") 1643 } else if (syscall == "timer_getoverrun") { 1644 pcmd("/* Nothing to do */") 1645 } else if (syscall == "compat_50_nanosleep") { 1646 pcmd("/* TODO */") 1647 } else if (syscall == "fdatasync") { 1648 pcmd("/* Nothing to do */") 1649 } else if (syscall == "mlockall") { 1650 pcmd("/* Nothing to do */") 1651 } else if (syscall == "munlockall") { 1652 pcmd("/* Nothing to do */") 1653 } else if (syscall == "compat_50___sigtimedwait") { 1654 pcmd("/* TODO */") 1655 } else if (syscall == "sigqueueinfo") { 1656 if (mode == "pre") { 1657 pcmd("if (info_) {") 1658 pcmd(" PRE_READ(info_, siginfo_t_sz);") 1659 pcmd("}") 1660 } 1661 } else if (syscall == "modctl") { 1662 pcmd("/* TODO */") 1663 } else if (syscall == "_ksem_init") { 1664 pcmd("/* Nothing to do */") 1665 } else if (syscall == "_ksem_open") { 1666 if (mode == "pre") { 1667 pcmd("const char *name = (const char *)name_;") 1668 pcmd("if (name) {") 1669 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1670 pcmd("}") 1671 } else { 1672 pcmd("const char *name = (const char *)name_;") 1673 pcmd("if (name) {") 1674 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1675 pcmd("}") 1676 } 1677 } else if (syscall == "_ksem_unlink") { 1678 if (mode == "pre") { 1679 pcmd("const char *name = (const char *)name_;") 1680 pcmd("if (name) {") 1681 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1682 pcmd("}") 1683 } else { 1684 pcmd("const char *name = (const char *)name_;") 1685 pcmd("if (name) {") 1686 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1687 pcmd("}") 1688 } 1689 } else if (syscall == "_ksem_close") { 1690 pcmd("/* Nothing to do */") 1691 } else if (syscall == "_ksem_post") { 1692 pcmd("/* Nothing to do */") 1693 } else if (syscall == "_ksem_wait") { 1694 pcmd("/* Nothing to do */") 1695 } else if (syscall == "_ksem_trywait") { 1696 pcmd("/* Nothing to do */") 1697 } else if (syscall == "_ksem_getvalue") { 1698 pcmd("/* Nothing to do */") 1699 } else if (syscall == "_ksem_destroy") { 1700 pcmd("/* Nothing to do */") 1701 } else if (syscall == "_ksem_timedwait") { 1702 if (mode == "pre") { 1703 pcmd("if (abstime_) {") 1704 pcmd(" PRE_READ(abstime_, struct_timespec_sz);") 1705 pcmd("}") 1706 } 1707 } else if (syscall == "mq_open") { 1708 if (mode == "pre") { 1709 pcmd("const char *name = (const char *)name_;") 1710 pcmd("if (name) {") 1711 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1712 pcmd("}") 1713 } else { 1714 pcmd("const char *name = (const char *)name_;") 1715 pcmd("if (name) {") 1716 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1717 pcmd("}") 1718 } 1719 } else if (syscall == "mq_close") { 1720 pcmd("/* Nothing to do */") 1721 } else if (syscall == "mq_unlink") { 1722 if (mode == "pre") { 1723 pcmd("const char *name = (const char *)name_;") 1724 pcmd("if (name) {") 1725 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1726 pcmd("}") 1727 } else { 1728 pcmd("const char *name = (const char *)name_;") 1729 pcmd("if (name) {") 1730 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1731 pcmd("}") 1732 } 1733 } else if (syscall == "mq_getattr") { 1734 pcmd("/* Nothing to do */") 1735 } else if (syscall == "mq_setattr") { 1736 if (mode == "pre") { 1737 pcmd("if (mqstat_) {") 1738 pcmd(" PRE_READ(mqstat_, struct_mq_attr_sz);") 1739 pcmd("}") 1740 } 1741 } else if (syscall == "mq_notify") { 1742 if (mode == "pre") { 1743 pcmd("if (notification_) {") 1744 pcmd(" PRE_READ(notification_, struct_sigevent_sz);") 1745 pcmd("}") 1746 } 1747 } else if (syscall == "mq_send") { 1748 if (mode == "pre") { 1749 pcmd("if (msg_ptr_) {") 1750 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 1751 pcmd("}") 1752 } 1753 } else if (syscall == "mq_receive") { 1754 pcmd("/* Nothing to do */") 1755 } else if (syscall == "compat_50_mq_timedsend") { 1756 pcmd("/* TODO */") 1757 } else if (syscall == "compat_50_mq_timedreceive") { 1758 pcmd("/* TODO */") 1759 } else if (syscall == "__posix_rename") { 1760 if (mode == "pre") { 1761 pcmd("const char *from = (const char *)from_;") 1762 pcmd("const char *to = (const char *)to_;") 1763 pcmd("if (from_) {") 1764 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1765 pcmd("}") 1766 pcmd("if (to) {") 1767 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1768 pcmd("}") 1769 } else { 1770 pcmd("const char *from = (const char *)from_;") 1771 pcmd("const char *to = (const char *)to_;") 1772 pcmd("if (from) {") 1773 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1774 pcmd("}") 1775 pcmd("if (to) {") 1776 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1777 pcmd("}") 1778 } 1779 } else if (syscall == "swapctl") { 1780 pcmd("/* TODO */") 1781 } else if (syscall == "compat_30_getdents") { 1782 pcmd("/* TODO */") 1783 } else if (syscall == "minherit") { 1784 pcmd("/* Nothing to do */") 1785 } else if (syscall == "lchmod") { 1786 if (mode == "pre") { 1787 pcmd("const char *path = (const char *)path_;") 1788 pcmd("if (path) {") 1789 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1790 pcmd("}") 1791 } else { 1792 pcmd("const char *path = (const char *)path_;") 1793 pcmd("if (path) {") 1794 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1795 pcmd("}") 1796 } 1797 } else if (syscall == "lchown") { 1798 if (mode == "pre") { 1799 pcmd("const char *path = (const char *)path_;") 1800 pcmd("if (path) {") 1801 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1802 pcmd("}") 1803 } else { 1804 pcmd("const char *path = (const char *)path_;") 1805 pcmd("if (path) {") 1806 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1807 pcmd("}") 1808 } 1809 } else if (syscall == "compat_50_lutimes") { 1810 pcmd("/* TODO */") 1811 } else if (syscall == "__msync13") { 1812 pcmd("/* Nothing to do */") 1813 } else if (syscall == "compat_30___stat13") { 1814 pcmd("/* TODO */") 1815 } else if (syscall == "compat_30___fstat13") { 1816 pcmd("/* TODO */") 1817 } else if (syscall == "compat_30___lstat13") { 1818 pcmd("/* TODO */") 1819 } else if (syscall == "__sigaltstack14") { 1820 if (mode == "pre") { 1821 pcmd("if (nss_) {") 1822 pcmd(" PRE_READ(nss_, struct_sigaltstack_sz);") 1823 pcmd("}") 1824 pcmd("if (oss_) {") 1825 pcmd(" PRE_READ(oss_, struct_sigaltstack_sz);") 1826 pcmd("}") 1827 } 1828 } else if (syscall == "__vfork14") { 1829 pcmd("/* Nothing to do */") 1830 } else if (syscall == "__posix_chown") { 1831 if (mode == "pre") { 1832 pcmd("const char *path = (const char *)path_;") 1833 pcmd("if (path) {") 1834 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1835 pcmd("}") 1836 } else { 1837 pcmd("const char *path = (const char *)path_;") 1838 pcmd("if (path) {") 1839 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1840 pcmd("}") 1841 } 1842 } else if (syscall == "__posix_fchown") { 1843 pcmd("/* Nothing to do */") 1844 } else if (syscall == "__posix_lchown") { 1845 if (mode == "pre") { 1846 pcmd("const char *path = (const char *)path_;") 1847 pcmd("if (path) {") 1848 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1849 pcmd("}") 1850 } else { 1851 pcmd("const char *path = (const char *)path_;") 1852 pcmd("if (path) {") 1853 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1854 pcmd("}") 1855 } 1856 } else if (syscall == "getsid") { 1857 pcmd("/* Nothing to do */") 1858 } else if (syscall == "__clone") { 1859 pcmd("/* Nothing to do */") 1860 } else if (syscall == "fktrace") { 1861 pcmd("/* Nothing to do */") 1862 } else if (syscall == "preadv") { 1863 pcmd("/* Nothing to do */") 1864 } else if (syscall == "pwritev") { 1865 pcmd("/* Nothing to do */") 1866 } else if (syscall == "compat_16___sigaction14") { 1867 pcmd("/* TODO */") 1868 } else if (syscall == "__sigpending14") { 1869 pcmd("/* Nothing to do */") 1870 } else if (syscall == "__sigprocmask14") { 1871 pcmd("/* Nothing to do */") 1872 } else if (syscall == "__sigsuspend14") { 1873 pcmd("if (set_) {") 1874 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 1875 pcmd("}") 1876 } else if (syscall == "compat_16___sigreturn14") { 1877 pcmd("/* TODO */") 1878 } else if (syscall == "__getcwd") { 1879 pcmd("/* Nothing to do */") 1880 } else if (syscall == "fchroot") { 1881 pcmd("/* Nothing to do */") 1882 } else if (syscall == "compat_30_fhopen") { 1883 pcmd("/* TODO */") 1884 } else if (syscall == "compat_30_fhstat") { 1885 pcmd("/* TODO */") 1886 } else if (syscall == "compat_20_fhstatfs") { 1887 pcmd("/* TODO */") 1888 } else if (syscall == "compat_50_____semctl13") { 1889 pcmd("/* TODO */") 1890 } else if (syscall == "compat_50___msgctl13") { 1891 pcmd("/* TODO */") 1892 } else if (syscall == "compat_50___shmctl13") { 1893 pcmd("/* TODO */") 1894 } else if (syscall == "lchflags") { 1895 if (mode == "pre") { 1896 pcmd("const char *path = (const char *)path_;") 1897 pcmd("if (path) {") 1898 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1899 pcmd("}") 1900 } else { 1901 pcmd("const char *path = (const char *)path_;") 1902 pcmd("if (path) {") 1903 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1904 pcmd("}") 1905 } 1906 } else if (syscall == "issetugid") { 1907 pcmd("/* Nothing to do */") 1908 } else if (syscall == "utrace") { 1909 if (mode == "pre") { 1910 pcmd("const char *label = (const char *)label_;") 1911 pcmd("if (label) {") 1912 pcmd(" PRE_READ(label, __sanitizer::internal_strlen(label) + 1);") 1913 pcmd("}") 1914 pcmd("if (addr_) {") 1915 pcmd(" PRE_READ(addr_, len_);") 1916 pcmd("}") 1917 } else { 1918 pcmd("const char *label = (const char *)label_;") 1919 pcmd("if (label) {") 1920 pcmd(" POST_READ(label, __sanitizer::internal_strlen(label) + 1);") 1921 pcmd("}") 1922 pcmd("if (addr_) {") 1923 pcmd(" POST_READ(addr_, len_);") 1924 pcmd("}") 1925 } 1926 } else if (syscall == "getcontext") { 1927 pcmd("/* Nothing to do */") 1928 } else if (syscall == "setcontext") { 1929 if (mode == "pre") { 1930 pcmd("if (ucp_) {") 1931 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1932 pcmd("}") 1933 } 1934 } else if (syscall == "_lwp_create") { 1935 if (mode == "pre") { 1936 pcmd("if (ucp_) {") 1937 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1938 pcmd("}") 1939 } 1940 } else if (syscall == "_lwp_exit") { 1941 pcmd("/* Nothing to do */") 1942 } else if (syscall == "_lwp_self") { 1943 pcmd("/* Nothing to do */") 1944 } else if (syscall == "_lwp_wait") { 1945 pcmd("/* Nothing to do */") 1946 } else if (syscall == "_lwp_suspend") { 1947 pcmd("/* Nothing to do */") 1948 } else if (syscall == "_lwp_continue") { 1949 pcmd("/* Nothing to do */") 1950 } else if (syscall == "_lwp_wakeup") { 1951 pcmd("/* Nothing to do */") 1952 } else if (syscall == "_lwp_getprivate") { 1953 pcmd("/* Nothing to do */") 1954 } else if (syscall == "_lwp_setprivate") { 1955 pcmd("/* Nothing to do */") 1956 } else if (syscall == "_lwp_kill") { 1957 pcmd("/* Nothing to do */") 1958 } else if (syscall == "_lwp_detach") { 1959 pcmd("/* Nothing to do */") 1960 } else if (syscall == "compat_50__lwp_park") { 1961 pcmd("/* TODO */") 1962 } else if (syscall == "_lwp_unpark") { 1963 pcmd("/* Nothing to do */") 1964 } else if (syscall == "_lwp_unpark_all") { 1965 if (mode == "pre") { 1966 pcmd("if (targets_) {") 1967 pcmd(" PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));") 1968 pcmd("}") 1969 } 1970 } else if (syscall == "_lwp_setname") { 1971 if (mode == "pre") { 1972 pcmd("const char *name = (const char *)name_;") 1973 pcmd("if (name) {") 1974 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1975 pcmd("}") 1976 } else { 1977 pcmd("const char *name = (const char *)name_;") 1978 pcmd("if (name) {") 1979 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1980 pcmd("}") 1981 } 1982 } else if (syscall == "_lwp_getname") { 1983 pcmd("/* Nothing to do */") 1984 } else if (syscall == "_lwp_ctl") { 1985 pcmd("/* Nothing to do */") 1986 } else if (syscall == "compat_60_sa_register") { 1987 pcmd("/* TODO */") 1988 } else if (syscall == "compat_60_sa_stacks") { 1989 pcmd("/* TODO */") 1990 } else if (syscall == "compat_60_sa_enable") { 1991 pcmd("/* TODO */") 1992 } else if (syscall == "compat_60_sa_setconcurrency") { 1993 pcmd("/* TODO */") 1994 } else if (syscall == "compat_60_sa_yield") { 1995 pcmd("/* TODO */") 1996 } else if (syscall == "compat_60_sa_preempt") { 1997 pcmd("/* TODO */") 1998 } else if (syscall == "__sigaction_sigtramp") { 1999 pcmd("if (nsa_) {") 2000 pcmd(" PRE_READ(nsa_, sizeof(__sanitizer_sigaction));") 2001 pcmd("}") 2002 } else if (syscall == "rasctl") { 2003 pcmd("/* Nothing to do */") 2004 } else if (syscall == "kqueue") { 2005 pcmd("/* Nothing to do */") 2006 } else if (syscall == "compat_50_kevent") { 2007 pcmd("/* TODO */") 2008 } else if (syscall == "_sched_setparam") { 2009 pcmd("if (params_) {") 2010 pcmd(" PRE_READ(params_, struct_sched_param_sz);") 2011 pcmd("}") 2012 } else if (syscall == "_sched_getparam") { 2013 pcmd("/* Nothing to do */") 2014 } else if (syscall == "_sched_setaffinity") { 2015 pcmd("if (cpuset_) {") 2016 pcmd(" PRE_READ(cpuset_, size_);") 2017 pcmd("}") 2018 } else if (syscall == "_sched_getaffinity") { 2019 pcmd("/* Nothing to do */") 2020 } else if (syscall == "sched_yield") { 2021 pcmd("/* Nothing to do */") 2022 } else if (syscall == "_sched_protect") { 2023 pcmd("/* Nothing to do */") 2024 } else if (syscall == "fsync_range") { 2025 pcmd("/* Nothing to do */") 2026 } else if (syscall == "uuidgen") { 2027 pcmd("/* Nothing to do */") 2028 } else if (syscall == "compat_90_getvfsstat") { 2029 pcmd("/* Nothing to do */") 2030 } else if (syscall == "compat_90_statvfs1") { 2031 if (mode == "pre") { 2032 pcmd("const char *path = (const char *)path_;") 2033 pcmd("if (path) {") 2034 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2035 pcmd("}") 2036 } else { 2037 pcmd("const char *path = (const char *)path_;") 2038 pcmd("if (path) {") 2039 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2040 pcmd("}") 2041 } 2042 } else if (syscall == "compat_90_fstatvfs1") { 2043 pcmd("/* Nothing to do */") 2044 } else if (syscall == "compat_30_fhstatvfs1") { 2045 pcmd("/* TODO */") 2046 } else if (syscall == "extattrctl") { 2047 if (mode == "pre") { 2048 pcmd("const char *path = (const char *)path_;") 2049 pcmd("if (path) {") 2050 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2051 pcmd("}") 2052 } else { 2053 pcmd("const char *path = (const char *)path_;") 2054 pcmd("if (path) {") 2055 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2056 pcmd("}") 2057 } 2058 } else if (syscall == "extattr_set_file") { 2059 if (mode == "pre") { 2060 pcmd("const char *path = (const char *)path_;") 2061 pcmd("if (path) {") 2062 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2063 pcmd("}") 2064 } else { 2065 pcmd("const char *path = (const char *)path_;") 2066 pcmd("if (path) {") 2067 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2068 pcmd("}") 2069 } 2070 } else if (syscall == "extattr_get_file") { 2071 if (mode == "pre") { 2072 pcmd("const char *path = (const char *)path_;") 2073 pcmd("if (path) {") 2074 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2075 pcmd("}") 2076 } else { 2077 pcmd("const char *path = (const char *)path_;") 2078 pcmd("if (path) {") 2079 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2080 pcmd("}") 2081 } 2082 } else if (syscall == "extattr_delete_file") { 2083 if (mode == "pre") { 2084 pcmd("const char *path = (const char *)path_;") 2085 pcmd("if (path) {") 2086 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2087 pcmd("}") 2088 } else { 2089 pcmd("const char *path = (const char *)path_;") 2090 pcmd("if (path) {") 2091 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2092 pcmd("}") 2093 } 2094 } else if (syscall == "extattr_set_fd") { 2095 pcmd("/* TODO */") 2096 } else if (syscall == "extattr_get_fd") { 2097 pcmd("/* TODO */") 2098 } else if (syscall == "extattr_delete_fd") { 2099 pcmd("/* TODO */") 2100 } else if (syscall == "extattr_set_link") { 2101 if (mode == "pre") { 2102 pcmd("const char *path = (const char *)path_;") 2103 pcmd("if (path) {") 2104 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2105 pcmd("}") 2106 } else { 2107 pcmd("const char *path = (const char *)path_;") 2108 pcmd("if (path) {") 2109 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2110 pcmd("}") 2111 } 2112 } else if (syscall == "extattr_get_link") { 2113 if (mode == "pre") { 2114 pcmd("const char *path = (const char *)path_;") 2115 pcmd("if (path) {") 2116 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2117 pcmd("}") 2118 } else { 2119 pcmd("const char *path = (const char *)path_;") 2120 pcmd("if (path) {") 2121 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2122 pcmd("}") 2123 } 2124 } else if (syscall == "extattr_delete_link") { 2125 if (mode == "pre") { 2126 pcmd("const char *path = (const char *)path_;") 2127 pcmd("if (path) {") 2128 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2129 pcmd("}") 2130 } else { 2131 pcmd("const char *path = (const char *)path_;") 2132 pcmd("if (path) {") 2133 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2134 pcmd("}") 2135 } 2136 } else if (syscall == "extattr_list_fd") { 2137 pcmd("/* TODO */") 2138 } else if (syscall == "extattr_list_file") { 2139 if (mode == "pre") { 2140 pcmd("const char *path = (const char *)path_;") 2141 pcmd("if (path) {") 2142 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2143 pcmd("}") 2144 } else { 2145 pcmd("const char *path = (const char *)path_;") 2146 pcmd("if (path) {") 2147 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2148 pcmd("}") 2149 } 2150 } else if (syscall == "extattr_list_link") { 2151 if (mode == "pre") { 2152 pcmd("const char *path = (const char *)path_;") 2153 pcmd("if (path) {") 2154 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2155 pcmd("}") 2156 } else { 2157 pcmd("const char *path = (const char *)path_;") 2158 pcmd("if (path) {") 2159 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2160 pcmd("}") 2161 } 2162 } else if (syscall == "compat_50_pselect") { 2163 pcmd("/* TODO */") 2164 } else if (syscall == "compat_50_pollts") { 2165 pcmd("/* TODO */") 2166 } else if (syscall == "setxattr") { 2167 if (mode == "pre") { 2168 pcmd("const char *path = (const char *)path_;") 2169 pcmd("if (path) {") 2170 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2171 pcmd("}") 2172 } else { 2173 pcmd("const char *path = (const char *)path_;") 2174 pcmd("if (path) {") 2175 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2176 pcmd("}") 2177 } 2178 } else if (syscall == "lsetxattr") { 2179 if (mode == "pre") { 2180 pcmd("const char *path = (const char *)path_;") 2181 pcmd("if (path) {") 2182 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2183 pcmd("}") 2184 } else { 2185 pcmd("const char *path = (const char *)path_;") 2186 pcmd("if (path) {") 2187 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2188 pcmd("}") 2189 } 2190 } else if (syscall == "fsetxattr") { 2191 pcmd("/* Nothing to do */") 2192 } else if (syscall == "getxattr") { 2193 if (mode == "pre") { 2194 pcmd("const char *path = (const char *)path_;") 2195 pcmd("if (path) {") 2196 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2197 pcmd("}") 2198 } else { 2199 pcmd("const char *path = (const char *)path_;") 2200 pcmd("if (path) {") 2201 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2202 pcmd("}") 2203 } 2204 } else if (syscall == "lgetxattr") { 2205 if (mode == "pre") { 2206 pcmd("const char *path = (const char *)path_;") 2207 pcmd("if (path) {") 2208 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2209 pcmd("}") 2210 } else { 2211 pcmd("const char *path = (const char *)path_;") 2212 pcmd("if (path) {") 2213 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2214 pcmd("}") 2215 } 2216 } else if (syscall == "fgetxattr") { 2217 pcmd("/* Nothing to do */") 2218 } else if (syscall == "listxattr") { 2219 if (mode == "pre") { 2220 pcmd("const char *path = (const char *)path_;") 2221 pcmd("if (path) {") 2222 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2223 pcmd("}") 2224 } else { 2225 pcmd("const char *path = (const char *)path_;") 2226 pcmd("if (path) {") 2227 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2228 pcmd("}") 2229 } 2230 } else if (syscall == "llistxattr") { 2231 if (mode == "pre") { 2232 pcmd("const char *path = (const char *)path_;") 2233 pcmd("if (path) {") 2234 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2235 pcmd("}") 2236 } else { 2237 pcmd("const char *path = (const char *)path_;") 2238 pcmd("if (path) {") 2239 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2240 pcmd("}") 2241 } 2242 } else if (syscall == "flistxattr") { 2243 pcmd("/* TODO */") 2244 } else if (syscall == "removexattr") { 2245 if (mode == "pre") { 2246 pcmd("const char *path = (const char *)path_;") 2247 pcmd("if (path) {") 2248 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2249 pcmd("}") 2250 } else { 2251 pcmd("const char *path = (const char *)path_;") 2252 pcmd("if (path) {") 2253 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2254 pcmd("}") 2255 } 2256 } else if (syscall == "lremovexattr") { 2257 if (mode == "pre") { 2258 pcmd("const char *path = (const char *)path_;") 2259 pcmd("if (path) {") 2260 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2261 pcmd("}") 2262 } else { 2263 pcmd("const char *path = (const char *)path_;") 2264 pcmd("if (path) {") 2265 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2266 pcmd("}") 2267 } 2268 } else if (syscall == "fremovexattr") { 2269 pcmd("/* TODO */") 2270 } else if (syscall == "compat_50___stat30") { 2271 pcmd("/* TODO */") 2272 } else if (syscall == "compat_50___fstat30") { 2273 pcmd("/* TODO */") 2274 } else if (syscall == "compat_50___lstat30") { 2275 pcmd("/* TODO */") 2276 } else if (syscall == "__getdents30") { 2277 pcmd("/* Nothing to do */") 2278 } else if (syscall == "posix_fadvise") { 2279 pcmd("/* Nothing to do */") 2280 } else if (syscall == "compat_30___fhstat30") { 2281 pcmd("/* TODO */") 2282 } else if (syscall == "compat_50___ntp_gettime30") { 2283 pcmd("/* TODO */") 2284 } else if (syscall == "__socket30") { 2285 pcmd("/* Nothing to do */") 2286 } else if (syscall == "__getfh30") { 2287 if (mode == "pre") { 2288 pcmd("const char *fname = (const char *)fname_;") 2289 pcmd("if (fname) {") 2290 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2291 pcmd("}") 2292 } else { 2293 pcmd("const char *fname = (const char *)fname_;") 2294 pcmd("if (res == 0) {") 2295 pcmd(" if (fname) {") 2296 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2297 pcmd(" }") 2298 pcmd("}") 2299 } 2300 } else if (syscall == "__fhopen40") { 2301 if (mode == "pre") { 2302 pcmd("if (fhp_) {") 2303 pcmd(" PRE_READ(fhp_, fh_size_);") 2304 pcmd("}") 2305 } 2306 } else if (syscall == "compat_90_fhstatvfs1") { 2307 if (mode == "pre") { 2308 pcmd("if (fhp_) {") 2309 pcmd(" PRE_READ(fhp_, fh_size_);") 2310 pcmd("}") 2311 } 2312 } else if (syscall == "compat_50___fhstat40") { 2313 if (mode == "pre") { 2314 pcmd("if (fhp_) {") 2315 pcmd(" PRE_READ(fhp_, fh_size_);") 2316 pcmd("}") 2317 } 2318 } else if (syscall == "aio_cancel") { 2319 if (mode == "pre") { 2320 pcmd("if (aiocbp_) {") 2321 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2322 pcmd("}") 2323 } 2324 } else if (syscall == "aio_error") { 2325 if (mode == "pre") { 2326 pcmd("if (aiocbp_) {") 2327 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2328 pcmd("}") 2329 } 2330 } else if (syscall == "aio_fsync") { 2331 if (mode == "pre") { 2332 pcmd("if (aiocbp_) {") 2333 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2334 pcmd("}") 2335 } 2336 } else if (syscall == "aio_read") { 2337 if (mode == "pre") { 2338 pcmd("if (aiocbp_) {") 2339 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2340 pcmd("}") 2341 } 2342 } else if (syscall == "aio_return") { 2343 if (mode == "pre") { 2344 pcmd("if (aiocbp_) {") 2345 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2346 pcmd("}") 2347 } 2348 } else if (syscall == "compat_50_aio_suspend") { 2349 pcmd("/* TODO */") 2350 } else if (syscall == "aio_write") { 2351 if (mode == "pre") { 2352 pcmd("if (aiocbp_) {") 2353 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2354 pcmd("}") 2355 } 2356 } else if (syscall == "lio_listio") { 2357 pcmd("/* Nothing to do */") 2358 } else if (syscall == "__mount50") { 2359 if (mode == "pre") { 2360 pcmd("const char *type = (const char *)type_;") 2361 pcmd("const char *path = (const char *)path_;") 2362 pcmd("if (type) {") 2363 pcmd(" PRE_READ(type, __sanitizer::internal_strlen(type) + 1);") 2364 pcmd("}") 2365 pcmd("if (path) {") 2366 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2367 pcmd("}") 2368 pcmd("if (data_) {") 2369 pcmd(" PRE_READ(data_, data_len_);") 2370 pcmd("}") 2371 } else { 2372 pcmd("const char *type = (const char *)type_;") 2373 pcmd("const char *path = (const char *)path_;") 2374 pcmd("if (type) {") 2375 pcmd(" POST_READ(type, __sanitizer::internal_strlen(type) + 1);") 2376 pcmd("}") 2377 pcmd("if (path) {") 2378 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2379 pcmd("}") 2380 pcmd("if (data_) {") 2381 pcmd(" POST_READ(data_, data_len_);") 2382 pcmd("}") 2383 } 2384 } else if (syscall == "mremap") { 2385 pcmd("/* Nothing to do */") 2386 } else if (syscall == "pset_create") { 2387 pcmd("/* Nothing to do */") 2388 } else if (syscall == "pset_destroy") { 2389 pcmd("/* Nothing to do */") 2390 } else if (syscall == "pset_assign") { 2391 pcmd("/* Nothing to do */") 2392 } else if (syscall == "_pset_bind") { 2393 pcmd("/* Nothing to do */") 2394 } else if (syscall == "__posix_fadvise50") { 2395 pcmd("/* Nothing to do */") 2396 } else if (syscall == "__select50") { 2397 pcmd("/* Nothing to do */") 2398 } else if (syscall == "__gettimeofday50") { 2399 pcmd("/* Nothing to do */") 2400 } else if (syscall == "__settimeofday50") { 2401 if (mode == "pre") { 2402 pcmd("if (tv_) {") 2403 pcmd(" PRE_READ(tv_, timeval_sz);") 2404 pcmd("}") 2405 pcmd("if (tzp_) {") 2406 pcmd(" PRE_READ(tzp_, struct_timezone_sz);") 2407 pcmd("}") 2408 } 2409 } else if (syscall == "__utimes50") { 2410 if (mode == "pre") { 2411 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2412 pcmd("const char *path = (const char *)path_;") 2413 pcmd("if (path) {") 2414 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2415 pcmd("}") 2416 pcmd("if (tptr) {") 2417 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2418 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2419 pcmd("}") 2420 } 2421 } else if (syscall == "__adjtime50") { 2422 if (mode == "pre") { 2423 pcmd("if (delta_) {") 2424 pcmd(" PRE_READ(delta_, timeval_sz);") 2425 pcmd("}") 2426 } 2427 } else if (syscall == "__lfs_segwait50") { 2428 pcmd("/* TODO */") 2429 } else if (syscall == "__futimes50") { 2430 if (mode == "pre") { 2431 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2432 pcmd("if (tptr) {") 2433 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2434 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2435 pcmd("}") 2436 } 2437 } else if (syscall == "__lutimes50") { 2438 if (mode == "pre") { 2439 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2440 pcmd("const char *path = (const char *)path_;") 2441 pcmd("if (path) {") 2442 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2443 pcmd("}") 2444 pcmd("if (tptr) {") 2445 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2446 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2447 pcmd("}") 2448 } else { 2449 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2450 pcmd("const char *path = (const char *)path_;") 2451 pcmd("if (path) {") 2452 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2453 pcmd("}") 2454 pcmd("if (tptr) {") 2455 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2456 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2457 pcmd("}") 2458 } 2459 } else if (syscall == "__setitimer50") { 2460 if (mode == "pre") { 2461 pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;") 2462 pcmd("if (itv) {") 2463 pcmd(" PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2464 pcmd(" PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2465 pcmd(" PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2466 pcmd(" PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2467 pcmd("}") 2468 } 2469 } else if (syscall == "__getitimer50") { 2470 pcmd("/* Nothing to do */") 2471 } else if (syscall == "__clock_gettime50") { 2472 pcmd("/* Nothing to do */") 2473 } else if (syscall == "__clock_settime50") { 2474 if (mode == "pre") { 2475 pcmd("if (tp_) {") 2476 pcmd(" PRE_READ(tp_, struct_timespec_sz);") 2477 pcmd("}") 2478 } 2479 } else if (syscall == "__clock_getres50") { 2480 pcmd("/* Nothing to do */") 2481 } else if (syscall == "__nanosleep50") { 2482 if (mode == "pre") { 2483 pcmd("if (rqtp_) {") 2484 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2485 pcmd("}") 2486 } 2487 } else if (syscall == "____sigtimedwait50") { 2488 if (mode == "pre") { 2489 pcmd("if (set_) {") 2490 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 2491 pcmd("}") 2492 pcmd("if (timeout_) {") 2493 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2494 pcmd("}") 2495 } 2496 } else if (syscall == "__mq_timedsend50") { 2497 if (mode == "pre") { 2498 pcmd("if (msg_ptr_) {") 2499 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2500 pcmd("}") 2501 pcmd("if (abs_timeout_) {") 2502 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2503 pcmd("}") 2504 } 2505 } else if (syscall == "__mq_timedreceive50") { 2506 if (mode == "pre") { 2507 pcmd("if (msg_ptr_) {") 2508 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2509 pcmd("}") 2510 pcmd("if (abs_timeout_) {") 2511 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2512 pcmd("}") 2513 } 2514 } else if (syscall == "compat_60__lwp_park") { 2515 pcmd("/* TODO */") 2516 } else if (syscall == "__kevent50") { 2517 if (mode == "pre") { 2518 pcmd("if (changelist_) {") 2519 pcmd(" PRE_READ(changelist_, nchanges_ * struct_kevent_sz);") 2520 pcmd("}") 2521 pcmd("if (timeout_) {") 2522 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2523 pcmd("}") 2524 } 2525 } else if (syscall == "__pselect50") { 2526 if (mode == "pre") { 2527 pcmd("if (ts_) {") 2528 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2529 pcmd("}") 2530 pcmd("if (mask_) {") 2531 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2532 pcmd("}") 2533 } 2534 } else if (syscall == "__pollts50") { 2535 if (mode == "pre") { 2536 pcmd("if (ts_) {") 2537 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2538 pcmd("}") 2539 pcmd("if (mask_) {") 2540 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2541 pcmd("}") 2542 } 2543 } else if (syscall == "__aio_suspend50") { 2544 if (mode == "pre") { 2545 pcmd("int i;") 2546 pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;") 2547 pcmd("if (list) {") 2548 pcmd(" for (i = 0; i < nent_; i++) {") 2549 pcmd(" if (list[i]) {") 2550 pcmd(" PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));") 2551 pcmd(" }") 2552 pcmd(" }") 2553 pcmd("}") 2554 pcmd("if (timeout_) {") 2555 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2556 pcmd("}") 2557 } 2558 } else if (syscall == "__stat50") { 2559 if (mode == "pre") { 2560 pcmd("const char *path = (const char *)path_;") 2561 pcmd("if (path) {") 2562 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2563 pcmd("}") 2564 } else { 2565 pcmd("const char *path = (const char *)path_;") 2566 pcmd("if (res == 0) {") 2567 pcmd(" if (path) {") 2568 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2569 pcmd(" }") 2570 pcmd("}") 2571 } 2572 } else if (syscall == "__fstat50") { 2573 pcmd("/* Nothing to do */") 2574 } else if (syscall == "__lstat50") { 2575 if (mode == "pre") { 2576 pcmd("const char *path = (const char *)path_;") 2577 pcmd("if (path) {") 2578 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2579 pcmd("}") 2580 } else { 2581 pcmd("const char *path = (const char *)path_;") 2582 pcmd("if (res == 0) {") 2583 pcmd(" if (path) {") 2584 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2585 pcmd(" }") 2586 pcmd("}") 2587 } 2588 } else if (syscall == "____semctl50") { 2589 pcmd("/* Nothing to do */") 2590 } else if (syscall == "__shmctl50") { 2591 pcmd("/* Nothing to do */") 2592 } else if (syscall == "__msgctl50") { 2593 pcmd("/* Nothing to do */") 2594 } else if (syscall == "__getrusage50") { 2595 pcmd("/* Nothing to do */") 2596 } else if (syscall == "__timer_settime50") { 2597 if (mode == "pre") { 2598 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2599 pcmd("if (value) {") 2600 pcmd(" PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2601 pcmd(" PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2602 pcmd(" PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2603 pcmd(" PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2604 pcmd("}") 2605 } else { 2606 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2607 pcmd("if (res == 0) {") 2608 pcmd(" if (value) {") 2609 pcmd(" POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2610 pcmd(" POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2611 pcmd(" POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2612 pcmd(" POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2613 pcmd(" }") 2614 pcmd("}") 2615 } 2616 } else if (syscall == "__timer_gettime50") { 2617 pcmd("/* Nothing to do */") 2618 } else if (syscall == "__ntp_gettime50") { 2619 pcmd("/* Nothing to do */") 2620 } else if (syscall == "__wait450") { 2621 pcmd("/* Nothing to do */") 2622 } else if (syscall == "__mknod50") { 2623 if (mode == "pre") { 2624 pcmd("const char *path = (const char *)path_;") 2625 pcmd("if (path) {") 2626 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2627 pcmd("}") 2628 } else { 2629 pcmd("const char *path = (const char *)path_;") 2630 pcmd("if (res == 0) {") 2631 pcmd(" if (path) {") 2632 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2633 pcmd(" }") 2634 pcmd("}") 2635 } 2636 } else if (syscall == "__fhstat50") { 2637 if (mode == "pre") { 2638 pcmd("if (fhp_) {") 2639 pcmd(" PRE_READ(fhp_, fh_size_);") 2640 pcmd("}") 2641 } else { 2642 pcmd("if (res == 0) {") 2643 pcmd(" if (fhp_) {") 2644 pcmd(" POST_READ(fhp_, fh_size_);") 2645 pcmd(" }") 2646 pcmd("}") 2647 } 2648 } else if (syscall == "pipe2") { 2649 pcmd("/* Nothing to do */") 2650 } else if (syscall == "dup3") { 2651 pcmd("/* Nothing to do */") 2652 } else if (syscall == "kqueue1") { 2653 pcmd("/* Nothing to do */") 2654 } else if (syscall == "paccept") { 2655 if (mode == "pre") { 2656 pcmd("if (mask_) {") 2657 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2658 pcmd("}") 2659 } else { 2660 pcmd("if (res >= 0) {") 2661 pcmd(" if (mask_) {") 2662 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2663 pcmd(" }") 2664 pcmd("}") 2665 } 2666 } else if (syscall == "linkat") { 2667 if (mode == "pre") { 2668 pcmd("const char *name1 = (const char *)name1_;") 2669 pcmd("const char *name2 = (const char *)name2_;") 2670 pcmd("if (name1) {") 2671 pcmd(" PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2672 pcmd("}") 2673 pcmd("if (name2) {") 2674 pcmd(" PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2675 pcmd("}") 2676 } else { 2677 pcmd("const char *name1 = (const char *)name1_;") 2678 pcmd("const char *name2 = (const char *)name2_;") 2679 pcmd("if (res == 0) {") 2680 pcmd(" if (name1) {") 2681 pcmd(" POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2682 pcmd(" }") 2683 pcmd(" if (name2) {") 2684 pcmd(" POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2685 pcmd(" }") 2686 pcmd("}") 2687 } 2688 } else if (syscall == "renameat") { 2689 if (mode == "pre") { 2690 pcmd("const char *from = (const char *)from_;") 2691 pcmd("const char *to = (const char *)to_;") 2692 pcmd("if (from) {") 2693 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 2694 pcmd("}") 2695 pcmd("if (to) {") 2696 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 2697 pcmd("}") 2698 } else { 2699 pcmd("const char *from = (const char *)from_;") 2700 pcmd("const char *to = (const char *)to_;") 2701 pcmd("if (res == 0) {") 2702 pcmd(" if (from) {") 2703 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 2704 pcmd(" }") 2705 pcmd(" if (to) {") 2706 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 2707 pcmd(" }") 2708 pcmd("}") 2709 } 2710 } else if (syscall == "mkfifoat") { 2711 if (mode == "pre") { 2712 pcmd("const char *path = (const char *)path_;") 2713 pcmd("if (path) {") 2714 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2715 pcmd("}") 2716 } else { 2717 pcmd("const char *path = (const char *)path_;") 2718 pcmd("if (res == 0) {") 2719 pcmd(" if (path) {") 2720 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2721 pcmd(" }") 2722 pcmd("}") 2723 } 2724 } else if (syscall == "mknodat") { 2725 if (mode == "pre") { 2726 pcmd("const char *path = (const char *)path_;") 2727 pcmd("if (path) {") 2728 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2729 pcmd("}") 2730 } else { 2731 pcmd("const char *path = (const char *)path_;") 2732 pcmd("if (res == 0) {") 2733 pcmd(" if (path) {") 2734 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2735 pcmd(" }") 2736 pcmd("}") 2737 } 2738 } else if (syscall == "mkdirat") { 2739 if (mode == "pre") { 2740 pcmd("const char *path = (const char *)path_;") 2741 pcmd("if (path) {") 2742 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2743 pcmd("}") 2744 } else { 2745 pcmd("const char *path = (const char *)path_;") 2746 pcmd("if (res == 0) {") 2747 pcmd(" if (path) {") 2748 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2749 pcmd(" }") 2750 pcmd("}") 2751 } 2752 } else if (syscall == "faccessat") { 2753 if (mode == "pre") { 2754 pcmd("const char *path = (const char *)path_;") 2755 pcmd("if (path) {") 2756 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2757 pcmd("}") 2758 } else { 2759 pcmd("const char *path = (const char *)path_;") 2760 pcmd("if (res == 0) {") 2761 pcmd(" if (path) {") 2762 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2763 pcmd(" }") 2764 pcmd("}") 2765 } 2766 } else if (syscall == "fchmodat") { 2767 if (mode == "pre") { 2768 pcmd("const char *path = (const char *)path_;") 2769 pcmd("if (path) {") 2770 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2771 pcmd("}") 2772 } else { 2773 pcmd("const char *path = (const char *)path_;") 2774 pcmd("if (res == 0) {") 2775 pcmd(" if (path) {") 2776 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2777 pcmd(" }") 2778 pcmd("}") 2779 } 2780 } else if (syscall == "fchownat") { 2781 if (mode == "pre") { 2782 pcmd("const char *path = (const char *)path_;") 2783 pcmd("if (path) {") 2784 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2785 pcmd("}") 2786 } else { 2787 pcmd("const char *path = (const char *)path_;") 2788 pcmd("if (res == 0) {") 2789 pcmd(" if (path) {") 2790 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2791 pcmd(" }") 2792 pcmd("}") 2793 } 2794 } else if (syscall == "fexecve") { 2795 pcmd("/* TODO */") 2796 } else if (syscall == "fstatat") { 2797 if (mode == "pre") { 2798 pcmd("const char *path = (const char *)path_;") 2799 pcmd("if (path) {") 2800 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2801 pcmd("}") 2802 } else { 2803 pcmd("const char *path = (const char *)path_;") 2804 pcmd("if (path) {") 2805 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2806 pcmd("}") 2807 } 2808 } else if (syscall == "utimensat") { 2809 if (mode == "pre") { 2810 pcmd("const char *path = (const char *)path_;") 2811 pcmd("if (path) {") 2812 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2813 pcmd("}") 2814 pcmd("if (tptr_) {") 2815 pcmd(" PRE_READ(tptr_, struct_timespec_sz);") 2816 pcmd("}") 2817 } else { 2818 pcmd("const char *path = (const char *)path_;") 2819 pcmd("if (res > 0) {") 2820 pcmd(" if (path) {") 2821 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2822 pcmd(" }") 2823 pcmd(" if (tptr_) {") 2824 pcmd(" POST_READ(tptr_, struct_timespec_sz);") 2825 pcmd(" }") 2826 pcmd("}") 2827 } 2828 } else if (syscall == "openat") { 2829 if (mode == "pre") { 2830 pcmd("const char *path = (const char *)path_;") 2831 pcmd("if (path) {") 2832 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2833 pcmd("}") 2834 } else { 2835 pcmd("const char *path = (const char *)path_;") 2836 pcmd("if (res > 0) {") 2837 pcmd(" if (path) {") 2838 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2839 pcmd(" }") 2840 pcmd("}") 2841 } 2842 } else if (syscall == "readlinkat") { 2843 if (mode == "pre") { 2844 pcmd("const char *path = (const char *)path_;") 2845 pcmd("if (path) {") 2846 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2847 pcmd("}") 2848 } else { 2849 pcmd("const char *path = (const char *)path_;") 2850 pcmd("if (res > 0) {") 2851 pcmd(" if (path) {") 2852 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2853 pcmd(" }") 2854 pcmd("}") 2855 } 2856 } else if (syscall == "symlinkat") { 2857 if (mode == "pre") { 2858 pcmd("const char *path1 = (const char *)path1_;") 2859 pcmd("const char *path2 = (const char *)path2_;") 2860 pcmd("if (path1) {") 2861 pcmd(" PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2862 pcmd("}") 2863 pcmd("if (path2) {") 2864 pcmd(" PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2865 pcmd("}") 2866 } else { 2867 pcmd("const char *path1 = (const char *)path1_;") 2868 pcmd("const char *path2 = (const char *)path2_;") 2869 pcmd("if (res == 0) {") 2870 pcmd(" if (path1) {") 2871 pcmd(" POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2872 pcmd(" }") 2873 pcmd(" if (path2) {") 2874 pcmd(" POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2875 pcmd(" }") 2876 pcmd("}") 2877 } 2878 } else if (syscall == "unlinkat") { 2879 if (mode == "pre") { 2880 pcmd("const char *path = (const char *)path_;") 2881 pcmd("if (path) {") 2882 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2883 pcmd("}") 2884 } else { 2885 pcmd("const char *path = (const char *)path_;") 2886 pcmd("if (res == 0) {") 2887 pcmd(" if (path) {") 2888 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2889 pcmd(" }") 2890 pcmd("}") 2891 } 2892 } else if (syscall == "futimens") { 2893 if (mode == "pre") { 2894 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2895 pcmd("if (tptr) {") 2896 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2897 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2898 pcmd("}") 2899 } else { 2900 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2901 pcmd("if (res == 0) {") 2902 pcmd(" if (tptr) {") 2903 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2904 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2905 pcmd(" }") 2906 pcmd("}") 2907 } 2908 } else if (syscall == "__quotactl") { 2909 if (mode == "pre") { 2910 pcmd("const char *path = (const char *)path_;") 2911 pcmd("if (path) {") 2912 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2913 pcmd("}") 2914 } else { 2915 pcmd("const char *path = (const char *)path_;") 2916 pcmd("if (res == 0) {") 2917 pcmd(" if (path) {") 2918 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2919 pcmd(" }") 2920 pcmd("}") 2921 } 2922 } else if (syscall == "posix_spawn") { 2923 if (mode == "pre") { 2924 pcmd("const char *path = (const char *)path_;") 2925 pcmd("if (path) {") 2926 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2927 pcmd("}") 2928 } else { 2929 pcmd("const char *path = (const char *)path_;") 2930 pcmd("if (pid_) {") 2931 pcmd(" if (path) {") 2932 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2933 pcmd(" }") 2934 pcmd("}") 2935 } 2936 } else if (syscall == "recvmmsg") { 2937 if (mode == "pre") { 2938 pcmd("if (timeout_) {") 2939 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2940 pcmd("}") 2941 } else { 2942 pcmd("if (res >= 0) {") 2943 pcmd(" if (timeout_) {") 2944 pcmd(" POST_READ(timeout_, struct_timespec_sz);") 2945 pcmd(" }") 2946 pcmd("}") 2947 } 2948 } else if (syscall == "sendmmsg") { 2949 if (mode == "pre") { 2950 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2951 pcmd("if (mmsg) {") 2952 pcmd(" PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2953 pcmd("}") 2954 } else { 2955 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2956 pcmd("if (res >= 0) {") 2957 pcmd(" if (mmsg) {") 2958 pcmd(" POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2959 pcmd(" }") 2960 pcmd("}") 2961 } 2962 } else if (syscall == "clock_nanosleep") { 2963 if (mode == "pre") { 2964 pcmd("if (rqtp_) {") 2965 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2966 pcmd("}") 2967 } else { 2968 pcmd("if (rqtp_) {") 2969 pcmd(" POST_READ(rqtp_, struct_timespec_sz);") 2970 pcmd("}") 2971 } 2972 } else if (syscall == "___lwp_park60") { 2973 if (mode == "pre") { 2974 pcmd("if (ts_) {") 2975 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2976 pcmd("}") 2977 } else { 2978 pcmd("if (res == 0) {") 2979 pcmd(" if (ts_) {") 2980 pcmd(" POST_READ(ts_, struct_timespec_sz);") 2981 pcmd(" }") 2982 pcmd("}") 2983 } 2984 } else if (syscall == "posix_fallocate") { 2985 pcmd("/* Nothing to do */") 2986 } else if (syscall == "fdiscard") { 2987 pcmd("/* Nothing to do */") 2988 } else if (syscall == "wait6") { 2989 pcmd("/* Nothing to do */") 2990 } else if (syscall == "clock_getcpuclockid2") { 2991 pcmd("/* Nothing to do */") 2992 } else if (syscall == "__getvfsstat90") { 2993 pcmd("/* Nothing to do */") 2994 } else if (syscall == "__statvfs190") { 2995 if (mode == "pre") { 2996 pcmd("const char *path = (const char *)path_;") 2997 pcmd("if (path) {") 2998 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2999 pcmd("}") 3000 } else { 3001 pcmd("const char *path = (const char *)path_;") 3002 pcmd("if (path) {") 3003 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 3004 pcmd("}") 3005 } 3006 } else if (syscall == "__fstatvfs190") { 3007 pcmd("/* Nothing to do */") 3008 } else if (syscall == "__fhstatvfs190") { 3009 if (mode == "pre") { 3010 pcmd("if (fhp_) {") 3011 pcmd(" PRE_READ(fhp_, fh_size_);") 3012 pcmd("}") 3013 } 3014 } else { 3015 print "Unrecognized syscall: " syscall 3016 abnormal_exit = 1 3017 exit 1 3018 } 3019} 3020