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.30. 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_lwpstatus) {") 737 pcmd(" struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;") 738 pcmd(" PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 739 pcmd(" PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);") 740 pcmd("} else if (req_ == ptrace_pt_lwpnext) {") 741 pcmd(" struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;") 742 pcmd(" PRE_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 743 pcmd(" PRE_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);") 744 pcmd("} else if (req_ == ptrace_pt_setregs) {") 745 pcmd(" PRE_READ(addr_, struct_ptrace_reg_struct_sz);") 746 pcmd("} else if (req_ == ptrace_pt_getregs) {") 747 pcmd(" PRE_WRITE(addr_, struct_ptrace_reg_struct_sz);") 748 pcmd("} else if (req_ == ptrace_pt_setfpregs) {") 749 pcmd(" PRE_READ(addr_, struct_ptrace_fpreg_struct_sz);") 750 pcmd("} else if (req_ == ptrace_pt_getfpregs) {") 751 pcmd(" PRE_WRITE(addr_, struct_ptrace_fpreg_struct_sz);") 752 pcmd("} else if (req_ == ptrace_pt_setdbregs) {") 753 pcmd(" PRE_READ(addr_, struct_ptrace_dbreg_struct_sz);") 754 pcmd("} else if (req_ == ptrace_pt_getdbregs) {") 755 pcmd(" PRE_WRITE(addr_, struct_ptrace_dbreg_struct_sz);") 756 pcmd("}") 757 } else { 758 pcmd("if (res == 0) {") 759 pcmd(" if (req_ == ptrace_pt_io) {") 760 pcmd(" struct __sanitizer_ptrace_io_desc *addr = (struct __sanitizer_ptrace_io_desc *)addr_;") 761 pcmd(" POST_READ(addr, struct_ptrace_ptrace_io_desc_struct_sz);") 762 pcmd(" if (addr->piod_op == ptrace_piod_write_d || addr->piod_op == ptrace_piod_write_i) {") 763 pcmd(" POST_READ(addr->piod_addr, addr->piod_len);") 764 pcmd(" }") 765 pcmd(" if (addr->piod_op == ptrace_piod_read_d || addr->piod_op == ptrace_piod_read_i || addr->piod_op == ptrace_piod_read_auxv) {") 766 pcmd(" POST_WRITE(addr->piod_addr, addr->piod_len);") 767 pcmd(" }") 768 pcmd(" } else if (req_ == ptrace_pt_lwpinfo) {") 769 pcmd(" struct __sanitizer_ptrace_lwpinfo *addr = (struct __sanitizer_ptrace_lwpinfo *)addr_;") 770 pcmd(" POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 771 pcmd(" POST_WRITE(addr, struct_ptrace_ptrace_lwpinfo_struct_sz);") 772 pcmd(" } else if (req_ == ptrace_pt_set_event_mask) {") 773 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_event_struct_sz);") 774 pcmd(" } else if (req_ == ptrace_pt_get_event_mask) {") 775 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_event_struct_sz);") 776 pcmd(" } else if (req_ == ptrace_pt_set_siginfo) {") 777 pcmd(" POST_READ(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 778 pcmd(" } else if (req_ == ptrace_pt_get_siginfo) {") 779 pcmd(" POST_WRITE(addr_, struct_ptrace_ptrace_siginfo_struct_sz);") 780 pcmd(" } else if (req_ == ptrace_pt_lwpstatus) {") 781 pcmd(" struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;") 782 pcmd(" POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 783 pcmd(" POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);") 784 pcmd(" } else if (req_ == ptrace_pt_lwpnext) {") 785 pcmd(" struct __sanitizer_ptrace_lwpstatus *addr = (struct __sanitizer_ptrace_lwpstatus *)addr_;") 786 pcmd(" POST_READ(&addr->pl_lwpid, sizeof(__sanitizer_lwpid_t));") 787 pcmd(" POST_WRITE(addr, struct_ptrace_ptrace_lwpstatus_struct_sz);") 788 pcmd(" } else if (req_ == ptrace_pt_setregs) {") 789 pcmd(" POST_READ(addr_, struct_ptrace_reg_struct_sz);") 790 pcmd(" } else if (req_ == ptrace_pt_getregs) {") 791 pcmd(" POST_WRITE(addr_, struct_ptrace_reg_struct_sz);") 792 pcmd(" } else if (req_ == ptrace_pt_setfpregs) {") 793 pcmd(" POST_READ(addr_, struct_ptrace_fpreg_struct_sz);") 794 pcmd(" } else if (req_ == ptrace_pt_getfpregs) {") 795 pcmd(" POST_WRITE(addr_, struct_ptrace_fpreg_struct_sz);") 796 pcmd(" } else if (req_ == ptrace_pt_setdbregs) {") 797 pcmd(" POST_READ(addr_, struct_ptrace_dbreg_struct_sz);") 798 pcmd(" } else if (req_ == ptrace_pt_getdbregs) {") 799 pcmd(" POST_WRITE(addr_, struct_ptrace_dbreg_struct_sz);") 800 pcmd(" }") 801 pcmd("}") 802 } 803 } else if (syscall == "recvmsg") { 804 if (mode == "pre") { 805 pcmd("PRE_WRITE(msg_, sizeof(__sanitizer_msghdr));") 806 } else { 807 pcmd("if (res > 0) {") 808 pcmd(" POST_WRITE(msg_, sizeof(__sanitizer_msghdr));") 809 pcmd("}") 810 } 811 } else if (syscall == "sendmsg") { 812 if (mode == "pre") { 813 pcmd("PRE_READ(msg_, sizeof(__sanitizer_msghdr));") 814 } else { 815 pcmd("if (res > 0) {") 816 pcmd(" POST_READ(msg_, sizeof(__sanitizer_msghdr));") 817 pcmd("}") 818 } 819 } else if (syscall == "recvfrom") { 820 if (mode == "pre") { 821 pcmd("PRE_WRITE(buf_, len_);") 822 pcmd("PRE_WRITE(from_, struct_sockaddr_sz);") 823 pcmd("PRE_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));") 824 } else { 825 pcmd("if (res >= 0) {") 826 pcmd(" POST_WRITE(buf_, res);") 827 pcmd(" POST_WRITE(from_, struct_sockaddr_sz);") 828 pcmd(" POST_WRITE(fromlenaddr_, sizeof(__sanitizer_socklen_t));") 829 pcmd("}") 830 } 831 } else if (syscall == "accept") { 832 if (mode == "pre") { 833 pcmd("PRE_WRITE(name_, struct_sockaddr_sz);") 834 pcmd("PRE_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));") 835 } else { 836 pcmd("if (res == 0) {") 837 pcmd(" POST_WRITE(name_, struct_sockaddr_sz);") 838 pcmd(" POST_WRITE(anamelen_, sizeof(__sanitizer_socklen_t));") 839 pcmd("}") 840 } 841 } else if (syscall == "getpeername") { 842 if (mode == "pre") { 843 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);") 844 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 845 } else { 846 pcmd("if (res == 0) {") 847 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);") 848 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 849 pcmd("}") 850 } 851 } else if (syscall == "getsockname") { 852 if (mode == "pre") { 853 pcmd("PRE_WRITE(asa_, struct_sockaddr_sz);") 854 pcmd("PRE_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 855 } else { 856 pcmd("if (res == 0) {") 857 pcmd(" POST_WRITE(asa_, struct_sockaddr_sz);") 858 pcmd(" POST_WRITE(alen_, sizeof(__sanitizer_socklen_t));") 859 pcmd("}") 860 } 861 } else if (syscall == "access") { 862 if (mode == "pre") { 863 pcmd("const char *path = (const char *)path_;") 864 pcmd("if (path) {") 865 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 866 pcmd("}") 867 } else { 868 pcmd("if (res == 0) {") 869 pcmd(" const char *path = (const char *)path_;") 870 pcmd(" if (path) {") 871 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 872 pcmd(" }") 873 pcmd("}") 874 } 875 } else if (syscall == "chflags") { 876 if (mode == "pre") { 877 pcmd("const char *path = (const char *)path_;") 878 pcmd("if (path) {") 879 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 880 pcmd("}") 881 } else { 882 pcmd("if (res == 0) {") 883 pcmd(" const char *path = (const char *)path_;") 884 pcmd(" if (path) {") 885 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 886 pcmd(" }") 887 pcmd("}") 888 } 889 } else if (syscall == "fchflags") { 890 pcmd("/* Nothing to do */") 891 } else if (syscall == "sync") { 892 pcmd("/* Nothing to do */") 893 } else if (syscall == "kill") { 894 pcmd("/* Nothing to do */") 895 } else if (syscall == "compat_43_stat43") { 896 pcmd("/* TODO */") 897 } else if (syscall == "getppid") { 898 pcmd("/* Nothing to do */") 899 } else if (syscall == "compat_43_lstat43") { 900 pcmd("/* TODO */") 901 } else if (syscall == "dup") { 902 pcmd("/* Nothing to do */") 903 } else if (syscall == "pipe") { 904 pcmd("/* pipe returns two descriptors through two returned values */") 905 } else if (syscall == "getegid") { 906 pcmd("/* Nothing to do */") 907 } else if (syscall == "profil") { 908 if (mode == "pre") { 909 pcmd("if (samples_) {") 910 pcmd(" PRE_WRITE(samples_, size_);") 911 pcmd("}") 912 } else { 913 pcmd("if (res == 0) {") 914 pcmd(" if (samples_) {") 915 pcmd(" POST_WRITE(samples_, size_);") 916 pcmd(" }") 917 pcmd("}") 918 } 919 } else if (syscall == "ktrace") { 920 if (mode == "pre") { 921 pcmd("const char *fname = (const char *)fname_;") 922 pcmd("if (fname) {") 923 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 924 pcmd("}") 925 } else { 926 pcmd("const char *fname = (const char *)fname_;") 927 pcmd("if (res == 0) {") 928 pcmd(" if (fname) {") 929 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 930 pcmd(" }") 931 pcmd("}") 932 } 933 } else if (syscall == "compat_13_sigaction13") { 934 pcmd("/* TODO */") 935 } else if (syscall == "getgid") { 936 pcmd("/* Nothing to do */") 937 } else if (syscall == "compat_13_sigprocmask13") { 938 pcmd("/* TODO */") 939 } else if (syscall == "__getlogin") { 940 if (mode == "pre") { 941 pcmd("if (namebuf_) {") 942 pcmd(" PRE_WRITE(namebuf_, namelen_);") 943 pcmd("}") 944 } else { 945 pcmd("if (res == 0) {") 946 pcmd(" if (namebuf_) {") 947 pcmd(" POST_WRITE(namebuf_, namelen_);") 948 pcmd(" }") 949 pcmd("}") 950 } 951 } else if (syscall == "__setlogin") { 952 if (mode == "pre") { 953 pcmd("const char *namebuf = (const char *)namebuf_;") 954 pcmd("if (namebuf) {") 955 pcmd(" PRE_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);") 956 pcmd("}") 957 } else { 958 pcmd("if (res == 0) {") 959 pcmd(" const char *namebuf = (const char *)namebuf_;") 960 pcmd(" if (namebuf) {") 961 pcmd(" POST_READ(namebuf, __sanitizer::internal_strlen(namebuf) + 1);") 962 pcmd(" }") 963 pcmd("}") 964 } 965 } else if (syscall == "acct") { 966 if (mode == "pre") { 967 pcmd("const char *path = (const char *)path_;") 968 pcmd("if (path) {") 969 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 970 pcmd("}") 971 } else { 972 pcmd("if (res == 0) {") 973 pcmd(" const char *path = (const char *)path_;") 974 pcmd(" if (path) {") 975 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 976 pcmd(" }") 977 pcmd("}") 978 } 979 } else if (syscall == "compat_13_sigpending13") { 980 pcmd("/* TODO */") 981 } else if (syscall == "compat_13_sigaltstack13") { 982 pcmd("/* TODO */") 983 } else if (syscall == "ioctl") { 984 pcmd("/* Nothing to do */") 985 } else if (syscall == "compat_12_oreboot") { 986 pcmd("/* TODO */") 987 } else if (syscall == "revoke") { 988 if (mode == "pre") { 989 pcmd("const char *path = (const char *)path_;") 990 pcmd("if (path) {") 991 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 992 pcmd("}") 993 } else { 994 pcmd("if (res == 0) {") 995 pcmd(" const char *path = (const char *)path_;") 996 pcmd(" if (path) {") 997 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 998 pcmd(" }") 999 pcmd("}") 1000 } 1001 } else if (syscall == "symlink") { 1002 if (mode == "pre") { 1003 pcmd("const char *path = (const char *)path_;") 1004 pcmd("const char *link = (const char *)link_;") 1005 pcmd("if (path) {") 1006 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1007 pcmd("}") 1008 pcmd("if (link) {") 1009 pcmd(" PRE_READ(link, __sanitizer::internal_strlen(link) + 1);") 1010 pcmd("}") 1011 } else { 1012 pcmd("if (res == 0) {") 1013 pcmd(" const char *path = (const char *)path_;") 1014 pcmd(" const char *link = (const char *)link_;") 1015 pcmd(" if (path) {") 1016 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1017 pcmd(" }") 1018 pcmd(" if (link) {") 1019 pcmd(" POST_READ(link, __sanitizer::internal_strlen(link) + 1);") 1020 pcmd(" }") 1021 pcmd("}") 1022 } 1023 } else if (syscall == "readlink") { 1024 if (mode == "pre") { 1025 pcmd("const char *path = (const char *)path_;") 1026 pcmd("if (path) {") 1027 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1028 pcmd("}") 1029 pcmd("if (buf_) {") 1030 pcmd(" PRE_WRITE(buf_, count_);") 1031 pcmd("}") 1032 } else { 1033 pcmd("if (res > 0) {") 1034 pcmd(" const char *path = (const char *)path_;") 1035 pcmd(" if (path) {") 1036 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1037 pcmd(" }") 1038 pcmd(" if (buf_) {") 1039 pcmd(" PRE_WRITE(buf_, res);") 1040 pcmd(" }") 1041 pcmd("}") 1042 } 1043 } else if (syscall == "execve") { 1044 if (mode == "pre") { 1045 pcmd("const char *path = (const char *)path_;") 1046 pcmd("char **argp = (char **)argp_;") 1047 pcmd("char **envp = (char **)envp_;") 1048 pcmd("if (path) {") 1049 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1050 pcmd("}") 1051 pcmd("if (argp && argp[0]) {") 1052 pcmd(" char *a = argp[0];") 1053 pcmd(" while (a++) {") 1054 pcmd(" PRE_READ(a, __sanitizer::internal_strlen(a) + 1);") 1055 pcmd(" }") 1056 pcmd("}") 1057 pcmd("if (envp && envp[0]) {") 1058 pcmd(" char *e = envp[0];") 1059 pcmd(" while (e++) {") 1060 pcmd(" PRE_READ(e, __sanitizer::internal_strlen(e) + 1);") 1061 pcmd(" }") 1062 pcmd("}") 1063 } else { 1064 pcmd("/* If we are here, something went wrong */") 1065 pcmd("const char *path = (const char *)path_;") 1066 pcmd("char **argp = (char **)argp_;") 1067 pcmd("char **envp = (char **)envp_;") 1068 pcmd("if (path) {") 1069 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1070 pcmd("}") 1071 pcmd("if (argp && argp[0]) {") 1072 pcmd(" char *a = argp[0];") 1073 pcmd(" while (a++) {") 1074 pcmd(" POST_READ(a, __sanitizer::internal_strlen(a) + 1);") 1075 pcmd(" }") 1076 pcmd("}") 1077 pcmd("if (envp && envp[0]) {") 1078 pcmd(" char *e = envp[0];") 1079 pcmd(" while (e++) {") 1080 pcmd(" POST_READ(e, __sanitizer::internal_strlen(e) + 1);") 1081 pcmd(" }") 1082 pcmd("}") 1083 } 1084 } else if (syscall == "umask") { 1085 pcmd("/* Nothing to do */") 1086 } else if (syscall == "chroot") { 1087 if (mode == "pre") { 1088 pcmd("const char *path = (const char *)path_;") 1089 pcmd("if (path) {") 1090 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1091 pcmd("}") 1092 } else { 1093 pcmd("if (res == 0) {") 1094 pcmd(" const char *path = (const char *)path_;") 1095 pcmd(" if (path) {") 1096 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1097 pcmd(" }") 1098 pcmd("}") 1099 } 1100 } else if (syscall == "compat_43_fstat43") { 1101 pcmd("/* TODO */") 1102 } else if (syscall == "compat_43_ogetkerninfo") { 1103 pcmd("/* TODO */") 1104 } else if (syscall == "compat_43_ogetpagesize") { 1105 pcmd("/* TODO */") 1106 } else if (syscall == "compat_12_msync") { 1107 pcmd("/* TODO */") 1108 } else if (syscall == "vfork") { 1109 pcmd("/* Nothing to do */") 1110 } else if (syscall == "compat_43_ommap") { 1111 pcmd("/* TODO */") 1112 } else if (syscall == "vadvise") { 1113 pcmd("/* Nothing to do */") 1114 } else if (syscall == "munmap") { 1115 pcmd("/* Nothing to do */") 1116 } else if (syscall == "mprotect") { 1117 pcmd("/* Nothing to do */") 1118 } else if (syscall == "madvise") { 1119 pcmd("/* Nothing to do */") 1120 } else if (syscall == "mincore") { 1121 pcmd("/* Nothing to do */") 1122 } else if (syscall == "getgroups") { 1123 if (mode == "pre") { 1124 pcmd("unsigned int *gidset = (unsigned int *)gidset_;") 1125 pcmd("if (gidset) {") 1126 pcmd(" PRE_WRITE(gidset, sizeof(*gidset) * gidsetsize_);") 1127 pcmd("}") 1128 } else { 1129 pcmd("if (res == 0) {") 1130 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;") 1131 pcmd(" if (gidset) {") 1132 pcmd(" POST_WRITE(gidset, sizeof(*gidset) * gidsetsize_);") 1133 pcmd(" }") 1134 pcmd("}") 1135 } 1136 } else if (syscall == "setgroups") { 1137 if (mode == "pre") { 1138 pcmd("unsigned int *gidset = (unsigned int *)gidset_;") 1139 pcmd("if (gidset) {") 1140 pcmd(" PRE_READ(gidset, sizeof(*gidset) * gidsetsize_);") 1141 pcmd("}") 1142 } else { 1143 pcmd("if (res == 0) {") 1144 pcmd(" unsigned int *gidset = (unsigned int *)gidset_;") 1145 pcmd(" if (gidset) {") 1146 pcmd(" POST_READ(gidset, sizeof(*gidset) * gidsetsize_);") 1147 pcmd(" }") 1148 pcmd("}") 1149 } 1150 } else if (syscall == "getpgrp") { 1151 pcmd("/* Nothing to do */") 1152 } else if (syscall == "setpgid") { 1153 pcmd("/* Nothing to do */") 1154 } else if (syscall == "compat_50_setitimer") { 1155 pcmd("/* TODO */") 1156 } else if (syscall == "compat_43_owait") { 1157 pcmd("/* TODO */") 1158 } else if (syscall == "compat_12_oswapon") { 1159 pcmd("/* TODO */") 1160 } else if (syscall == "compat_50_getitimer") { 1161 pcmd("/* TODO */") 1162 } else if (syscall == "compat_43_ogethostname") { 1163 pcmd("/* TODO */") 1164 } else if (syscall == "compat_43_osethostname") { 1165 pcmd("/* TODO */") 1166 } else if (syscall == "compat_43_ogetdtablesize") { 1167 pcmd("/* TODO */") 1168 } else if (syscall == "dup2") { 1169 pcmd("/* Nothing to do */") 1170 } else if (syscall == "getrandom") { 1171 pcmd("/* TODO */") 1172 } else if (syscall == "fcntl") { 1173 pcmd("/* Nothing to do */") 1174 } else if (syscall == "compat_50_select") { 1175 pcmd("/* TODO */") 1176 } else if (syscall == "fsync") { 1177 pcmd("/* Nothing to do */") 1178 } else if (syscall == "setpriority") { 1179 pcmd("/* Nothing to do */") 1180 } else if (syscall == "compat_30_socket") { 1181 pcmd("/* TODO */") 1182 } else if (syscall == "connect") { 1183 if (mode == "pre") { 1184 pcmd("PRE_READ(name_, namelen_);") 1185 } else { 1186 pcmd("if (res == 0) {") 1187 pcmd(" POST_READ(name_, namelen_);") 1188 pcmd("}") 1189 } 1190 } else if (syscall == "compat_43_oaccept") { 1191 pcmd("/* TODO */") 1192 } else if (syscall == "getpriority") { 1193 pcmd("/* Nothing to do */") 1194 } else if (syscall == "compat_43_osend") { 1195 pcmd("/* TODO */") 1196 } else if (syscall == "compat_43_orecv") { 1197 pcmd("/* TODO */") 1198 } else if (syscall == "compat_13_sigreturn13") { 1199 pcmd("/* TODO */") 1200 } else if (syscall == "bind") { 1201 if (mode == "pre") { 1202 pcmd("PRE_READ(name_, namelen_);") 1203 } else { 1204 pcmd("if (res == 0) {") 1205 pcmd(" PRE_READ(name_, namelen_);") 1206 pcmd("}") 1207 } 1208 } else if (syscall == "setsockopt") { 1209 if (mode == "pre") { 1210 pcmd("if (val_) {") 1211 pcmd(" PRE_READ(val_, valsize_);") 1212 pcmd("}") 1213 } else { 1214 pcmd("if (res == 0) {") 1215 pcmd(" if (val_) {") 1216 pcmd(" POST_READ(val_, valsize_);") 1217 pcmd(" }") 1218 pcmd("}") 1219 } 1220 } else if (syscall == "listen") { 1221 pcmd("/* Nothing to do */") 1222 } else if (syscall == "compat_43_osigvec") { 1223 pcmd("/* TODO */") 1224 } else if (syscall == "compat_43_osigblock") { 1225 pcmd("/* TODO */") 1226 } else if (syscall == "compat_43_osigsetmask") { 1227 pcmd("/* TODO */") 1228 } else if (syscall == "compat_13_sigsuspend13") { 1229 pcmd("/* TODO */") 1230 } else if (syscall == "compat_43_osigstack") { 1231 pcmd("/* TODO */") 1232 } else if (syscall == "compat_43_orecvmsg") { 1233 pcmd("/* TODO */") 1234 } else if (syscall == "compat_43_osendmsg") { 1235 pcmd("/* TODO */") 1236 } else if (syscall == "compat_50_gettimeofday") { 1237 pcmd("/* TODO */") 1238 } else if (syscall == "compat_50_getrusage") { 1239 pcmd("/* TODO */") 1240 } else if (syscall == "getsockopt") { 1241 pcmd("/* TODO */") 1242 } else if (syscall == "readv") { 1243 if (mode == "pre") { 1244 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1245 pcmd("int i;") 1246 pcmd("if (iovp) {") 1247 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1248 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1249 pcmd(" PRE_WRITE(iovp[i].iov_base, iovp[i].iov_len);") 1250 pcmd(" }") 1251 pcmd("}") 1252 } else { 1253 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1254 pcmd("int i;") 1255 pcmd("uptr m, n = res;") 1256 pcmd("if (res > 0) {") 1257 pcmd(" if (iovp) {") 1258 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1259 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1260 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1261 pcmd(" POST_WRITE(iovp[i].iov_base, m);") 1262 pcmd(" n -= m;") 1263 pcmd(" }") 1264 pcmd(" }") 1265 pcmd("}") 1266 } 1267 } else if (syscall == "writev") { 1268 if (mode == "pre") { 1269 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1270 pcmd("int i;") 1271 pcmd("if (iovp) {") 1272 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1273 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1274 pcmd(" PRE_READ(iovp[i].iov_base, iovp[i].iov_len);") 1275 pcmd(" }") 1276 pcmd("}") 1277 } else { 1278 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1279 pcmd("int i;") 1280 pcmd("uptr m, n = res;") 1281 pcmd("if (res > 0) {") 1282 pcmd(" if (iovp) {") 1283 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1284 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1285 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1286 pcmd(" POST_READ(iovp[i].iov_base, m);") 1287 pcmd(" n -= m;") 1288 pcmd(" }") 1289 pcmd(" }") 1290 pcmd("}") 1291 } 1292 } else if (syscall == "compat_50_settimeofday") { 1293 pcmd("/* TODO */") 1294 } else if (syscall == "fchown") { 1295 pcmd("/* Nothing to do */") 1296 } else if (syscall == "fchmod") { 1297 pcmd("/* Nothing to do */") 1298 } else if (syscall == "compat_43_orecvfrom") { 1299 pcmd("/* TODO */") 1300 } else if (syscall == "setreuid") { 1301 pcmd("/* Nothing to do */") 1302 } else if (syscall == "setregid") { 1303 pcmd("/* Nothing to do */") 1304 } else if (syscall == "rename") { 1305 if (mode == "pre") { 1306 pcmd("const char *from = (const char *)from_;") 1307 pcmd("const char *to = (const char *)to_;") 1308 pcmd("if (from) {") 1309 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1310 pcmd("}") 1311 pcmd("if (to) {") 1312 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1313 pcmd("}") 1314 } else { 1315 pcmd("if (res == 0) {") 1316 pcmd(" const char *from = (const char *)from_;") 1317 pcmd(" const char *to = (const char *)to_;") 1318 pcmd(" if (from) {") 1319 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1320 pcmd(" }") 1321 pcmd(" if (to) {") 1322 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1323 pcmd(" }") 1324 pcmd("}") 1325 } 1326 } else if (syscall == "compat_43_otruncate") { 1327 pcmd("/* TODO */") 1328 } else if (syscall == "compat_43_oftruncate") { 1329 pcmd("/* TODO */") 1330 } else if (syscall == "flock") { 1331 pcmd("/* Nothing to do */") 1332 } else if (syscall == "mkfifo") { 1333 if (mode == "pre") { 1334 pcmd("const char *path = (const char *)path_;") 1335 pcmd("if (path) {") 1336 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1337 pcmd("}") 1338 } else { 1339 pcmd("if (res == 0) {") 1340 pcmd(" const char *path = (const char *)path_;") 1341 pcmd(" if (path) {") 1342 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1343 pcmd(" }") 1344 pcmd("}") 1345 } 1346 } else if (syscall == "sendto") { 1347 if (mode == "pre") { 1348 pcmd("PRE_READ(buf_, len_);") 1349 pcmd("PRE_READ(to_, tolen_);") 1350 } else { 1351 pcmd("if (res >= 0) {") 1352 pcmd(" POST_READ(buf_, len_);") 1353 pcmd(" POST_READ(to_, tolen_);") 1354 pcmd("}") 1355 } 1356 } else if (syscall == "shutdown") { 1357 pcmd("/* Nothing to do */") 1358 } else if (syscall == "socketpair") { 1359 if (mode == "pre") { 1360 pcmd("PRE_WRITE(rsv_, 2 * sizeof(int));") 1361 } else { 1362 pcmd("if (res == 0) {") 1363 pcmd(" POST_WRITE(rsv_, 2 * sizeof(int));") 1364 pcmd("}") 1365 } 1366 } else if (syscall == "mkdir") { 1367 if (mode == "pre") { 1368 pcmd("const char *path = (const char *)path_;") 1369 pcmd("if (path) {") 1370 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1371 pcmd("}") 1372 } else { 1373 pcmd("if (res == 0) {") 1374 pcmd(" const char *path = (const char *)path_;") 1375 pcmd(" if (path) {") 1376 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1377 pcmd(" }") 1378 pcmd("}") 1379 } 1380 } else if (syscall == "rmdir") { 1381 if (mode == "pre") { 1382 pcmd("const char *path = (const char *)path_;") 1383 pcmd("if (path) {") 1384 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1385 pcmd("}") 1386 } else { 1387 pcmd("if (res == 0) {") 1388 pcmd(" const char *path = (const char *)path_;") 1389 pcmd(" if (path) {") 1390 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1391 pcmd(" }") 1392 pcmd("}") 1393 } 1394 } else if (syscall == "compat_50_utimes") { 1395 pcmd("/* TODO */") 1396 } else if (syscall == "compat_50_adjtime") { 1397 pcmd("/* TODO */") 1398 } else if (syscall == "compat_43_ogetpeername") { 1399 pcmd("/* TODO */") 1400 } else if (syscall == "compat_43_ogethostid") { 1401 pcmd("/* TODO */") 1402 } else if (syscall == "compat_43_osethostid") { 1403 pcmd("/* TODO */") 1404 } else if (syscall == "compat_43_ogetrlimit") { 1405 pcmd("/* TODO */") 1406 } else if (syscall == "compat_43_osetrlimit") { 1407 pcmd("/* TODO */") 1408 } else if (syscall == "compat_43_okillpg") { 1409 pcmd("/* TODO */") 1410 } else if (syscall == "setsid") { 1411 pcmd("/* Nothing to do */") 1412 } else if (syscall == "compat_50_quotactl") { 1413 pcmd("/* TODO */") 1414 } else if (syscall == "compat_43_oquota") { 1415 pcmd("/* TODO */") 1416 } else if (syscall == "compat_43_ogetsockname") { 1417 pcmd("/* TODO */") 1418 } else if (syscall == "nfssvc") { 1419 pcmd("/* Nothing to do */") 1420 } else if (syscall == "compat_43_ogetdirentries") { 1421 pcmd("/* TODO */") 1422 } else if (syscall == "compat_20_statfs") { 1423 pcmd("/* TODO */") 1424 } else if (syscall == "compat_20_fstatfs") { 1425 pcmd("/* TODO */") 1426 } else if (syscall == "compat_30_getfh") { 1427 pcmd("/* TODO */") 1428 } else if (syscall == "compat_09_ogetdomainname") { 1429 pcmd("/* TODO */") 1430 } else if (syscall == "compat_09_osetdomainname") { 1431 pcmd("/* TODO */") 1432 } else if (syscall == "compat_09_ouname") { 1433 pcmd("/* TODO */") 1434 } else if (syscall == "sysarch") { 1435 pcmd("/* TODO */") 1436 } else if (syscall == "__futex") { 1437 pcmd("/* TODO */") 1438 } else if (syscall == "__futex_set_robust_list") { 1439 pcmd("/* TODO */") 1440 } else if (syscall == "__futex_get_robust_list") { 1441 pcmd("/* TODO */") 1442 } else if (syscall == "compat_10_osemsys") { 1443 pcmd("/* TODO */") 1444 } else if (syscall == "compat_10_omsgsys") { 1445 pcmd("/* TODO */") 1446 } else if (syscall == "compat_10_oshmsys") { 1447 pcmd("/* TODO */") 1448 } else if (syscall == "pread") { 1449 if (mode == "pre") { 1450 pcmd("if (buf_) {") 1451 pcmd(" PRE_WRITE(buf_, nbyte_);") 1452 pcmd("}") 1453 } else { 1454 pcmd("if (res > 0) {") 1455 pcmd(" POST_WRITE(buf_, res);") 1456 pcmd("}") 1457 } 1458 } else if (syscall == "pwrite") { 1459 if (mode == "pre") { 1460 pcmd("if (buf_) {") 1461 pcmd(" PRE_READ(buf_, nbyte_);") 1462 pcmd("}") 1463 } else { 1464 pcmd("if (res > 0) {") 1465 pcmd(" POST_READ(buf_, res);") 1466 pcmd("}") 1467 } 1468 } else if (syscall == "compat_30_ntp_gettime") { 1469 pcmd("/* TODO */") 1470 } else if (syscall == "ntp_adjtime") { 1471 pcmd("/* Nothing to do */") 1472 } else if (syscall == "setgid") { 1473 pcmd("/* Nothing to do */") 1474 } else if (syscall == "setegid") { 1475 pcmd("/* Nothing to do */") 1476 } else if (syscall == "seteuid") { 1477 pcmd("/* Nothing to do */") 1478 } else if (syscall == "lfs_bmapv") { 1479 pcmd("/* TODO */") 1480 } else if (syscall == "lfs_markv") { 1481 pcmd("/* TODO */") 1482 } else if (syscall == "lfs_segclean") { 1483 pcmd("/* TODO */") 1484 } else if (syscall == "compat_50_lfs_segwait") { 1485 pcmd("/* TODO */") 1486 } else if (syscall == "compat_12_stat12") { 1487 pcmd("/* TODO */") 1488 } else if (syscall == "compat_12_fstat12") { 1489 pcmd("/* TODO */") 1490 } else if (syscall == "compat_12_lstat12") { 1491 pcmd("/* TODO */") 1492 } else if (syscall == "pathconf") { 1493 if (mode == "pre") { 1494 pcmd("const char *path = (const char *)path_;") 1495 pcmd("if (path) {") 1496 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1497 pcmd("}") 1498 } else { 1499 pcmd("if (res != -1) {") 1500 pcmd(" const char *path = (const char *)path_;") 1501 pcmd(" if (path) {") 1502 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1503 pcmd(" }") 1504 pcmd("}") 1505 } 1506 } else if (syscall == "getsockopt2") { 1507 pcmd("/* TODO */") 1508 } else if (syscall == "fpathconf") { 1509 pcmd("/* Nothing to do */") 1510 } else if (syscall == "getrlimit") { 1511 if (mode == "pre") { 1512 pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);") 1513 } else { 1514 pcmd("if (res == 0) {") 1515 pcmd(" POST_WRITE(rlp_, struct_rlimit_sz);") 1516 pcmd("}") 1517 } 1518 } else if (syscall == "setrlimit") { 1519 if (mode == "pre") { 1520 pcmd("PRE_READ(rlp_, struct_rlimit_sz);") 1521 } else { 1522 pcmd("if (res == 0) {") 1523 pcmd(" POST_READ(rlp_, struct_rlimit_sz);") 1524 pcmd("}") 1525 } 1526 } else if (syscall == "compat_12_getdirentries") { 1527 pcmd("/* TODO */") 1528 } else if (syscall == "mmap") { 1529 pcmd("/* Nothing to do */") 1530 } else if (syscall == "__syscall") { 1531 pcmd("/* Nothing to do */") 1532 } else if (syscall == "lseek") { 1533 pcmd("/* Nothing to do */") 1534 } else if (syscall == "truncate") { 1535 if (mode == "pre") { 1536 pcmd("const char *path = (const char *)path_;") 1537 pcmd("if (path) {") 1538 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1539 pcmd("}") 1540 } else { 1541 pcmd("if (res == 0) {") 1542 pcmd(" const char *path = (const char *)path_;") 1543 pcmd(" if (path) {") 1544 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1545 pcmd(" }") 1546 pcmd("}") 1547 } 1548 } else if (syscall == "ftruncate") { 1549 pcmd("/* Nothing to do */") 1550 } else if (syscall == "__sysctl") { 1551 if (mode == "pre") { 1552 pcmd("const int *name = (const int *)name_;") 1553 pcmd("if (name) {") 1554 pcmd(" PRE_READ(name, namelen_ * sizeof(*name));") 1555 pcmd("}") 1556 pcmd("if (newv_) {") 1557 pcmd(" PRE_READ(name, newlen_);") 1558 pcmd("}") 1559 } else { 1560 pcmd("if (res == 0) {") 1561 pcmd(" const int *name = (const int *)name_;") 1562 pcmd(" if (name) {") 1563 pcmd(" POST_READ(name, namelen_ * sizeof(*name));") 1564 pcmd(" }") 1565 pcmd(" if (newv_) {") 1566 pcmd(" POST_READ(name, newlen_);") 1567 pcmd(" }") 1568 pcmd("}") 1569 } 1570 } else if (syscall == "mlock") { 1571 pcmd("/* Nothing to do */") 1572 } else if (syscall == "munlock") { 1573 pcmd("/* Nothing to do */") 1574 } else if (syscall == "undelete") { 1575 if (mode == "pre") { 1576 pcmd("const char *path = (const char *)path_;") 1577 pcmd("if (path) {") 1578 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1579 pcmd("}") 1580 } else { 1581 pcmd("if (res == 0) {") 1582 pcmd(" const char *path = (const char *)path_;") 1583 pcmd(" if (path) {") 1584 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1585 pcmd(" }") 1586 pcmd("}") 1587 } 1588 } else if (syscall == "compat_50_futimes") { 1589 pcmd("/* TODO */") 1590 } else if (syscall == "getpgid") { 1591 pcmd("/* Nothing to do */") 1592 } else if (syscall == "reboot") { 1593 if (mode == "pre") { 1594 pcmd("const char *bootstr = (const char *)bootstr_;") 1595 pcmd("if (bootstr) {") 1596 pcmd(" PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1597 pcmd("}") 1598 } else { 1599 pcmd("/* This call should never return */") 1600 pcmd("const char *bootstr = (const char *)bootstr_;") 1601 pcmd("if (bootstr) {") 1602 pcmd(" POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1603 pcmd("}") 1604 } 1605 } else if (syscall == "poll") { 1606 pcmd("/* Nothing to do */") 1607 } else if (syscall == "afssys") { 1608 pcmd("/* TODO */") 1609 } else if (syscall == "compat_14___semctl") { 1610 pcmd("/* TODO */") 1611 } else if (syscall == "semget") { 1612 pcmd("/* Nothing to do */") 1613 } else if (syscall == "semop") { 1614 if (mode == "pre") { 1615 pcmd("if (sops_) {") 1616 pcmd(" PRE_READ(sops_, nsops_ * struct_sembuf_sz);") 1617 pcmd("}") 1618 } else { 1619 pcmd("if (res == 0) {") 1620 pcmd(" if (sops_) {") 1621 pcmd(" POST_READ(sops_, nsops_ * struct_sembuf_sz);") 1622 pcmd(" }") 1623 pcmd("}") 1624 } 1625 } else if (syscall == "semconfig") { 1626 pcmd("/* Nothing to do */") 1627 } else if (syscall == "compat_14_msgctl") { 1628 pcmd("/* TODO */") 1629 } else if (syscall == "msgget") { 1630 pcmd("/* Nothing to do */") 1631 } else if (syscall == "msgsnd") { 1632 if (mode == "pre") { 1633 pcmd("if (msgp_) {") 1634 pcmd(" PRE_READ(msgp_, msgsz_);") 1635 pcmd("}") 1636 } else { 1637 pcmd("if (res == 0) {") 1638 pcmd(" if (msgp_) {") 1639 pcmd(" POST_READ(msgp_, msgsz_);") 1640 pcmd(" }") 1641 pcmd("}") 1642 } 1643 } else if (syscall == "msgrcv") { 1644 pcmd("/* Nothing to do */") 1645 } else if (syscall == "shmat") { 1646 pcmd("/* Nothing to do */") 1647 } else if (syscall == "compat_14_shmctl") { 1648 pcmd("/* TODO */") 1649 } else if (syscall == "shmdt") { 1650 pcmd("/* Nothing to do */") 1651 } else if (syscall == "shmget") { 1652 pcmd("/* Nothing to do */") 1653 } else if (syscall == "compat_50_clock_gettime") { 1654 pcmd("/* TODO */") 1655 } else if (syscall == "compat_50_clock_settime") { 1656 pcmd("/* TODO */") 1657 } else if (syscall == "compat_50_clock_getres") { 1658 pcmd("/* TODO */") 1659 } else if (syscall == "timer_create") { 1660 pcmd("/* Nothing to do */") 1661 } else if (syscall == "timer_delete") { 1662 pcmd("/* Nothing to do */") 1663 } else if (syscall == "compat_50_timer_settime") { 1664 pcmd("/* TODO */") 1665 } else if (syscall == "compat_50_timer_gettime") { 1666 pcmd("/* TODO */") 1667 } else if (syscall == "timer_getoverrun") { 1668 pcmd("/* Nothing to do */") 1669 } else if (syscall == "compat_50_nanosleep") { 1670 pcmd("/* TODO */") 1671 } else if (syscall == "fdatasync") { 1672 pcmd("/* Nothing to do */") 1673 } else if (syscall == "mlockall") { 1674 pcmd("/* Nothing to do */") 1675 } else if (syscall == "munlockall") { 1676 pcmd("/* Nothing to do */") 1677 } else if (syscall == "compat_50___sigtimedwait") { 1678 pcmd("/* TODO */") 1679 } else if (syscall == "sigqueueinfo") { 1680 if (mode == "pre") { 1681 pcmd("if (info_) {") 1682 pcmd(" PRE_READ(info_, siginfo_t_sz);") 1683 pcmd("}") 1684 } 1685 } else if (syscall == "modctl") { 1686 pcmd("/* TODO */") 1687 } else if (syscall == "_ksem_init") { 1688 pcmd("/* Nothing to do */") 1689 } else if (syscall == "_ksem_open") { 1690 if (mode == "pre") { 1691 pcmd("const char *name = (const char *)name_;") 1692 pcmd("if (name) {") 1693 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1694 pcmd("}") 1695 } else { 1696 pcmd("const char *name = (const char *)name_;") 1697 pcmd("if (name) {") 1698 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1699 pcmd("}") 1700 } 1701 } else if (syscall == "_ksem_unlink") { 1702 if (mode == "pre") { 1703 pcmd("const char *name = (const char *)name_;") 1704 pcmd("if (name) {") 1705 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1706 pcmd("}") 1707 } else { 1708 pcmd("const char *name = (const char *)name_;") 1709 pcmd("if (name) {") 1710 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1711 pcmd("}") 1712 } 1713 } else if (syscall == "_ksem_close") { 1714 pcmd("/* Nothing to do */") 1715 } else if (syscall == "_ksem_post") { 1716 pcmd("/* Nothing to do */") 1717 } else if (syscall == "_ksem_wait") { 1718 pcmd("/* Nothing to do */") 1719 } else if (syscall == "_ksem_trywait") { 1720 pcmd("/* Nothing to do */") 1721 } else if (syscall == "_ksem_getvalue") { 1722 pcmd("/* Nothing to do */") 1723 } else if (syscall == "_ksem_destroy") { 1724 pcmd("/* Nothing to do */") 1725 } else if (syscall == "_ksem_timedwait") { 1726 if (mode == "pre") { 1727 pcmd("if (abstime_) {") 1728 pcmd(" PRE_READ(abstime_, struct_timespec_sz);") 1729 pcmd("}") 1730 } 1731 } else if (syscall == "mq_open") { 1732 if (mode == "pre") { 1733 pcmd("const char *name = (const char *)name_;") 1734 pcmd("if (name) {") 1735 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1736 pcmd("}") 1737 } else { 1738 pcmd("const char *name = (const char *)name_;") 1739 pcmd("if (name) {") 1740 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1741 pcmd("}") 1742 } 1743 } else if (syscall == "mq_close") { 1744 pcmd("/* Nothing to do */") 1745 } else if (syscall == "mq_unlink") { 1746 if (mode == "pre") { 1747 pcmd("const char *name = (const char *)name_;") 1748 pcmd("if (name) {") 1749 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1750 pcmd("}") 1751 } else { 1752 pcmd("const char *name = (const char *)name_;") 1753 pcmd("if (name) {") 1754 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1755 pcmd("}") 1756 } 1757 } else if (syscall == "mq_getattr") { 1758 pcmd("/* Nothing to do */") 1759 } else if (syscall == "mq_setattr") { 1760 if (mode == "pre") { 1761 pcmd("if (mqstat_) {") 1762 pcmd(" PRE_READ(mqstat_, struct_mq_attr_sz);") 1763 pcmd("}") 1764 } 1765 } else if (syscall == "mq_notify") { 1766 if (mode == "pre") { 1767 pcmd("if (notification_) {") 1768 pcmd(" PRE_READ(notification_, struct_sigevent_sz);") 1769 pcmd("}") 1770 } 1771 } else if (syscall == "mq_send") { 1772 if (mode == "pre") { 1773 pcmd("if (msg_ptr_) {") 1774 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 1775 pcmd("}") 1776 } 1777 } else if (syscall == "mq_receive") { 1778 pcmd("/* Nothing to do */") 1779 } else if (syscall == "compat_50_mq_timedsend") { 1780 pcmd("/* TODO */") 1781 } else if (syscall == "compat_50_mq_timedreceive") { 1782 pcmd("/* TODO */") 1783 } else if (syscall == "__posix_rename") { 1784 if (mode == "pre") { 1785 pcmd("const char *from = (const char *)from_;") 1786 pcmd("const char *to = (const char *)to_;") 1787 pcmd("if (from_) {") 1788 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1789 pcmd("}") 1790 pcmd("if (to) {") 1791 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1792 pcmd("}") 1793 } else { 1794 pcmd("const char *from = (const char *)from_;") 1795 pcmd("const char *to = (const char *)to_;") 1796 pcmd("if (from) {") 1797 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1798 pcmd("}") 1799 pcmd("if (to) {") 1800 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1801 pcmd("}") 1802 } 1803 } else if (syscall == "swapctl") { 1804 pcmd("/* TODO */") 1805 } else if (syscall == "compat_30_getdents") { 1806 pcmd("/* TODO */") 1807 } else if (syscall == "minherit") { 1808 pcmd("/* Nothing to do */") 1809 } else if (syscall == "lchmod") { 1810 if (mode == "pre") { 1811 pcmd("const char *path = (const char *)path_;") 1812 pcmd("if (path) {") 1813 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1814 pcmd("}") 1815 } else { 1816 pcmd("const char *path = (const char *)path_;") 1817 pcmd("if (path) {") 1818 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1819 pcmd("}") 1820 } 1821 } else if (syscall == "lchown") { 1822 if (mode == "pre") { 1823 pcmd("const char *path = (const char *)path_;") 1824 pcmd("if (path) {") 1825 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1826 pcmd("}") 1827 } else { 1828 pcmd("const char *path = (const char *)path_;") 1829 pcmd("if (path) {") 1830 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1831 pcmd("}") 1832 } 1833 } else if (syscall == "compat_50_lutimes") { 1834 pcmd("/* TODO */") 1835 } else if (syscall == "__msync13") { 1836 pcmd("/* Nothing to do */") 1837 } else if (syscall == "compat_30___stat13") { 1838 pcmd("/* TODO */") 1839 } else if (syscall == "compat_30___fstat13") { 1840 pcmd("/* TODO */") 1841 } else if (syscall == "compat_30___lstat13") { 1842 pcmd("/* TODO */") 1843 } else if (syscall == "__sigaltstack14") { 1844 if (mode == "pre") { 1845 pcmd("if (nss_) {") 1846 pcmd(" PRE_READ(nss_, struct_sigaltstack_sz);") 1847 pcmd("}") 1848 pcmd("if (oss_) {") 1849 pcmd(" PRE_READ(oss_, struct_sigaltstack_sz);") 1850 pcmd("}") 1851 } 1852 } else if (syscall == "__vfork14") { 1853 pcmd("/* Nothing to do */") 1854 } else if (syscall == "__posix_chown") { 1855 if (mode == "pre") { 1856 pcmd("const char *path = (const char *)path_;") 1857 pcmd("if (path) {") 1858 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1859 pcmd("}") 1860 } else { 1861 pcmd("const char *path = (const char *)path_;") 1862 pcmd("if (path) {") 1863 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1864 pcmd("}") 1865 } 1866 } else if (syscall == "__posix_fchown") { 1867 pcmd("/* Nothing to do */") 1868 } else if (syscall == "__posix_lchown") { 1869 if (mode == "pre") { 1870 pcmd("const char *path = (const char *)path_;") 1871 pcmd("if (path) {") 1872 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1873 pcmd("}") 1874 } else { 1875 pcmd("const char *path = (const char *)path_;") 1876 pcmd("if (path) {") 1877 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1878 pcmd("}") 1879 } 1880 } else if (syscall == "getsid") { 1881 pcmd("/* Nothing to do */") 1882 } else if (syscall == "__clone") { 1883 pcmd("/* Nothing to do */") 1884 } else if (syscall == "fktrace") { 1885 pcmd("/* Nothing to do */") 1886 } else if (syscall == "preadv") { 1887 pcmd("/* Nothing to do */") 1888 } else if (syscall == "pwritev") { 1889 pcmd("/* Nothing to do */") 1890 } else if (syscall == "compat_16___sigaction14") { 1891 pcmd("/* TODO */") 1892 } else if (syscall == "__sigpending14") { 1893 pcmd("/* Nothing to do */") 1894 } else if (syscall == "__sigprocmask14") { 1895 pcmd("/* Nothing to do */") 1896 } else if (syscall == "__sigsuspend14") { 1897 pcmd("if (set_) {") 1898 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 1899 pcmd("}") 1900 } else if (syscall == "compat_16___sigreturn14") { 1901 pcmd("/* TODO */") 1902 } else if (syscall == "__getcwd") { 1903 pcmd("/* Nothing to do */") 1904 } else if (syscall == "fchroot") { 1905 pcmd("/* Nothing to do */") 1906 } else if (syscall == "compat_30_fhopen") { 1907 pcmd("/* TODO */") 1908 } else if (syscall == "compat_30_fhstat") { 1909 pcmd("/* TODO */") 1910 } else if (syscall == "compat_20_fhstatfs") { 1911 pcmd("/* TODO */") 1912 } else if (syscall == "compat_50_____semctl13") { 1913 pcmd("/* TODO */") 1914 } else if (syscall == "compat_50___msgctl13") { 1915 pcmd("/* TODO */") 1916 } else if (syscall == "compat_50___shmctl13") { 1917 pcmd("/* TODO */") 1918 } else if (syscall == "lchflags") { 1919 if (mode == "pre") { 1920 pcmd("const char *path = (const char *)path_;") 1921 pcmd("if (path) {") 1922 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1923 pcmd("}") 1924 } else { 1925 pcmd("const char *path = (const char *)path_;") 1926 pcmd("if (path) {") 1927 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1928 pcmd("}") 1929 } 1930 } else if (syscall == "issetugid") { 1931 pcmd("/* Nothing to do */") 1932 } else if (syscall == "utrace") { 1933 if (mode == "pre") { 1934 pcmd("const char *label = (const char *)label_;") 1935 pcmd("if (label) {") 1936 pcmd(" PRE_READ(label, __sanitizer::internal_strlen(label) + 1);") 1937 pcmd("}") 1938 pcmd("if (addr_) {") 1939 pcmd(" PRE_READ(addr_, len_);") 1940 pcmd("}") 1941 } else { 1942 pcmd("const char *label = (const char *)label_;") 1943 pcmd("if (label) {") 1944 pcmd(" POST_READ(label, __sanitizer::internal_strlen(label) + 1);") 1945 pcmd("}") 1946 pcmd("if (addr_) {") 1947 pcmd(" POST_READ(addr_, len_);") 1948 pcmd("}") 1949 } 1950 } else if (syscall == "getcontext") { 1951 pcmd("/* Nothing to do */") 1952 } else if (syscall == "setcontext") { 1953 if (mode == "pre") { 1954 pcmd("if (ucp_) {") 1955 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1956 pcmd("}") 1957 } 1958 } else if (syscall == "_lwp_create") { 1959 if (mode == "pre") { 1960 pcmd("if (ucp_) {") 1961 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1962 pcmd("}") 1963 } 1964 } else if (syscall == "_lwp_exit") { 1965 pcmd("/* Nothing to do */") 1966 } else if (syscall == "_lwp_self") { 1967 pcmd("/* Nothing to do */") 1968 } else if (syscall == "_lwp_wait") { 1969 pcmd("/* Nothing to do */") 1970 } else if (syscall == "_lwp_suspend") { 1971 pcmd("/* Nothing to do */") 1972 } else if (syscall == "_lwp_continue") { 1973 pcmd("/* Nothing to do */") 1974 } else if (syscall == "_lwp_wakeup") { 1975 pcmd("/* Nothing to do */") 1976 } else if (syscall == "_lwp_getprivate") { 1977 pcmd("/* Nothing to do */") 1978 } else if (syscall == "_lwp_setprivate") { 1979 pcmd("/* Nothing to do */") 1980 } else if (syscall == "_lwp_kill") { 1981 pcmd("/* Nothing to do */") 1982 } else if (syscall == "_lwp_detach") { 1983 pcmd("/* Nothing to do */") 1984 } else if (syscall == "compat_50__lwp_park") { 1985 pcmd("/* TODO */") 1986 } else if (syscall == "_lwp_unpark") { 1987 pcmd("/* Nothing to do */") 1988 } else if (syscall == "_lwp_unpark_all") { 1989 if (mode == "pre") { 1990 pcmd("if (targets_) {") 1991 pcmd(" PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));") 1992 pcmd("}") 1993 } 1994 } else if (syscall == "_lwp_setname") { 1995 if (mode == "pre") { 1996 pcmd("const char *name = (const char *)name_;") 1997 pcmd("if (name) {") 1998 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1999 pcmd("}") 2000 } else { 2001 pcmd("const char *name = (const char *)name_;") 2002 pcmd("if (name) {") 2003 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 2004 pcmd("}") 2005 } 2006 } else if (syscall == "_lwp_getname") { 2007 pcmd("/* Nothing to do */") 2008 } else if (syscall == "_lwp_ctl") { 2009 pcmd("/* Nothing to do */") 2010 } else if (syscall == "compat_60_sa_register") { 2011 pcmd("/* TODO */") 2012 } else if (syscall == "compat_60_sa_stacks") { 2013 pcmd("/* TODO */") 2014 } else if (syscall == "compat_60_sa_enable") { 2015 pcmd("/* TODO */") 2016 } else if (syscall == "compat_60_sa_setconcurrency") { 2017 pcmd("/* TODO */") 2018 } else if (syscall == "compat_60_sa_yield") { 2019 pcmd("/* TODO */") 2020 } else if (syscall == "compat_60_sa_preempt") { 2021 pcmd("/* TODO */") 2022 } else if (syscall == "__sigaction_sigtramp") { 2023 pcmd("if (nsa_) {") 2024 pcmd(" PRE_READ(nsa_, sizeof(__sanitizer_sigaction));") 2025 pcmd("}") 2026 } else if (syscall == "rasctl") { 2027 pcmd("/* Nothing to do */") 2028 } else if (syscall == "kqueue") { 2029 pcmd("/* Nothing to do */") 2030 } else if (syscall == "compat_50_kevent") { 2031 pcmd("/* TODO */") 2032 } else if (syscall == "_sched_setparam") { 2033 pcmd("if (params_) {") 2034 pcmd(" PRE_READ(params_, struct_sched_param_sz);") 2035 pcmd("}") 2036 } else if (syscall == "_sched_getparam") { 2037 pcmd("/* Nothing to do */") 2038 } else if (syscall == "_sched_setaffinity") { 2039 pcmd("if (cpuset_) {") 2040 pcmd(" PRE_READ(cpuset_, size_);") 2041 pcmd("}") 2042 } else if (syscall == "_sched_getaffinity") { 2043 pcmd("/* Nothing to do */") 2044 } else if (syscall == "sched_yield") { 2045 pcmd("/* Nothing to do */") 2046 } else if (syscall == "_sched_protect") { 2047 pcmd("/* Nothing to do */") 2048 } else if (syscall == "fsync_range") { 2049 pcmd("/* Nothing to do */") 2050 } else if (syscall == "uuidgen") { 2051 pcmd("/* Nothing to do */") 2052 } else if (syscall == "compat_90_getvfsstat") { 2053 pcmd("/* Nothing to do */") 2054 } else if (syscall == "compat_90_statvfs1") { 2055 if (mode == "pre") { 2056 pcmd("const char *path = (const char *)path_;") 2057 pcmd("if (path) {") 2058 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2059 pcmd("}") 2060 } else { 2061 pcmd("const char *path = (const char *)path_;") 2062 pcmd("if (path) {") 2063 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2064 pcmd("}") 2065 } 2066 } else if (syscall == "compat_90_fstatvfs1") { 2067 pcmd("/* Nothing to do */") 2068 } else if (syscall == "compat_30_fhstatvfs1") { 2069 pcmd("/* TODO */") 2070 } else if (syscall == "extattrctl") { 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_set_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_get_file") { 2095 if (mode == "pre") { 2096 pcmd("const char *path = (const char *)path_;") 2097 pcmd("if (path) {") 2098 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2099 pcmd("}") 2100 } else { 2101 pcmd("const char *path = (const char *)path_;") 2102 pcmd("if (path) {") 2103 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2104 pcmd("}") 2105 } 2106 } else if (syscall == "extattr_delete_file") { 2107 if (mode == "pre") { 2108 pcmd("const char *path = (const char *)path_;") 2109 pcmd("if (path) {") 2110 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2111 pcmd("}") 2112 } else { 2113 pcmd("const char *path = (const char *)path_;") 2114 pcmd("if (path) {") 2115 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2116 pcmd("}") 2117 } 2118 } else if (syscall == "extattr_set_fd") { 2119 pcmd("/* TODO */") 2120 } else if (syscall == "extattr_get_fd") { 2121 pcmd("/* TODO */") 2122 } else if (syscall == "extattr_delete_fd") { 2123 pcmd("/* TODO */") 2124 } else if (syscall == "extattr_set_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_get_link") { 2137 if (mode == "pre") { 2138 pcmd("const char *path = (const char *)path_;") 2139 pcmd("if (path) {") 2140 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2141 pcmd("}") 2142 } else { 2143 pcmd("const char *path = (const char *)path_;") 2144 pcmd("if (path) {") 2145 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2146 pcmd("}") 2147 } 2148 } else if (syscall == "extattr_delete_link") { 2149 if (mode == "pre") { 2150 pcmd("const char *path = (const char *)path_;") 2151 pcmd("if (path) {") 2152 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2153 pcmd("}") 2154 } else { 2155 pcmd("const char *path = (const char *)path_;") 2156 pcmd("if (path) {") 2157 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2158 pcmd("}") 2159 } 2160 } else if (syscall == "extattr_list_fd") { 2161 pcmd("/* TODO */") 2162 } else if (syscall == "extattr_list_file") { 2163 if (mode == "pre") { 2164 pcmd("const char *path = (const char *)path_;") 2165 pcmd("if (path) {") 2166 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2167 pcmd("}") 2168 } else { 2169 pcmd("const char *path = (const char *)path_;") 2170 pcmd("if (path) {") 2171 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2172 pcmd("}") 2173 } 2174 } else if (syscall == "extattr_list_link") { 2175 if (mode == "pre") { 2176 pcmd("const char *path = (const char *)path_;") 2177 pcmd("if (path) {") 2178 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2179 pcmd("}") 2180 } else { 2181 pcmd("const char *path = (const char *)path_;") 2182 pcmd("if (path) {") 2183 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2184 pcmd("}") 2185 } 2186 } else if (syscall == "compat_50_pselect") { 2187 pcmd("/* TODO */") 2188 } else if (syscall == "compat_50_pollts") { 2189 pcmd("/* TODO */") 2190 } else if (syscall == "setxattr") { 2191 if (mode == "pre") { 2192 pcmd("const char *path = (const char *)path_;") 2193 pcmd("if (path) {") 2194 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2195 pcmd("}") 2196 } else { 2197 pcmd("const char *path = (const char *)path_;") 2198 pcmd("if (path) {") 2199 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2200 pcmd("}") 2201 } 2202 } else if (syscall == "lsetxattr") { 2203 if (mode == "pre") { 2204 pcmd("const char *path = (const char *)path_;") 2205 pcmd("if (path) {") 2206 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2207 pcmd("}") 2208 } else { 2209 pcmd("const char *path = (const char *)path_;") 2210 pcmd("if (path) {") 2211 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2212 pcmd("}") 2213 } 2214 } else if (syscall == "fsetxattr") { 2215 pcmd("/* Nothing to do */") 2216 } else if (syscall == "getxattr") { 2217 if (mode == "pre") { 2218 pcmd("const char *path = (const char *)path_;") 2219 pcmd("if (path) {") 2220 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2221 pcmd("}") 2222 } else { 2223 pcmd("const char *path = (const char *)path_;") 2224 pcmd("if (path) {") 2225 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2226 pcmd("}") 2227 } 2228 } else if (syscall == "lgetxattr") { 2229 if (mode == "pre") { 2230 pcmd("const char *path = (const char *)path_;") 2231 pcmd("if (path) {") 2232 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2233 pcmd("}") 2234 } else { 2235 pcmd("const char *path = (const char *)path_;") 2236 pcmd("if (path) {") 2237 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2238 pcmd("}") 2239 } 2240 } else if (syscall == "fgetxattr") { 2241 pcmd("/* Nothing to do */") 2242 } else if (syscall == "listxattr") { 2243 if (mode == "pre") { 2244 pcmd("const char *path = (const char *)path_;") 2245 pcmd("if (path) {") 2246 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2247 pcmd("}") 2248 } else { 2249 pcmd("const char *path = (const char *)path_;") 2250 pcmd("if (path) {") 2251 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2252 pcmd("}") 2253 } 2254 } else if (syscall == "llistxattr") { 2255 if (mode == "pre") { 2256 pcmd("const char *path = (const char *)path_;") 2257 pcmd("if (path) {") 2258 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2259 pcmd("}") 2260 } else { 2261 pcmd("const char *path = (const char *)path_;") 2262 pcmd("if (path) {") 2263 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2264 pcmd("}") 2265 } 2266 } else if (syscall == "flistxattr") { 2267 pcmd("/* TODO */") 2268 } else if (syscall == "removexattr") { 2269 if (mode == "pre") { 2270 pcmd("const char *path = (const char *)path_;") 2271 pcmd("if (path) {") 2272 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2273 pcmd("}") 2274 } else { 2275 pcmd("const char *path = (const char *)path_;") 2276 pcmd("if (path) {") 2277 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2278 pcmd("}") 2279 } 2280 } else if (syscall == "lremovexattr") { 2281 if (mode == "pre") { 2282 pcmd("const char *path = (const char *)path_;") 2283 pcmd("if (path) {") 2284 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2285 pcmd("}") 2286 } else { 2287 pcmd("const char *path = (const char *)path_;") 2288 pcmd("if (path) {") 2289 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2290 pcmd("}") 2291 } 2292 } else if (syscall == "fremovexattr") { 2293 pcmd("/* TODO */") 2294 } else if (syscall == "compat_50___stat30") { 2295 pcmd("/* TODO */") 2296 } else if (syscall == "compat_50___fstat30") { 2297 pcmd("/* TODO */") 2298 } else if (syscall == "compat_50___lstat30") { 2299 pcmd("/* TODO */") 2300 } else if (syscall == "__getdents30") { 2301 pcmd("/* Nothing to do */") 2302 } else if (syscall == "posix_fadvise") { 2303 pcmd("/* Nothing to do */") 2304 } else if (syscall == "compat_30___fhstat30") { 2305 pcmd("/* TODO */") 2306 } else if (syscall == "compat_50___ntp_gettime30") { 2307 pcmd("/* TODO */") 2308 } else if (syscall == "__socket30") { 2309 pcmd("/* Nothing to do */") 2310 } else if (syscall == "__getfh30") { 2311 if (mode == "pre") { 2312 pcmd("const char *fname = (const char *)fname_;") 2313 pcmd("if (fname) {") 2314 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2315 pcmd("}") 2316 } else { 2317 pcmd("const char *fname = (const char *)fname_;") 2318 pcmd("if (res == 0) {") 2319 pcmd(" if (fname) {") 2320 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2321 pcmd(" }") 2322 pcmd("}") 2323 } 2324 } else if (syscall == "__fhopen40") { 2325 if (mode == "pre") { 2326 pcmd("if (fhp_) {") 2327 pcmd(" PRE_READ(fhp_, fh_size_);") 2328 pcmd("}") 2329 } 2330 } else if (syscall == "compat_90_fhstatvfs1") { 2331 if (mode == "pre") { 2332 pcmd("if (fhp_) {") 2333 pcmd(" PRE_READ(fhp_, fh_size_);") 2334 pcmd("}") 2335 } 2336 } else if (syscall == "compat_50___fhstat40") { 2337 if (mode == "pre") { 2338 pcmd("if (fhp_) {") 2339 pcmd(" PRE_READ(fhp_, fh_size_);") 2340 pcmd("}") 2341 } 2342 } else if (syscall == "aio_cancel") { 2343 if (mode == "pre") { 2344 pcmd("if (aiocbp_) {") 2345 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2346 pcmd("}") 2347 } 2348 } else if (syscall == "aio_error") { 2349 if (mode == "pre") { 2350 pcmd("if (aiocbp_) {") 2351 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2352 pcmd("}") 2353 } 2354 } else if (syscall == "aio_fsync") { 2355 if (mode == "pre") { 2356 pcmd("if (aiocbp_) {") 2357 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2358 pcmd("}") 2359 } 2360 } else if (syscall == "aio_read") { 2361 if (mode == "pre") { 2362 pcmd("if (aiocbp_) {") 2363 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2364 pcmd("}") 2365 } 2366 } else if (syscall == "aio_return") { 2367 if (mode == "pre") { 2368 pcmd("if (aiocbp_) {") 2369 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2370 pcmd("}") 2371 } 2372 } else if (syscall == "compat_50_aio_suspend") { 2373 pcmd("/* TODO */") 2374 } else if (syscall == "aio_write") { 2375 if (mode == "pre") { 2376 pcmd("if (aiocbp_) {") 2377 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2378 pcmd("}") 2379 } 2380 } else if (syscall == "lio_listio") { 2381 pcmd("/* Nothing to do */") 2382 } else if (syscall == "__mount50") { 2383 if (mode == "pre") { 2384 pcmd("const char *type = (const char *)type_;") 2385 pcmd("const char *path = (const char *)path_;") 2386 pcmd("if (type) {") 2387 pcmd(" PRE_READ(type, __sanitizer::internal_strlen(type) + 1);") 2388 pcmd("}") 2389 pcmd("if (path) {") 2390 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2391 pcmd("}") 2392 pcmd("if (data_) {") 2393 pcmd(" PRE_READ(data_, data_len_);") 2394 pcmd("}") 2395 } else { 2396 pcmd("const char *type = (const char *)type_;") 2397 pcmd("const char *path = (const char *)path_;") 2398 pcmd("if (type) {") 2399 pcmd(" POST_READ(type, __sanitizer::internal_strlen(type) + 1);") 2400 pcmd("}") 2401 pcmd("if (path) {") 2402 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2403 pcmd("}") 2404 pcmd("if (data_) {") 2405 pcmd(" POST_READ(data_, data_len_);") 2406 pcmd("}") 2407 } 2408 } else if (syscall == "mremap") { 2409 pcmd("/* Nothing to do */") 2410 } else if (syscall == "pset_create") { 2411 pcmd("/* Nothing to do */") 2412 } else if (syscall == "pset_destroy") { 2413 pcmd("/* Nothing to do */") 2414 } else if (syscall == "pset_assign") { 2415 pcmd("/* Nothing to do */") 2416 } else if (syscall == "_pset_bind") { 2417 pcmd("/* Nothing to do */") 2418 } else if (syscall == "__posix_fadvise50") { 2419 pcmd("/* Nothing to do */") 2420 } else if (syscall == "__select50") { 2421 pcmd("/* Nothing to do */") 2422 } else if (syscall == "__gettimeofday50") { 2423 pcmd("/* Nothing to do */") 2424 } else if (syscall == "__settimeofday50") { 2425 if (mode == "pre") { 2426 pcmd("if (tv_) {") 2427 pcmd(" PRE_READ(tv_, timeval_sz);") 2428 pcmd("}") 2429 pcmd("if (tzp_) {") 2430 pcmd(" PRE_READ(tzp_, struct_timezone_sz);") 2431 pcmd("}") 2432 } 2433 } else if (syscall == "__utimes50") { 2434 if (mode == "pre") { 2435 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2436 pcmd("const char *path = (const char *)path_;") 2437 pcmd("if (path) {") 2438 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2439 pcmd("}") 2440 pcmd("if (tptr) {") 2441 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2442 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2443 pcmd("}") 2444 } 2445 } else if (syscall == "__adjtime50") { 2446 if (mode == "pre") { 2447 pcmd("if (delta_) {") 2448 pcmd(" PRE_READ(delta_, timeval_sz);") 2449 pcmd("}") 2450 } 2451 } else if (syscall == "__lfs_segwait50") { 2452 pcmd("/* TODO */") 2453 } else if (syscall == "__futimes50") { 2454 if (mode == "pre") { 2455 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2456 pcmd("if (tptr) {") 2457 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2458 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2459 pcmd("}") 2460 } 2461 } else if (syscall == "__lutimes50") { 2462 if (mode == "pre") { 2463 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2464 pcmd("const char *path = (const char *)path_;") 2465 pcmd("if (path) {") 2466 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2467 pcmd("}") 2468 pcmd("if (tptr) {") 2469 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2470 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2471 pcmd("}") 2472 } else { 2473 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2474 pcmd("const char *path = (const char *)path_;") 2475 pcmd("if (path) {") 2476 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2477 pcmd("}") 2478 pcmd("if (tptr) {") 2479 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2480 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2481 pcmd("}") 2482 } 2483 } else if (syscall == "__setitimer50") { 2484 if (mode == "pre") { 2485 pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;") 2486 pcmd("if (itv) {") 2487 pcmd(" PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2488 pcmd(" PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2489 pcmd(" PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2490 pcmd(" PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2491 pcmd("}") 2492 } 2493 } else if (syscall == "__getitimer50") { 2494 pcmd("/* Nothing to do */") 2495 } else if (syscall == "__clock_gettime50") { 2496 pcmd("/* Nothing to do */") 2497 } else if (syscall == "__clock_settime50") { 2498 if (mode == "pre") { 2499 pcmd("if (tp_) {") 2500 pcmd(" PRE_READ(tp_, struct_timespec_sz);") 2501 pcmd("}") 2502 } 2503 } else if (syscall == "__clock_getres50") { 2504 pcmd("/* Nothing to do */") 2505 } else if (syscall == "__nanosleep50") { 2506 if (mode == "pre") { 2507 pcmd("if (rqtp_) {") 2508 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2509 pcmd("}") 2510 } 2511 } else if (syscall == "____sigtimedwait50") { 2512 if (mode == "pre") { 2513 pcmd("if (set_) {") 2514 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 2515 pcmd("}") 2516 pcmd("if (timeout_) {") 2517 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2518 pcmd("}") 2519 } 2520 } else if (syscall == "__mq_timedsend50") { 2521 if (mode == "pre") { 2522 pcmd("if (msg_ptr_) {") 2523 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2524 pcmd("}") 2525 pcmd("if (abs_timeout_) {") 2526 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2527 pcmd("}") 2528 } 2529 } else if (syscall == "__mq_timedreceive50") { 2530 if (mode == "pre") { 2531 pcmd("if (msg_ptr_) {") 2532 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2533 pcmd("}") 2534 pcmd("if (abs_timeout_) {") 2535 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2536 pcmd("}") 2537 } 2538 } else if (syscall == "compat_60__lwp_park") { 2539 pcmd("/* TODO */") 2540 } else if (syscall == "__kevent50") { 2541 if (mode == "pre") { 2542 pcmd("if (changelist_) {") 2543 pcmd(" PRE_READ(changelist_, nchanges_ * struct_kevent_sz);") 2544 pcmd("}") 2545 pcmd("if (timeout_) {") 2546 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2547 pcmd("}") 2548 } 2549 } else if (syscall == "__pselect50") { 2550 if (mode == "pre") { 2551 pcmd("if (ts_) {") 2552 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2553 pcmd("}") 2554 pcmd("if (mask_) {") 2555 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2556 pcmd("}") 2557 } 2558 } else if (syscall == "__pollts50") { 2559 if (mode == "pre") { 2560 pcmd("if (ts_) {") 2561 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2562 pcmd("}") 2563 pcmd("if (mask_) {") 2564 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2565 pcmd("}") 2566 } 2567 } else if (syscall == "__aio_suspend50") { 2568 if (mode == "pre") { 2569 pcmd("int i;") 2570 pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;") 2571 pcmd("if (list) {") 2572 pcmd(" for (i = 0; i < nent_; i++) {") 2573 pcmd(" if (list[i]) {") 2574 pcmd(" PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));") 2575 pcmd(" }") 2576 pcmd(" }") 2577 pcmd("}") 2578 pcmd("if (timeout_) {") 2579 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2580 pcmd("}") 2581 } 2582 } else if (syscall == "__stat50") { 2583 if (mode == "pre") { 2584 pcmd("const char *path = (const char *)path_;") 2585 pcmd("if (path) {") 2586 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2587 pcmd("}") 2588 } else { 2589 pcmd("const char *path = (const char *)path_;") 2590 pcmd("if (res == 0) {") 2591 pcmd(" if (path) {") 2592 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2593 pcmd(" }") 2594 pcmd("}") 2595 } 2596 } else if (syscall == "__fstat50") { 2597 pcmd("/* Nothing to do */") 2598 } else if (syscall == "__lstat50") { 2599 if (mode == "pre") { 2600 pcmd("const char *path = (const char *)path_;") 2601 pcmd("if (path) {") 2602 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2603 pcmd("}") 2604 } else { 2605 pcmd("const char *path = (const char *)path_;") 2606 pcmd("if (res == 0) {") 2607 pcmd(" if (path) {") 2608 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2609 pcmd(" }") 2610 pcmd("}") 2611 } 2612 } else if (syscall == "____semctl50") { 2613 pcmd("/* Nothing to do */") 2614 } else if (syscall == "__shmctl50") { 2615 pcmd("/* Nothing to do */") 2616 } else if (syscall == "__msgctl50") { 2617 pcmd("/* Nothing to do */") 2618 } else if (syscall == "__getrusage50") { 2619 pcmd("/* Nothing to do */") 2620 } else if (syscall == "__timer_settime50") { 2621 if (mode == "pre") { 2622 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2623 pcmd("if (value) {") 2624 pcmd(" PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2625 pcmd(" PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2626 pcmd(" PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2627 pcmd(" PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2628 pcmd("}") 2629 } else { 2630 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2631 pcmd("if (res == 0) {") 2632 pcmd(" if (value) {") 2633 pcmd(" POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2634 pcmd(" POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2635 pcmd(" POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2636 pcmd(" POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2637 pcmd(" }") 2638 pcmd("}") 2639 } 2640 } else if (syscall == "__timer_gettime50") { 2641 pcmd("/* Nothing to do */") 2642 } else if (syscall == "__ntp_gettime50") { 2643 pcmd("/* Nothing to do */") 2644 } else if (syscall == "__wait450") { 2645 pcmd("/* Nothing to do */") 2646 } else if (syscall == "__mknod50") { 2647 if (mode == "pre") { 2648 pcmd("const char *path = (const char *)path_;") 2649 pcmd("if (path) {") 2650 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2651 pcmd("}") 2652 } else { 2653 pcmd("const char *path = (const char *)path_;") 2654 pcmd("if (res == 0) {") 2655 pcmd(" if (path) {") 2656 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2657 pcmd(" }") 2658 pcmd("}") 2659 } 2660 } else if (syscall == "__fhstat50") { 2661 if (mode == "pre") { 2662 pcmd("if (fhp_) {") 2663 pcmd(" PRE_READ(fhp_, fh_size_);") 2664 pcmd("}") 2665 } else { 2666 pcmd("if (res == 0) {") 2667 pcmd(" if (fhp_) {") 2668 pcmd(" POST_READ(fhp_, fh_size_);") 2669 pcmd(" }") 2670 pcmd("}") 2671 } 2672 } else if (syscall == "pipe2") { 2673 pcmd("/* Nothing to do */") 2674 } else if (syscall == "dup3") { 2675 pcmd("/* Nothing to do */") 2676 } else if (syscall == "kqueue1") { 2677 pcmd("/* Nothing to do */") 2678 } else if (syscall == "paccept") { 2679 if (mode == "pre") { 2680 pcmd("if (mask_) {") 2681 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2682 pcmd("}") 2683 } else { 2684 pcmd("if (res >= 0) {") 2685 pcmd(" if (mask_) {") 2686 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2687 pcmd(" }") 2688 pcmd("}") 2689 } 2690 } else if (syscall == "linkat") { 2691 if (mode == "pre") { 2692 pcmd("const char *name1 = (const char *)name1_;") 2693 pcmd("const char *name2 = (const char *)name2_;") 2694 pcmd("if (name1) {") 2695 pcmd(" PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2696 pcmd("}") 2697 pcmd("if (name2) {") 2698 pcmd(" PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2699 pcmd("}") 2700 } else { 2701 pcmd("const char *name1 = (const char *)name1_;") 2702 pcmd("const char *name2 = (const char *)name2_;") 2703 pcmd("if (res == 0) {") 2704 pcmd(" if (name1) {") 2705 pcmd(" POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2706 pcmd(" }") 2707 pcmd(" if (name2) {") 2708 pcmd(" POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2709 pcmd(" }") 2710 pcmd("}") 2711 } 2712 } else if (syscall == "renameat") { 2713 if (mode == "pre") { 2714 pcmd("const char *from = (const char *)from_;") 2715 pcmd("const char *to = (const char *)to_;") 2716 pcmd("if (from) {") 2717 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 2718 pcmd("}") 2719 pcmd("if (to) {") 2720 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 2721 pcmd("}") 2722 } else { 2723 pcmd("const char *from = (const char *)from_;") 2724 pcmd("const char *to = (const char *)to_;") 2725 pcmd("if (res == 0) {") 2726 pcmd(" if (from) {") 2727 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 2728 pcmd(" }") 2729 pcmd(" if (to) {") 2730 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 2731 pcmd(" }") 2732 pcmd("}") 2733 } 2734 } else if (syscall == "mkfifoat") { 2735 if (mode == "pre") { 2736 pcmd("const char *path = (const char *)path_;") 2737 pcmd("if (path) {") 2738 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2739 pcmd("}") 2740 } else { 2741 pcmd("const char *path = (const char *)path_;") 2742 pcmd("if (res == 0) {") 2743 pcmd(" if (path) {") 2744 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2745 pcmd(" }") 2746 pcmd("}") 2747 } 2748 } else if (syscall == "mknodat") { 2749 if (mode == "pre") { 2750 pcmd("const char *path = (const char *)path_;") 2751 pcmd("if (path) {") 2752 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2753 pcmd("}") 2754 } else { 2755 pcmd("const char *path = (const char *)path_;") 2756 pcmd("if (res == 0) {") 2757 pcmd(" if (path) {") 2758 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2759 pcmd(" }") 2760 pcmd("}") 2761 } 2762 } else if (syscall == "mkdirat") { 2763 if (mode == "pre") { 2764 pcmd("const char *path = (const char *)path_;") 2765 pcmd("if (path) {") 2766 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2767 pcmd("}") 2768 } else { 2769 pcmd("const char *path = (const char *)path_;") 2770 pcmd("if (res == 0) {") 2771 pcmd(" if (path) {") 2772 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2773 pcmd(" }") 2774 pcmd("}") 2775 } 2776 } else if (syscall == "faccessat") { 2777 if (mode == "pre") { 2778 pcmd("const char *path = (const char *)path_;") 2779 pcmd("if (path) {") 2780 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2781 pcmd("}") 2782 } else { 2783 pcmd("const char *path = (const char *)path_;") 2784 pcmd("if (res == 0) {") 2785 pcmd(" if (path) {") 2786 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2787 pcmd(" }") 2788 pcmd("}") 2789 } 2790 } else if (syscall == "fchmodat") { 2791 if (mode == "pre") { 2792 pcmd("const char *path = (const char *)path_;") 2793 pcmd("if (path) {") 2794 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2795 pcmd("}") 2796 } else { 2797 pcmd("const char *path = (const char *)path_;") 2798 pcmd("if (res == 0) {") 2799 pcmd(" if (path) {") 2800 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2801 pcmd(" }") 2802 pcmd("}") 2803 } 2804 } else if (syscall == "fchownat") { 2805 if (mode == "pre") { 2806 pcmd("const char *path = (const char *)path_;") 2807 pcmd("if (path) {") 2808 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2809 pcmd("}") 2810 } else { 2811 pcmd("const char *path = (const char *)path_;") 2812 pcmd("if (res == 0) {") 2813 pcmd(" if (path) {") 2814 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2815 pcmd(" }") 2816 pcmd("}") 2817 } 2818 } else if (syscall == "fexecve") { 2819 pcmd("/* TODO */") 2820 } else if (syscall == "fstatat") { 2821 if (mode == "pre") { 2822 pcmd("const char *path = (const char *)path_;") 2823 pcmd("if (path) {") 2824 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2825 pcmd("}") 2826 } else { 2827 pcmd("const char *path = (const char *)path_;") 2828 pcmd("if (path) {") 2829 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2830 pcmd("}") 2831 } 2832 } else if (syscall == "utimensat") { 2833 if (mode == "pre") { 2834 pcmd("const char *path = (const char *)path_;") 2835 pcmd("if (path) {") 2836 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2837 pcmd("}") 2838 pcmd("if (tptr_) {") 2839 pcmd(" PRE_READ(tptr_, struct_timespec_sz);") 2840 pcmd("}") 2841 } else { 2842 pcmd("const char *path = (const char *)path_;") 2843 pcmd("if (res > 0) {") 2844 pcmd(" if (path) {") 2845 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2846 pcmd(" }") 2847 pcmd(" if (tptr_) {") 2848 pcmd(" POST_READ(tptr_, struct_timespec_sz);") 2849 pcmd(" }") 2850 pcmd("}") 2851 } 2852 } else if (syscall == "openat") { 2853 if (mode == "pre") { 2854 pcmd("const char *path = (const char *)path_;") 2855 pcmd("if (path) {") 2856 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2857 pcmd("}") 2858 } else { 2859 pcmd("const char *path = (const char *)path_;") 2860 pcmd("if (res > 0) {") 2861 pcmd(" if (path) {") 2862 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2863 pcmd(" }") 2864 pcmd("}") 2865 } 2866 } else if (syscall == "readlinkat") { 2867 if (mode == "pre") { 2868 pcmd("const char *path = (const char *)path_;") 2869 pcmd("if (path) {") 2870 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2871 pcmd("}") 2872 } else { 2873 pcmd("const char *path = (const char *)path_;") 2874 pcmd("if (res > 0) {") 2875 pcmd(" if (path) {") 2876 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2877 pcmd(" }") 2878 pcmd("}") 2879 } 2880 } else if (syscall == "symlinkat") { 2881 if (mode == "pre") { 2882 pcmd("const char *path1 = (const char *)path1_;") 2883 pcmd("const char *path2 = (const char *)path2_;") 2884 pcmd("if (path1) {") 2885 pcmd(" PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2886 pcmd("}") 2887 pcmd("if (path2) {") 2888 pcmd(" PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2889 pcmd("}") 2890 } else { 2891 pcmd("const char *path1 = (const char *)path1_;") 2892 pcmd("const char *path2 = (const char *)path2_;") 2893 pcmd("if (res == 0) {") 2894 pcmd(" if (path1) {") 2895 pcmd(" POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2896 pcmd(" }") 2897 pcmd(" if (path2) {") 2898 pcmd(" POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2899 pcmd(" }") 2900 pcmd("}") 2901 } 2902 } else if (syscall == "unlinkat") { 2903 if (mode == "pre") { 2904 pcmd("const char *path = (const char *)path_;") 2905 pcmd("if (path) {") 2906 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2907 pcmd("}") 2908 } else { 2909 pcmd("const char *path = (const char *)path_;") 2910 pcmd("if (res == 0) {") 2911 pcmd(" if (path) {") 2912 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2913 pcmd(" }") 2914 pcmd("}") 2915 } 2916 } else if (syscall == "futimens") { 2917 if (mode == "pre") { 2918 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2919 pcmd("if (tptr) {") 2920 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2921 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2922 pcmd("}") 2923 } else { 2924 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2925 pcmd("if (res == 0) {") 2926 pcmd(" if (tptr) {") 2927 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2928 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2929 pcmd(" }") 2930 pcmd("}") 2931 } 2932 } else if (syscall == "__quotactl") { 2933 if (mode == "pre") { 2934 pcmd("const char *path = (const char *)path_;") 2935 pcmd("if (path) {") 2936 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2937 pcmd("}") 2938 } else { 2939 pcmd("const char *path = (const char *)path_;") 2940 pcmd("if (res == 0) {") 2941 pcmd(" if (path) {") 2942 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2943 pcmd(" }") 2944 pcmd("}") 2945 } 2946 } else if (syscall == "posix_spawn") { 2947 if (mode == "pre") { 2948 pcmd("const char *path = (const char *)path_;") 2949 pcmd("if (path) {") 2950 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2951 pcmd("}") 2952 } else { 2953 pcmd("const char *path = (const char *)path_;") 2954 pcmd("if (pid_) {") 2955 pcmd(" if (path) {") 2956 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2957 pcmd(" }") 2958 pcmd("}") 2959 } 2960 } else if (syscall == "recvmmsg") { 2961 if (mode == "pre") { 2962 pcmd("if (timeout_) {") 2963 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2964 pcmd("}") 2965 } else { 2966 pcmd("if (res >= 0) {") 2967 pcmd(" if (timeout_) {") 2968 pcmd(" POST_READ(timeout_, struct_timespec_sz);") 2969 pcmd(" }") 2970 pcmd("}") 2971 } 2972 } else if (syscall == "sendmmsg") { 2973 if (mode == "pre") { 2974 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2975 pcmd("if (mmsg) {") 2976 pcmd(" PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2977 pcmd("}") 2978 } else { 2979 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2980 pcmd("if (res >= 0) {") 2981 pcmd(" if (mmsg) {") 2982 pcmd(" POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2983 pcmd(" }") 2984 pcmd("}") 2985 } 2986 } else if (syscall == "clock_nanosleep") { 2987 if (mode == "pre") { 2988 pcmd("if (rqtp_) {") 2989 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2990 pcmd("}") 2991 } else { 2992 pcmd("if (rqtp_) {") 2993 pcmd(" POST_READ(rqtp_, struct_timespec_sz);") 2994 pcmd("}") 2995 } 2996 } else if (syscall == "___lwp_park60") { 2997 if (mode == "pre") { 2998 pcmd("if (ts_) {") 2999 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 3000 pcmd("}") 3001 } else { 3002 pcmd("if (res == 0) {") 3003 pcmd(" if (ts_) {") 3004 pcmd(" POST_READ(ts_, struct_timespec_sz);") 3005 pcmd(" }") 3006 pcmd("}") 3007 } 3008 } else if (syscall == "posix_fallocate") { 3009 pcmd("/* Nothing to do */") 3010 } else if (syscall == "fdiscard") { 3011 pcmd("/* Nothing to do */") 3012 } else if (syscall == "wait6") { 3013 pcmd("/* Nothing to do */") 3014 } else if (syscall == "clock_getcpuclockid2") { 3015 pcmd("/* Nothing to do */") 3016 } else if (syscall == "__getvfsstat90") { 3017 pcmd("/* Nothing to do */") 3018 } else if (syscall == "__statvfs190") { 3019 if (mode == "pre") { 3020 pcmd("const char *path = (const char *)path_;") 3021 pcmd("if (path) {") 3022 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 3023 pcmd("}") 3024 } else { 3025 pcmd("const char *path = (const char *)path_;") 3026 pcmd("if (path) {") 3027 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 3028 pcmd("}") 3029 } 3030 } else if (syscall == "__fstatvfs190") { 3031 pcmd("/* Nothing to do */") 3032 } else if (syscall == "__fhstatvfs190") { 3033 if (mode == "pre") { 3034 pcmd("if (fhp_) {") 3035 pcmd(" PRE_READ(fhp_, fh_size_);") 3036 pcmd("}") 3037 } 3038 } else if (syscall == "__acl_get_link") { 3039 pcmd("/* TODO */") 3040 } else if (syscall == "__acl_set_link") { 3041 pcmd("/* TODO */") 3042 } else if (syscall == "__acl_delete_link") { 3043 pcmd("/* TODO */") 3044 } else if (syscall == "__acl_aclcheck_link") { 3045 pcmd("/* TODO */") 3046 } else if (syscall == "__acl_get_file") { 3047 pcmd("/* TODO */") 3048 } else if (syscall == "__acl_set_file") { 3049 pcmd("/* TODO */") 3050 } else if (syscall == "__acl_get_fd") { 3051 pcmd("/* TODO */") 3052 } else if (syscall == "__acl_set_fd") { 3053 pcmd("/* TODO */") 3054 } else if (syscall == "__acl_delete_file") { 3055 pcmd("/* TODO */") 3056 } else if (syscall == "__acl_delete_fd") { 3057 pcmd("/* TODO */") 3058 } else if (syscall == "__acl_aclcheck_file") { 3059 pcmd("/* TODO */") 3060 } else if (syscall == "__acl_aclcheck_fd") { 3061 pcmd("/* TODO */") 3062 } else if (syscall == "lpathconf") { 3063 pcmd("/* TODO */") 3064 } else { 3065 print "Unrecognized syscall: " syscall 3066 abnormal_exit = 1 3067 exit 1 3068 } 3069} 3070