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 == "fcntl") { 1171 pcmd("/* Nothing to do */") 1172 } else if (syscall == "compat_50_select") { 1173 pcmd("/* TODO */") 1174 } else if (syscall == "fsync") { 1175 pcmd("/* Nothing to do */") 1176 } else if (syscall == "setpriority") { 1177 pcmd("/* Nothing to do */") 1178 } else if (syscall == "compat_30_socket") { 1179 pcmd("/* TODO */") 1180 } else if (syscall == "connect") { 1181 if (mode == "pre") { 1182 pcmd("PRE_READ(name_, namelen_);") 1183 } else { 1184 pcmd("if (res == 0) {") 1185 pcmd(" POST_READ(name_, namelen_);") 1186 pcmd("}") 1187 } 1188 } else if (syscall == "compat_43_oaccept") { 1189 pcmd("/* TODO */") 1190 } else if (syscall == "getpriority") { 1191 pcmd("/* Nothing to do */") 1192 } else if (syscall == "compat_43_osend") { 1193 pcmd("/* TODO */") 1194 } else if (syscall == "compat_43_orecv") { 1195 pcmd("/* TODO */") 1196 } else if (syscall == "compat_13_sigreturn13") { 1197 pcmd("/* TODO */") 1198 } else if (syscall == "bind") { 1199 if (mode == "pre") { 1200 pcmd("PRE_READ(name_, namelen_);") 1201 } else { 1202 pcmd("if (res == 0) {") 1203 pcmd(" PRE_READ(name_, namelen_);") 1204 pcmd("}") 1205 } 1206 } else if (syscall == "setsockopt") { 1207 if (mode == "pre") { 1208 pcmd("if (val_) {") 1209 pcmd(" PRE_READ(val_, valsize_);") 1210 pcmd("}") 1211 } else { 1212 pcmd("if (res == 0) {") 1213 pcmd(" if (val_) {") 1214 pcmd(" POST_READ(val_, valsize_);") 1215 pcmd(" }") 1216 pcmd("}") 1217 } 1218 } else if (syscall == "listen") { 1219 pcmd("/* Nothing to do */") 1220 } else if (syscall == "compat_43_osigvec") { 1221 pcmd("/* TODO */") 1222 } else if (syscall == "compat_43_osigblock") { 1223 pcmd("/* TODO */") 1224 } else if (syscall == "compat_43_osigsetmask") { 1225 pcmd("/* TODO */") 1226 } else if (syscall == "compat_13_sigsuspend13") { 1227 pcmd("/* TODO */") 1228 } else if (syscall == "compat_43_osigstack") { 1229 pcmd("/* TODO */") 1230 } else if (syscall == "compat_43_orecvmsg") { 1231 pcmd("/* TODO */") 1232 } else if (syscall == "compat_43_osendmsg") { 1233 pcmd("/* TODO */") 1234 } else if (syscall == "compat_50_gettimeofday") { 1235 pcmd("/* TODO */") 1236 } else if (syscall == "compat_50_getrusage") { 1237 pcmd("/* TODO */") 1238 } else if (syscall == "getsockopt") { 1239 pcmd("/* TODO */") 1240 } else if (syscall == "readv") { 1241 if (mode == "pre") { 1242 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1243 pcmd("int i;") 1244 pcmd("if (iovp) {") 1245 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1246 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1247 pcmd(" PRE_WRITE(iovp[i].iov_base, iovp[i].iov_len);") 1248 pcmd(" }") 1249 pcmd("}") 1250 } else { 1251 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1252 pcmd("int i;") 1253 pcmd("uptr m, n = res;") 1254 pcmd("if (res > 0) {") 1255 pcmd(" if (iovp) {") 1256 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1257 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1258 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1259 pcmd(" POST_WRITE(iovp[i].iov_base, m);") 1260 pcmd(" n -= m;") 1261 pcmd(" }") 1262 pcmd(" }") 1263 pcmd("}") 1264 } 1265 } else if (syscall == "writev") { 1266 if (mode == "pre") { 1267 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1268 pcmd("int i;") 1269 pcmd("if (iovp) {") 1270 pcmd(" PRE_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1271 pcmd(" for (i = 0; i < iovcnt_; i++) {") 1272 pcmd(" PRE_READ(iovp[i].iov_base, iovp[i].iov_len);") 1273 pcmd(" }") 1274 pcmd("}") 1275 } else { 1276 pcmd("struct __sanitizer_iovec *iovp = (struct __sanitizer_iovec *)iovp_;") 1277 pcmd("int i;") 1278 pcmd("uptr m, n = res;") 1279 pcmd("if (res > 0) {") 1280 pcmd(" if (iovp) {") 1281 pcmd(" POST_READ(iovp, sizeof(struct __sanitizer_iovec) * iovcnt_);") 1282 pcmd(" for (i = 0; i < iovcnt_ && n > 0; i++) {") 1283 pcmd(" m = n > iovp[i].iov_len ? iovp[i].iov_len : n;") 1284 pcmd(" POST_READ(iovp[i].iov_base, m);") 1285 pcmd(" n -= m;") 1286 pcmd(" }") 1287 pcmd(" }") 1288 pcmd("}") 1289 } 1290 } else if (syscall == "compat_50_settimeofday") { 1291 pcmd("/* TODO */") 1292 } else if (syscall == "fchown") { 1293 pcmd("/* Nothing to do */") 1294 } else if (syscall == "fchmod") { 1295 pcmd("/* Nothing to do */") 1296 } else if (syscall == "compat_43_orecvfrom") { 1297 pcmd("/* TODO */") 1298 } else if (syscall == "setreuid") { 1299 pcmd("/* Nothing to do */") 1300 } else if (syscall == "setregid") { 1301 pcmd("/* Nothing to do */") 1302 } else if (syscall == "rename") { 1303 if (mode == "pre") { 1304 pcmd("const char *from = (const char *)from_;") 1305 pcmd("const char *to = (const char *)to_;") 1306 pcmd("if (from) {") 1307 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1308 pcmd("}") 1309 pcmd("if (to) {") 1310 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1311 pcmd("}") 1312 } else { 1313 pcmd("if (res == 0) {") 1314 pcmd(" const char *from = (const char *)from_;") 1315 pcmd(" const char *to = (const char *)to_;") 1316 pcmd(" if (from) {") 1317 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1318 pcmd(" }") 1319 pcmd(" if (to) {") 1320 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1321 pcmd(" }") 1322 pcmd("}") 1323 } 1324 } else if (syscall == "compat_43_otruncate") { 1325 pcmd("/* TODO */") 1326 } else if (syscall == "compat_43_oftruncate") { 1327 pcmd("/* TODO */") 1328 } else if (syscall == "flock") { 1329 pcmd("/* Nothing to do */") 1330 } else if (syscall == "mkfifo") { 1331 if (mode == "pre") { 1332 pcmd("const char *path = (const char *)path_;") 1333 pcmd("if (path) {") 1334 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1335 pcmd("}") 1336 } else { 1337 pcmd("if (res == 0) {") 1338 pcmd(" const char *path = (const char *)path_;") 1339 pcmd(" if (path) {") 1340 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1341 pcmd(" }") 1342 pcmd("}") 1343 } 1344 } else if (syscall == "sendto") { 1345 if (mode == "pre") { 1346 pcmd("PRE_READ(buf_, len_);") 1347 pcmd("PRE_READ(to_, tolen_);") 1348 } else { 1349 pcmd("if (res >= 0) {") 1350 pcmd(" POST_READ(buf_, len_);") 1351 pcmd(" POST_READ(to_, tolen_);") 1352 pcmd("}") 1353 } 1354 } else if (syscall == "shutdown") { 1355 pcmd("/* Nothing to do */") 1356 } else if (syscall == "socketpair") { 1357 if (mode == "pre") { 1358 pcmd("PRE_WRITE(rsv_, 2 * sizeof(int));") 1359 } else { 1360 pcmd("if (res == 0) {") 1361 pcmd(" POST_WRITE(rsv_, 2 * sizeof(int));") 1362 pcmd("}") 1363 } 1364 } else if (syscall == "mkdir") { 1365 if (mode == "pre") { 1366 pcmd("const char *path = (const char *)path_;") 1367 pcmd("if (path) {") 1368 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1369 pcmd("}") 1370 } else { 1371 pcmd("if (res == 0) {") 1372 pcmd(" const char *path = (const char *)path_;") 1373 pcmd(" if (path) {") 1374 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1375 pcmd(" }") 1376 pcmd("}") 1377 } 1378 } else if (syscall == "rmdir") { 1379 if (mode == "pre") { 1380 pcmd("const char *path = (const char *)path_;") 1381 pcmd("if (path) {") 1382 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1383 pcmd("}") 1384 } else { 1385 pcmd("if (res == 0) {") 1386 pcmd(" const char *path = (const char *)path_;") 1387 pcmd(" if (path) {") 1388 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1389 pcmd(" }") 1390 pcmd("}") 1391 } 1392 } else if (syscall == "compat_50_utimes") { 1393 pcmd("/* TODO */") 1394 } else if (syscall == "compat_50_adjtime") { 1395 pcmd("/* TODO */") 1396 } else if (syscall == "compat_43_ogetpeername") { 1397 pcmd("/* TODO */") 1398 } else if (syscall == "compat_43_ogethostid") { 1399 pcmd("/* TODO */") 1400 } else if (syscall == "compat_43_osethostid") { 1401 pcmd("/* TODO */") 1402 } else if (syscall == "compat_43_ogetrlimit") { 1403 pcmd("/* TODO */") 1404 } else if (syscall == "compat_43_osetrlimit") { 1405 pcmd("/* TODO */") 1406 } else if (syscall == "compat_43_okillpg") { 1407 pcmd("/* TODO */") 1408 } else if (syscall == "setsid") { 1409 pcmd("/* Nothing to do */") 1410 } else if (syscall == "compat_50_quotactl") { 1411 pcmd("/* TODO */") 1412 } else if (syscall == "compat_43_oquota") { 1413 pcmd("/* TODO */") 1414 } else if (syscall == "compat_43_ogetsockname") { 1415 pcmd("/* TODO */") 1416 } else if (syscall == "nfssvc") { 1417 pcmd("/* Nothing to do */") 1418 } else if (syscall == "compat_43_ogetdirentries") { 1419 pcmd("/* TODO */") 1420 } else if (syscall == "compat_20_statfs") { 1421 pcmd("/* TODO */") 1422 } else if (syscall == "compat_20_fstatfs") { 1423 pcmd("/* TODO */") 1424 } else if (syscall == "compat_30_getfh") { 1425 pcmd("/* TODO */") 1426 } else if (syscall == "compat_09_ogetdomainname") { 1427 pcmd("/* TODO */") 1428 } else if (syscall == "compat_09_osetdomainname") { 1429 pcmd("/* TODO */") 1430 } else if (syscall == "compat_09_ouname") { 1431 pcmd("/* TODO */") 1432 } else if (syscall == "sysarch") { 1433 pcmd("/* TODO */") 1434 } else if (syscall == "compat_10_osemsys") { 1435 pcmd("/* TODO */") 1436 } else if (syscall == "compat_10_omsgsys") { 1437 pcmd("/* TODO */") 1438 } else if (syscall == "compat_10_oshmsys") { 1439 pcmd("/* TODO */") 1440 } else if (syscall == "pread") { 1441 if (mode == "pre") { 1442 pcmd("if (buf_) {") 1443 pcmd(" PRE_WRITE(buf_, nbyte_);") 1444 pcmd("}") 1445 } else { 1446 pcmd("if (res > 0) {") 1447 pcmd(" POST_WRITE(buf_, res);") 1448 pcmd("}") 1449 } 1450 } else if (syscall == "pwrite") { 1451 if (mode == "pre") { 1452 pcmd("if (buf_) {") 1453 pcmd(" PRE_READ(buf_, nbyte_);") 1454 pcmd("}") 1455 } else { 1456 pcmd("if (res > 0) {") 1457 pcmd(" POST_READ(buf_, res);") 1458 pcmd("}") 1459 } 1460 } else if (syscall == "compat_30_ntp_gettime") { 1461 pcmd("/* TODO */") 1462 } else if (syscall == "ntp_adjtime") { 1463 pcmd("/* Nothing to do */") 1464 } else if (syscall == "setgid") { 1465 pcmd("/* Nothing to do */") 1466 } else if (syscall == "setegid") { 1467 pcmd("/* Nothing to do */") 1468 } else if (syscall == "seteuid") { 1469 pcmd("/* Nothing to do */") 1470 } else if (syscall == "lfs_bmapv") { 1471 pcmd("/* TODO */") 1472 } else if (syscall == "lfs_markv") { 1473 pcmd("/* TODO */") 1474 } else if (syscall == "lfs_segclean") { 1475 pcmd("/* TODO */") 1476 } else if (syscall == "compat_50_lfs_segwait") { 1477 pcmd("/* TODO */") 1478 } else if (syscall == "compat_12_stat12") { 1479 pcmd("/* TODO */") 1480 } else if (syscall == "compat_12_fstat12") { 1481 pcmd("/* TODO */") 1482 } else if (syscall == "compat_12_lstat12") { 1483 pcmd("/* TODO */") 1484 } else if (syscall == "pathconf") { 1485 if (mode == "pre") { 1486 pcmd("const char *path = (const char *)path_;") 1487 pcmd("if (path) {") 1488 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1489 pcmd("}") 1490 } else { 1491 pcmd("if (res != -1) {") 1492 pcmd(" const char *path = (const char *)path_;") 1493 pcmd(" if (path) {") 1494 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1495 pcmd(" }") 1496 pcmd("}") 1497 } 1498 } else if (syscall == "getsockopt2") { 1499 pcmd("/* TODO */") 1500 } else if (syscall == "fpathconf") { 1501 pcmd("/* Nothing to do */") 1502 } else if (syscall == "getrlimit") { 1503 if (mode == "pre") { 1504 pcmd("PRE_WRITE(rlp_, struct_rlimit_sz);") 1505 } else { 1506 pcmd("if (res == 0) {") 1507 pcmd(" POST_WRITE(rlp_, struct_rlimit_sz);") 1508 pcmd("}") 1509 } 1510 } else if (syscall == "setrlimit") { 1511 if (mode == "pre") { 1512 pcmd("PRE_READ(rlp_, struct_rlimit_sz);") 1513 } else { 1514 pcmd("if (res == 0) {") 1515 pcmd(" POST_READ(rlp_, struct_rlimit_sz);") 1516 pcmd("}") 1517 } 1518 } else if (syscall == "compat_12_getdirentries") { 1519 pcmd("/* TODO */") 1520 } else if (syscall == "mmap") { 1521 pcmd("/* Nothing to do */") 1522 } else if (syscall == "__syscall") { 1523 pcmd("/* Nothing to do */") 1524 } else if (syscall == "lseek") { 1525 pcmd("/* Nothing to do */") 1526 } else if (syscall == "truncate") { 1527 if (mode == "pre") { 1528 pcmd("const char *path = (const char *)path_;") 1529 pcmd("if (path) {") 1530 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1531 pcmd("}") 1532 } else { 1533 pcmd("if (res == 0) {") 1534 pcmd(" const char *path = (const char *)path_;") 1535 pcmd(" if (path) {") 1536 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1537 pcmd(" }") 1538 pcmd("}") 1539 } 1540 } else if (syscall == "ftruncate") { 1541 pcmd("/* Nothing to do */") 1542 } else if (syscall == "__sysctl") { 1543 if (mode == "pre") { 1544 pcmd("const int *name = (const int *)name_;") 1545 pcmd("if (name) {") 1546 pcmd(" PRE_READ(name, namelen_ * sizeof(*name));") 1547 pcmd("}") 1548 pcmd("if (newv_) {") 1549 pcmd(" PRE_READ(name, newlen_);") 1550 pcmd("}") 1551 } else { 1552 pcmd("if (res == 0) {") 1553 pcmd(" const int *name = (const int *)name_;") 1554 pcmd(" if (name) {") 1555 pcmd(" POST_READ(name, namelen_ * sizeof(*name));") 1556 pcmd(" }") 1557 pcmd(" if (newv_) {") 1558 pcmd(" POST_READ(name, newlen_);") 1559 pcmd(" }") 1560 pcmd("}") 1561 } 1562 } else if (syscall == "mlock") { 1563 pcmd("/* Nothing to do */") 1564 } else if (syscall == "munlock") { 1565 pcmd("/* Nothing to do */") 1566 } else if (syscall == "undelete") { 1567 if (mode == "pre") { 1568 pcmd("const char *path = (const char *)path_;") 1569 pcmd("if (path) {") 1570 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1571 pcmd("}") 1572 } else { 1573 pcmd("if (res == 0) {") 1574 pcmd(" const char *path = (const char *)path_;") 1575 pcmd(" if (path) {") 1576 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1577 pcmd(" }") 1578 pcmd("}") 1579 } 1580 } else if (syscall == "compat_50_futimes") { 1581 pcmd("/* TODO */") 1582 } else if (syscall == "getpgid") { 1583 pcmd("/* Nothing to do */") 1584 } else if (syscall == "reboot") { 1585 if (mode == "pre") { 1586 pcmd("const char *bootstr = (const char *)bootstr_;") 1587 pcmd("if (bootstr) {") 1588 pcmd(" PRE_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1589 pcmd("}") 1590 } else { 1591 pcmd("/* This call should never return */") 1592 pcmd("const char *bootstr = (const char *)bootstr_;") 1593 pcmd("if (bootstr) {") 1594 pcmd(" POST_READ(bootstr, __sanitizer::internal_strlen(bootstr) + 1);") 1595 pcmd("}") 1596 } 1597 } else if (syscall == "poll") { 1598 pcmd("/* Nothing to do */") 1599 } else if (syscall == "afssys") { 1600 pcmd("/* TODO */") 1601 } else if (syscall == "compat_14___semctl") { 1602 pcmd("/* TODO */") 1603 } else if (syscall == "semget") { 1604 pcmd("/* Nothing to do */") 1605 } else if (syscall == "semop") { 1606 if (mode == "pre") { 1607 pcmd("if (sops_) {") 1608 pcmd(" PRE_READ(sops_, nsops_ * struct_sembuf_sz);") 1609 pcmd("}") 1610 } else { 1611 pcmd("if (res == 0) {") 1612 pcmd(" if (sops_) {") 1613 pcmd(" POST_READ(sops_, nsops_ * struct_sembuf_sz);") 1614 pcmd(" }") 1615 pcmd("}") 1616 } 1617 } else if (syscall == "semconfig") { 1618 pcmd("/* Nothing to do */") 1619 } else if (syscall == "compat_14_msgctl") { 1620 pcmd("/* TODO */") 1621 } else if (syscall == "msgget") { 1622 pcmd("/* Nothing to do */") 1623 } else if (syscall == "msgsnd") { 1624 if (mode == "pre") { 1625 pcmd("if (msgp_) {") 1626 pcmd(" PRE_READ(msgp_, msgsz_);") 1627 pcmd("}") 1628 } else { 1629 pcmd("if (res == 0) {") 1630 pcmd(" if (msgp_) {") 1631 pcmd(" POST_READ(msgp_, msgsz_);") 1632 pcmd(" }") 1633 pcmd("}") 1634 } 1635 } else if (syscall == "msgrcv") { 1636 pcmd("/* Nothing to do */") 1637 } else if (syscall == "shmat") { 1638 pcmd("/* Nothing to do */") 1639 } else if (syscall == "compat_14_shmctl") { 1640 pcmd("/* TODO */") 1641 } else if (syscall == "shmdt") { 1642 pcmd("/* Nothing to do */") 1643 } else if (syscall == "shmget") { 1644 pcmd("/* Nothing to do */") 1645 } else if (syscall == "compat_50_clock_gettime") { 1646 pcmd("/* TODO */") 1647 } else if (syscall == "compat_50_clock_settime") { 1648 pcmd("/* TODO */") 1649 } else if (syscall == "compat_50_clock_getres") { 1650 pcmd("/* TODO */") 1651 } else if (syscall == "timer_create") { 1652 pcmd("/* Nothing to do */") 1653 } else if (syscall == "timer_delete") { 1654 pcmd("/* Nothing to do */") 1655 } else if (syscall == "compat_50_timer_settime") { 1656 pcmd("/* TODO */") 1657 } else if (syscall == "compat_50_timer_gettime") { 1658 pcmd("/* TODO */") 1659 } else if (syscall == "timer_getoverrun") { 1660 pcmd("/* Nothing to do */") 1661 } else if (syscall == "compat_50_nanosleep") { 1662 pcmd("/* TODO */") 1663 } else if (syscall == "fdatasync") { 1664 pcmd("/* Nothing to do */") 1665 } else if (syscall == "mlockall") { 1666 pcmd("/* Nothing to do */") 1667 } else if (syscall == "munlockall") { 1668 pcmd("/* Nothing to do */") 1669 } else if (syscall == "compat_50___sigtimedwait") { 1670 pcmd("/* TODO */") 1671 } else if (syscall == "sigqueueinfo") { 1672 if (mode == "pre") { 1673 pcmd("if (info_) {") 1674 pcmd(" PRE_READ(info_, siginfo_t_sz);") 1675 pcmd("}") 1676 } 1677 } else if (syscall == "modctl") { 1678 pcmd("/* TODO */") 1679 } else if (syscall == "_ksem_init") { 1680 pcmd("/* Nothing to do */") 1681 } else if (syscall == "_ksem_open") { 1682 if (mode == "pre") { 1683 pcmd("const char *name = (const char *)name_;") 1684 pcmd("if (name) {") 1685 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1686 pcmd("}") 1687 } else { 1688 pcmd("const char *name = (const char *)name_;") 1689 pcmd("if (name) {") 1690 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1691 pcmd("}") 1692 } 1693 } else if (syscall == "_ksem_unlink") { 1694 if (mode == "pre") { 1695 pcmd("const char *name = (const char *)name_;") 1696 pcmd("if (name) {") 1697 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1698 pcmd("}") 1699 } else { 1700 pcmd("const char *name = (const char *)name_;") 1701 pcmd("if (name) {") 1702 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1703 pcmd("}") 1704 } 1705 } else if (syscall == "_ksem_close") { 1706 pcmd("/* Nothing to do */") 1707 } else if (syscall == "_ksem_post") { 1708 pcmd("/* Nothing to do */") 1709 } else if (syscall == "_ksem_wait") { 1710 pcmd("/* Nothing to do */") 1711 } else if (syscall == "_ksem_trywait") { 1712 pcmd("/* Nothing to do */") 1713 } else if (syscall == "_ksem_getvalue") { 1714 pcmd("/* Nothing to do */") 1715 } else if (syscall == "_ksem_destroy") { 1716 pcmd("/* Nothing to do */") 1717 } else if (syscall == "_ksem_timedwait") { 1718 if (mode == "pre") { 1719 pcmd("if (abstime_) {") 1720 pcmd(" PRE_READ(abstime_, struct_timespec_sz);") 1721 pcmd("}") 1722 } 1723 } else if (syscall == "mq_open") { 1724 if (mode == "pre") { 1725 pcmd("const char *name = (const char *)name_;") 1726 pcmd("if (name) {") 1727 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1728 pcmd("}") 1729 } else { 1730 pcmd("const char *name = (const char *)name_;") 1731 pcmd("if (name) {") 1732 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1733 pcmd("}") 1734 } 1735 } else if (syscall == "mq_close") { 1736 pcmd("/* Nothing to do */") 1737 } else if (syscall == "mq_unlink") { 1738 if (mode == "pre") { 1739 pcmd("const char *name = (const char *)name_;") 1740 pcmd("if (name) {") 1741 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1742 pcmd("}") 1743 } else { 1744 pcmd("const char *name = (const char *)name_;") 1745 pcmd("if (name) {") 1746 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1747 pcmd("}") 1748 } 1749 } else if (syscall == "mq_getattr") { 1750 pcmd("/* Nothing to do */") 1751 } else if (syscall == "mq_setattr") { 1752 if (mode == "pre") { 1753 pcmd("if (mqstat_) {") 1754 pcmd(" PRE_READ(mqstat_, struct_mq_attr_sz);") 1755 pcmd("}") 1756 } 1757 } else if (syscall == "mq_notify") { 1758 if (mode == "pre") { 1759 pcmd("if (notification_) {") 1760 pcmd(" PRE_READ(notification_, struct_sigevent_sz);") 1761 pcmd("}") 1762 } 1763 } else if (syscall == "mq_send") { 1764 if (mode == "pre") { 1765 pcmd("if (msg_ptr_) {") 1766 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 1767 pcmd("}") 1768 } 1769 } else if (syscall == "mq_receive") { 1770 pcmd("/* Nothing to do */") 1771 } else if (syscall == "compat_50_mq_timedsend") { 1772 pcmd("/* TODO */") 1773 } else if (syscall == "compat_50_mq_timedreceive") { 1774 pcmd("/* TODO */") 1775 } else if (syscall == "__posix_rename") { 1776 if (mode == "pre") { 1777 pcmd("const char *from = (const char *)from_;") 1778 pcmd("const char *to = (const char *)to_;") 1779 pcmd("if (from_) {") 1780 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 1781 pcmd("}") 1782 pcmd("if (to) {") 1783 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 1784 pcmd("}") 1785 } else { 1786 pcmd("const char *from = (const char *)from_;") 1787 pcmd("const char *to = (const char *)to_;") 1788 pcmd("if (from) {") 1789 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 1790 pcmd("}") 1791 pcmd("if (to) {") 1792 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 1793 pcmd("}") 1794 } 1795 } else if (syscall == "swapctl") { 1796 pcmd("/* TODO */") 1797 } else if (syscall == "compat_30_getdents") { 1798 pcmd("/* TODO */") 1799 } else if (syscall == "minherit") { 1800 pcmd("/* Nothing to do */") 1801 } else if (syscall == "lchmod") { 1802 if (mode == "pre") { 1803 pcmd("const char *path = (const char *)path_;") 1804 pcmd("if (path) {") 1805 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1806 pcmd("}") 1807 } else { 1808 pcmd("const char *path = (const char *)path_;") 1809 pcmd("if (path) {") 1810 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1811 pcmd("}") 1812 } 1813 } else if (syscall == "lchown") { 1814 if (mode == "pre") { 1815 pcmd("const char *path = (const char *)path_;") 1816 pcmd("if (path) {") 1817 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1818 pcmd("}") 1819 } else { 1820 pcmd("const char *path = (const char *)path_;") 1821 pcmd("if (path) {") 1822 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1823 pcmd("}") 1824 } 1825 } else if (syscall == "compat_50_lutimes") { 1826 pcmd("/* TODO */") 1827 } else if (syscall == "__msync13") { 1828 pcmd("/* Nothing to do */") 1829 } else if (syscall == "compat_30___stat13") { 1830 pcmd("/* TODO */") 1831 } else if (syscall == "compat_30___fstat13") { 1832 pcmd("/* TODO */") 1833 } else if (syscall == "compat_30___lstat13") { 1834 pcmd("/* TODO */") 1835 } else if (syscall == "__sigaltstack14") { 1836 if (mode == "pre") { 1837 pcmd("if (nss_) {") 1838 pcmd(" PRE_READ(nss_, struct_sigaltstack_sz);") 1839 pcmd("}") 1840 pcmd("if (oss_) {") 1841 pcmd(" PRE_READ(oss_, struct_sigaltstack_sz);") 1842 pcmd("}") 1843 } 1844 } else if (syscall == "__vfork14") { 1845 pcmd("/* Nothing to do */") 1846 } else if (syscall == "__posix_chown") { 1847 if (mode == "pre") { 1848 pcmd("const char *path = (const char *)path_;") 1849 pcmd("if (path) {") 1850 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1851 pcmd("}") 1852 } else { 1853 pcmd("const char *path = (const char *)path_;") 1854 pcmd("if (path) {") 1855 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1856 pcmd("}") 1857 } 1858 } else if (syscall == "__posix_fchown") { 1859 pcmd("/* Nothing to do */") 1860 } else if (syscall == "__posix_lchown") { 1861 if (mode == "pre") { 1862 pcmd("const char *path = (const char *)path_;") 1863 pcmd("if (path) {") 1864 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1865 pcmd("}") 1866 } else { 1867 pcmd("const char *path = (const char *)path_;") 1868 pcmd("if (path) {") 1869 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1870 pcmd("}") 1871 } 1872 } else if (syscall == "getsid") { 1873 pcmd("/* Nothing to do */") 1874 } else if (syscall == "__clone") { 1875 pcmd("/* Nothing to do */") 1876 } else if (syscall == "fktrace") { 1877 pcmd("/* Nothing to do */") 1878 } else if (syscall == "preadv") { 1879 pcmd("/* Nothing to do */") 1880 } else if (syscall == "pwritev") { 1881 pcmd("/* Nothing to do */") 1882 } else if (syscall == "compat_16___sigaction14") { 1883 pcmd("/* TODO */") 1884 } else if (syscall == "__sigpending14") { 1885 pcmd("/* Nothing to do */") 1886 } else if (syscall == "__sigprocmask14") { 1887 pcmd("/* Nothing to do */") 1888 } else if (syscall == "__sigsuspend14") { 1889 pcmd("if (set_) {") 1890 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 1891 pcmd("}") 1892 } else if (syscall == "compat_16___sigreturn14") { 1893 pcmd("/* TODO */") 1894 } else if (syscall == "__getcwd") { 1895 pcmd("/* Nothing to do */") 1896 } else if (syscall == "fchroot") { 1897 pcmd("/* Nothing to do */") 1898 } else if (syscall == "compat_30_fhopen") { 1899 pcmd("/* TODO */") 1900 } else if (syscall == "compat_30_fhstat") { 1901 pcmd("/* TODO */") 1902 } else if (syscall == "compat_20_fhstatfs") { 1903 pcmd("/* TODO */") 1904 } else if (syscall == "compat_50_____semctl13") { 1905 pcmd("/* TODO */") 1906 } else if (syscall == "compat_50___msgctl13") { 1907 pcmd("/* TODO */") 1908 } else if (syscall == "compat_50___shmctl13") { 1909 pcmd("/* TODO */") 1910 } else if (syscall == "lchflags") { 1911 if (mode == "pre") { 1912 pcmd("const char *path = (const char *)path_;") 1913 pcmd("if (path) {") 1914 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 1915 pcmd("}") 1916 } else { 1917 pcmd("const char *path = (const char *)path_;") 1918 pcmd("if (path) {") 1919 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 1920 pcmd("}") 1921 } 1922 } else if (syscall == "issetugid") { 1923 pcmd("/* Nothing to do */") 1924 } else if (syscall == "utrace") { 1925 if (mode == "pre") { 1926 pcmd("const char *label = (const char *)label_;") 1927 pcmd("if (label) {") 1928 pcmd(" PRE_READ(label, __sanitizer::internal_strlen(label) + 1);") 1929 pcmd("}") 1930 pcmd("if (addr_) {") 1931 pcmd(" PRE_READ(addr_, len_);") 1932 pcmd("}") 1933 } else { 1934 pcmd("const char *label = (const char *)label_;") 1935 pcmd("if (label) {") 1936 pcmd(" POST_READ(label, __sanitizer::internal_strlen(label) + 1);") 1937 pcmd("}") 1938 pcmd("if (addr_) {") 1939 pcmd(" POST_READ(addr_, len_);") 1940 pcmd("}") 1941 } 1942 } else if (syscall == "getcontext") { 1943 pcmd("/* Nothing to do */") 1944 } else if (syscall == "setcontext") { 1945 if (mode == "pre") { 1946 pcmd("if (ucp_) {") 1947 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1948 pcmd("}") 1949 } 1950 } else if (syscall == "_lwp_create") { 1951 if (mode == "pre") { 1952 pcmd("if (ucp_) {") 1953 pcmd(" PRE_READ(ucp_, ucontext_t_sz);") 1954 pcmd("}") 1955 } 1956 } else if (syscall == "_lwp_exit") { 1957 pcmd("/* Nothing to do */") 1958 } else if (syscall == "_lwp_self") { 1959 pcmd("/* Nothing to do */") 1960 } else if (syscall == "_lwp_wait") { 1961 pcmd("/* Nothing to do */") 1962 } else if (syscall == "_lwp_suspend") { 1963 pcmd("/* Nothing to do */") 1964 } else if (syscall == "_lwp_continue") { 1965 pcmd("/* Nothing to do */") 1966 } else if (syscall == "_lwp_wakeup") { 1967 pcmd("/* Nothing to do */") 1968 } else if (syscall == "_lwp_getprivate") { 1969 pcmd("/* Nothing to do */") 1970 } else if (syscall == "_lwp_setprivate") { 1971 pcmd("/* Nothing to do */") 1972 } else if (syscall == "_lwp_kill") { 1973 pcmd("/* Nothing to do */") 1974 } else if (syscall == "_lwp_detach") { 1975 pcmd("/* Nothing to do */") 1976 } else if (syscall == "compat_50__lwp_park") { 1977 pcmd("/* TODO */") 1978 } else if (syscall == "_lwp_unpark") { 1979 pcmd("/* Nothing to do */") 1980 } else if (syscall == "_lwp_unpark_all") { 1981 if (mode == "pre") { 1982 pcmd("if (targets_) {") 1983 pcmd(" PRE_READ(targets_, ntargets_ * sizeof(__sanitizer_lwpid_t));") 1984 pcmd("}") 1985 } 1986 } else if (syscall == "_lwp_setname") { 1987 if (mode == "pre") { 1988 pcmd("const char *name = (const char *)name_;") 1989 pcmd("if (name) {") 1990 pcmd(" PRE_READ(name, __sanitizer::internal_strlen(name) + 1);") 1991 pcmd("}") 1992 } else { 1993 pcmd("const char *name = (const char *)name_;") 1994 pcmd("if (name) {") 1995 pcmd(" POST_READ(name, __sanitizer::internal_strlen(name) + 1);") 1996 pcmd("}") 1997 } 1998 } else if (syscall == "_lwp_getname") { 1999 pcmd("/* Nothing to do */") 2000 } else if (syscall == "_lwp_ctl") { 2001 pcmd("/* Nothing to do */") 2002 } else if (syscall == "compat_60_sa_register") { 2003 pcmd("/* TODO */") 2004 } else if (syscall == "compat_60_sa_stacks") { 2005 pcmd("/* TODO */") 2006 } else if (syscall == "compat_60_sa_enable") { 2007 pcmd("/* TODO */") 2008 } else if (syscall == "compat_60_sa_setconcurrency") { 2009 pcmd("/* TODO */") 2010 } else if (syscall == "compat_60_sa_yield") { 2011 pcmd("/* TODO */") 2012 } else if (syscall == "compat_60_sa_preempt") { 2013 pcmd("/* TODO */") 2014 } else if (syscall == "__sigaction_sigtramp") { 2015 pcmd("if (nsa_) {") 2016 pcmd(" PRE_READ(nsa_, sizeof(__sanitizer_sigaction));") 2017 pcmd("}") 2018 } else if (syscall == "rasctl") { 2019 pcmd("/* Nothing to do */") 2020 } else if (syscall == "kqueue") { 2021 pcmd("/* Nothing to do */") 2022 } else if (syscall == "compat_50_kevent") { 2023 pcmd("/* TODO */") 2024 } else if (syscall == "_sched_setparam") { 2025 pcmd("if (params_) {") 2026 pcmd(" PRE_READ(params_, struct_sched_param_sz);") 2027 pcmd("}") 2028 } else if (syscall == "_sched_getparam") { 2029 pcmd("/* Nothing to do */") 2030 } else if (syscall == "_sched_setaffinity") { 2031 pcmd("if (cpuset_) {") 2032 pcmd(" PRE_READ(cpuset_, size_);") 2033 pcmd("}") 2034 } else if (syscall == "_sched_getaffinity") { 2035 pcmd("/* Nothing to do */") 2036 } else if (syscall == "sched_yield") { 2037 pcmd("/* Nothing to do */") 2038 } else if (syscall == "_sched_protect") { 2039 pcmd("/* Nothing to do */") 2040 } else if (syscall == "fsync_range") { 2041 pcmd("/* Nothing to do */") 2042 } else if (syscall == "uuidgen") { 2043 pcmd("/* Nothing to do */") 2044 } else if (syscall == "compat_90_getvfsstat") { 2045 pcmd("/* Nothing to do */") 2046 } else if (syscall == "compat_90_statvfs1") { 2047 if (mode == "pre") { 2048 pcmd("const char *path = (const char *)path_;") 2049 pcmd("if (path) {") 2050 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2051 pcmd("}") 2052 } else { 2053 pcmd("const char *path = (const char *)path_;") 2054 pcmd("if (path) {") 2055 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2056 pcmd("}") 2057 } 2058 } else if (syscall == "compat_90_fstatvfs1") { 2059 pcmd("/* Nothing to do */") 2060 } else if (syscall == "compat_30_fhstatvfs1") { 2061 pcmd("/* TODO */") 2062 } else if (syscall == "extattrctl") { 2063 if (mode == "pre") { 2064 pcmd("const char *path = (const char *)path_;") 2065 pcmd("if (path) {") 2066 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2067 pcmd("}") 2068 } else { 2069 pcmd("const char *path = (const char *)path_;") 2070 pcmd("if (path) {") 2071 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2072 pcmd("}") 2073 } 2074 } else if (syscall == "extattr_set_file") { 2075 if (mode == "pre") { 2076 pcmd("const char *path = (const char *)path_;") 2077 pcmd("if (path) {") 2078 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2079 pcmd("}") 2080 } else { 2081 pcmd("const char *path = (const char *)path_;") 2082 pcmd("if (path) {") 2083 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2084 pcmd("}") 2085 } 2086 } else if (syscall == "extattr_get_file") { 2087 if (mode == "pre") { 2088 pcmd("const char *path = (const char *)path_;") 2089 pcmd("if (path) {") 2090 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2091 pcmd("}") 2092 } else { 2093 pcmd("const char *path = (const char *)path_;") 2094 pcmd("if (path) {") 2095 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2096 pcmd("}") 2097 } 2098 } else if (syscall == "extattr_delete_file") { 2099 if (mode == "pre") { 2100 pcmd("const char *path = (const char *)path_;") 2101 pcmd("if (path) {") 2102 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2103 pcmd("}") 2104 } else { 2105 pcmd("const char *path = (const char *)path_;") 2106 pcmd("if (path) {") 2107 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2108 pcmd("}") 2109 } 2110 } else if (syscall == "extattr_set_fd") { 2111 pcmd("/* TODO */") 2112 } else if (syscall == "extattr_get_fd") { 2113 pcmd("/* TODO */") 2114 } else if (syscall == "extattr_delete_fd") { 2115 pcmd("/* TODO */") 2116 } else if (syscall == "extattr_set_link") { 2117 if (mode == "pre") { 2118 pcmd("const char *path = (const char *)path_;") 2119 pcmd("if (path) {") 2120 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2121 pcmd("}") 2122 } else { 2123 pcmd("const char *path = (const char *)path_;") 2124 pcmd("if (path) {") 2125 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2126 pcmd("}") 2127 } 2128 } else if (syscall == "extattr_get_link") { 2129 if (mode == "pre") { 2130 pcmd("const char *path = (const char *)path_;") 2131 pcmd("if (path) {") 2132 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2133 pcmd("}") 2134 } else { 2135 pcmd("const char *path = (const char *)path_;") 2136 pcmd("if (path) {") 2137 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2138 pcmd("}") 2139 } 2140 } else if (syscall == "extattr_delete_link") { 2141 if (mode == "pre") { 2142 pcmd("const char *path = (const char *)path_;") 2143 pcmd("if (path) {") 2144 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2145 pcmd("}") 2146 } else { 2147 pcmd("const char *path = (const char *)path_;") 2148 pcmd("if (path) {") 2149 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2150 pcmd("}") 2151 } 2152 } else if (syscall == "extattr_list_fd") { 2153 pcmd("/* TODO */") 2154 } else if (syscall == "extattr_list_file") { 2155 if (mode == "pre") { 2156 pcmd("const char *path = (const char *)path_;") 2157 pcmd("if (path) {") 2158 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2159 pcmd("}") 2160 } else { 2161 pcmd("const char *path = (const char *)path_;") 2162 pcmd("if (path) {") 2163 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2164 pcmd("}") 2165 } 2166 } else if (syscall == "extattr_list_link") { 2167 if (mode == "pre") { 2168 pcmd("const char *path = (const char *)path_;") 2169 pcmd("if (path) {") 2170 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2171 pcmd("}") 2172 } else { 2173 pcmd("const char *path = (const char *)path_;") 2174 pcmd("if (path) {") 2175 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2176 pcmd("}") 2177 } 2178 } else if (syscall == "compat_50_pselect") { 2179 pcmd("/* TODO */") 2180 } else if (syscall == "compat_50_pollts") { 2181 pcmd("/* TODO */") 2182 } else if (syscall == "setxattr") { 2183 if (mode == "pre") { 2184 pcmd("const char *path = (const char *)path_;") 2185 pcmd("if (path) {") 2186 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2187 pcmd("}") 2188 } else { 2189 pcmd("const char *path = (const char *)path_;") 2190 pcmd("if (path) {") 2191 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2192 pcmd("}") 2193 } 2194 } else if (syscall == "lsetxattr") { 2195 if (mode == "pre") { 2196 pcmd("const char *path = (const char *)path_;") 2197 pcmd("if (path) {") 2198 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2199 pcmd("}") 2200 } else { 2201 pcmd("const char *path = (const char *)path_;") 2202 pcmd("if (path) {") 2203 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2204 pcmd("}") 2205 } 2206 } else if (syscall == "fsetxattr") { 2207 pcmd("/* Nothing to do */") 2208 } else if (syscall == "getxattr") { 2209 if (mode == "pre") { 2210 pcmd("const char *path = (const char *)path_;") 2211 pcmd("if (path) {") 2212 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2213 pcmd("}") 2214 } else { 2215 pcmd("const char *path = (const char *)path_;") 2216 pcmd("if (path) {") 2217 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2218 pcmd("}") 2219 } 2220 } else if (syscall == "lgetxattr") { 2221 if (mode == "pre") { 2222 pcmd("const char *path = (const char *)path_;") 2223 pcmd("if (path) {") 2224 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2225 pcmd("}") 2226 } else { 2227 pcmd("const char *path = (const char *)path_;") 2228 pcmd("if (path) {") 2229 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2230 pcmd("}") 2231 } 2232 } else if (syscall == "fgetxattr") { 2233 pcmd("/* Nothing to do */") 2234 } else if (syscall == "listxattr") { 2235 if (mode == "pre") { 2236 pcmd("const char *path = (const char *)path_;") 2237 pcmd("if (path) {") 2238 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2239 pcmd("}") 2240 } else { 2241 pcmd("const char *path = (const char *)path_;") 2242 pcmd("if (path) {") 2243 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2244 pcmd("}") 2245 } 2246 } else if (syscall == "llistxattr") { 2247 if (mode == "pre") { 2248 pcmd("const char *path = (const char *)path_;") 2249 pcmd("if (path) {") 2250 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2251 pcmd("}") 2252 } else { 2253 pcmd("const char *path = (const char *)path_;") 2254 pcmd("if (path) {") 2255 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2256 pcmd("}") 2257 } 2258 } else if (syscall == "flistxattr") { 2259 pcmd("/* TODO */") 2260 } else if (syscall == "removexattr") { 2261 if (mode == "pre") { 2262 pcmd("const char *path = (const char *)path_;") 2263 pcmd("if (path) {") 2264 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2265 pcmd("}") 2266 } else { 2267 pcmd("const char *path = (const char *)path_;") 2268 pcmd("if (path) {") 2269 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2270 pcmd("}") 2271 } 2272 } else if (syscall == "lremovexattr") { 2273 if (mode == "pre") { 2274 pcmd("const char *path = (const char *)path_;") 2275 pcmd("if (path) {") 2276 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2277 pcmd("}") 2278 } else { 2279 pcmd("const char *path = (const char *)path_;") 2280 pcmd("if (path) {") 2281 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2282 pcmd("}") 2283 } 2284 } else if (syscall == "fremovexattr") { 2285 pcmd("/* TODO */") 2286 } else if (syscall == "compat_50___stat30") { 2287 pcmd("/* TODO */") 2288 } else if (syscall == "compat_50___fstat30") { 2289 pcmd("/* TODO */") 2290 } else if (syscall == "compat_50___lstat30") { 2291 pcmd("/* TODO */") 2292 } else if (syscall == "__getdents30") { 2293 pcmd("/* Nothing to do */") 2294 } else if (syscall == "posix_fadvise") { 2295 pcmd("/* Nothing to do */") 2296 } else if (syscall == "compat_30___fhstat30") { 2297 pcmd("/* TODO */") 2298 } else if (syscall == "compat_50___ntp_gettime30") { 2299 pcmd("/* TODO */") 2300 } else if (syscall == "__socket30") { 2301 pcmd("/* Nothing to do */") 2302 } else if (syscall == "__getfh30") { 2303 if (mode == "pre") { 2304 pcmd("const char *fname = (const char *)fname_;") 2305 pcmd("if (fname) {") 2306 pcmd(" PRE_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2307 pcmd("}") 2308 } else { 2309 pcmd("const char *fname = (const char *)fname_;") 2310 pcmd("if (res == 0) {") 2311 pcmd(" if (fname) {") 2312 pcmd(" POST_READ(fname, __sanitizer::internal_strlen(fname) + 1);") 2313 pcmd(" }") 2314 pcmd("}") 2315 } 2316 } else if (syscall == "__fhopen40") { 2317 if (mode == "pre") { 2318 pcmd("if (fhp_) {") 2319 pcmd(" PRE_READ(fhp_, fh_size_);") 2320 pcmd("}") 2321 } 2322 } else if (syscall == "compat_90_fhstatvfs1") { 2323 if (mode == "pre") { 2324 pcmd("if (fhp_) {") 2325 pcmd(" PRE_READ(fhp_, fh_size_);") 2326 pcmd("}") 2327 } 2328 } else if (syscall == "compat_50___fhstat40") { 2329 if (mode == "pre") { 2330 pcmd("if (fhp_) {") 2331 pcmd(" PRE_READ(fhp_, fh_size_);") 2332 pcmd("}") 2333 } 2334 } else if (syscall == "aio_cancel") { 2335 if (mode == "pre") { 2336 pcmd("if (aiocbp_) {") 2337 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2338 pcmd("}") 2339 } 2340 } else if (syscall == "aio_error") { 2341 if (mode == "pre") { 2342 pcmd("if (aiocbp_) {") 2343 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2344 pcmd("}") 2345 } 2346 } else if (syscall == "aio_fsync") { 2347 if (mode == "pre") { 2348 pcmd("if (aiocbp_) {") 2349 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2350 pcmd("}") 2351 } 2352 } else if (syscall == "aio_read") { 2353 if (mode == "pre") { 2354 pcmd("if (aiocbp_) {") 2355 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2356 pcmd("}") 2357 } 2358 } else if (syscall == "aio_return") { 2359 if (mode == "pre") { 2360 pcmd("if (aiocbp_) {") 2361 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2362 pcmd("}") 2363 } 2364 } else if (syscall == "compat_50_aio_suspend") { 2365 pcmd("/* TODO */") 2366 } else if (syscall == "aio_write") { 2367 if (mode == "pre") { 2368 pcmd("if (aiocbp_) {") 2369 pcmd(" PRE_READ(aiocbp_, sizeof(struct __sanitizer_aiocb));") 2370 pcmd("}") 2371 } 2372 } else if (syscall == "lio_listio") { 2373 pcmd("/* Nothing to do */") 2374 } else if (syscall == "__mount50") { 2375 if (mode == "pre") { 2376 pcmd("const char *type = (const char *)type_;") 2377 pcmd("const char *path = (const char *)path_;") 2378 pcmd("if (type) {") 2379 pcmd(" PRE_READ(type, __sanitizer::internal_strlen(type) + 1);") 2380 pcmd("}") 2381 pcmd("if (path) {") 2382 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2383 pcmd("}") 2384 pcmd("if (data_) {") 2385 pcmd(" PRE_READ(data_, data_len_);") 2386 pcmd("}") 2387 } else { 2388 pcmd("const char *type = (const char *)type_;") 2389 pcmd("const char *path = (const char *)path_;") 2390 pcmd("if (type) {") 2391 pcmd(" POST_READ(type, __sanitizer::internal_strlen(type) + 1);") 2392 pcmd("}") 2393 pcmd("if (path) {") 2394 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2395 pcmd("}") 2396 pcmd("if (data_) {") 2397 pcmd(" POST_READ(data_, data_len_);") 2398 pcmd("}") 2399 } 2400 } else if (syscall == "mremap") { 2401 pcmd("/* Nothing to do */") 2402 } else if (syscall == "pset_create") { 2403 pcmd("/* Nothing to do */") 2404 } else if (syscall == "pset_destroy") { 2405 pcmd("/* Nothing to do */") 2406 } else if (syscall == "pset_assign") { 2407 pcmd("/* Nothing to do */") 2408 } else if (syscall == "_pset_bind") { 2409 pcmd("/* Nothing to do */") 2410 } else if (syscall == "__posix_fadvise50") { 2411 pcmd("/* Nothing to do */") 2412 } else if (syscall == "__select50") { 2413 pcmd("/* Nothing to do */") 2414 } else if (syscall == "__gettimeofday50") { 2415 pcmd("/* Nothing to do */") 2416 } else if (syscall == "__settimeofday50") { 2417 if (mode == "pre") { 2418 pcmd("if (tv_) {") 2419 pcmd(" PRE_READ(tv_, timeval_sz);") 2420 pcmd("}") 2421 pcmd("if (tzp_) {") 2422 pcmd(" PRE_READ(tzp_, struct_timezone_sz);") 2423 pcmd("}") 2424 } 2425 } else if (syscall == "__utimes50") { 2426 if (mode == "pre") { 2427 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2428 pcmd("const char *path = (const char *)path_;") 2429 pcmd("if (path) {") 2430 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2431 pcmd("}") 2432 pcmd("if (tptr) {") 2433 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2434 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2435 pcmd("}") 2436 } 2437 } else if (syscall == "__adjtime50") { 2438 if (mode == "pre") { 2439 pcmd("if (delta_) {") 2440 pcmd(" PRE_READ(delta_, timeval_sz);") 2441 pcmd("}") 2442 } 2443 } else if (syscall == "__lfs_segwait50") { 2444 pcmd("/* TODO */") 2445 } else if (syscall == "__futimes50") { 2446 if (mode == "pre") { 2447 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2448 pcmd("if (tptr) {") 2449 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2450 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2451 pcmd("}") 2452 } 2453 } else if (syscall == "__lutimes50") { 2454 if (mode == "pre") { 2455 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2456 pcmd("const char *path = (const char *)path_;") 2457 pcmd("if (path) {") 2458 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2459 pcmd("}") 2460 pcmd("if (tptr) {") 2461 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2462 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2463 pcmd("}") 2464 } else { 2465 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2466 pcmd("const char *path = (const char *)path_;") 2467 pcmd("if (path) {") 2468 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2469 pcmd("}") 2470 pcmd("if (tptr) {") 2471 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2472 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2473 pcmd("}") 2474 } 2475 } else if (syscall == "__setitimer50") { 2476 if (mode == "pre") { 2477 pcmd("struct __sanitizer_itimerval *itv = (struct __sanitizer_itimerval *)itv_;") 2478 pcmd("if (itv) {") 2479 pcmd(" PRE_READ(&itv->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2480 pcmd(" PRE_READ(&itv->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2481 pcmd(" PRE_READ(&itv->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2482 pcmd(" PRE_READ(&itv->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2483 pcmd("}") 2484 } 2485 } else if (syscall == "__getitimer50") { 2486 pcmd("/* Nothing to do */") 2487 } else if (syscall == "__clock_gettime50") { 2488 pcmd("/* Nothing to do */") 2489 } else if (syscall == "__clock_settime50") { 2490 if (mode == "pre") { 2491 pcmd("if (tp_) {") 2492 pcmd(" PRE_READ(tp_, struct_timespec_sz);") 2493 pcmd("}") 2494 } 2495 } else if (syscall == "__clock_getres50") { 2496 pcmd("/* Nothing to do */") 2497 } else if (syscall == "__nanosleep50") { 2498 if (mode == "pre") { 2499 pcmd("if (rqtp_) {") 2500 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2501 pcmd("}") 2502 } 2503 } else if (syscall == "____sigtimedwait50") { 2504 if (mode == "pre") { 2505 pcmd("if (set_) {") 2506 pcmd(" PRE_READ(set_, sizeof(__sanitizer_sigset_t));") 2507 pcmd("}") 2508 pcmd("if (timeout_) {") 2509 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2510 pcmd("}") 2511 } 2512 } else if (syscall == "__mq_timedsend50") { 2513 if (mode == "pre") { 2514 pcmd("if (msg_ptr_) {") 2515 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2516 pcmd("}") 2517 pcmd("if (abs_timeout_) {") 2518 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2519 pcmd("}") 2520 } 2521 } else if (syscall == "__mq_timedreceive50") { 2522 if (mode == "pre") { 2523 pcmd("if (msg_ptr_) {") 2524 pcmd(" PRE_READ(msg_ptr_, msg_len_);") 2525 pcmd("}") 2526 pcmd("if (abs_timeout_) {") 2527 pcmd(" PRE_READ(abs_timeout_, struct_timespec_sz);") 2528 pcmd("}") 2529 } 2530 } else if (syscall == "compat_60__lwp_park") { 2531 pcmd("/* TODO */") 2532 } else if (syscall == "__kevent50") { 2533 if (mode == "pre") { 2534 pcmd("if (changelist_) {") 2535 pcmd(" PRE_READ(changelist_, nchanges_ * struct_kevent_sz);") 2536 pcmd("}") 2537 pcmd("if (timeout_) {") 2538 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2539 pcmd("}") 2540 } 2541 } else if (syscall == "__pselect50") { 2542 if (mode == "pre") { 2543 pcmd("if (ts_) {") 2544 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2545 pcmd("}") 2546 pcmd("if (mask_) {") 2547 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2548 pcmd("}") 2549 } 2550 } else if (syscall == "__pollts50") { 2551 if (mode == "pre") { 2552 pcmd("if (ts_) {") 2553 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2554 pcmd("}") 2555 pcmd("if (mask_) {") 2556 pcmd(" PRE_READ(mask_, sizeof(struct __sanitizer_sigset_t));") 2557 pcmd("}") 2558 } 2559 } else if (syscall == "__aio_suspend50") { 2560 if (mode == "pre") { 2561 pcmd("int i;") 2562 pcmd("const struct aiocb * const *list = (const struct aiocb * const *)list_;") 2563 pcmd("if (list) {") 2564 pcmd(" for (i = 0; i < nent_; i++) {") 2565 pcmd(" if (list[i]) {") 2566 pcmd(" PRE_READ(list[i], sizeof(struct __sanitizer_aiocb));") 2567 pcmd(" }") 2568 pcmd(" }") 2569 pcmd("}") 2570 pcmd("if (timeout_) {") 2571 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2572 pcmd("}") 2573 } 2574 } else if (syscall == "__stat50") { 2575 if (mode == "pre") { 2576 pcmd("const char *path = (const char *)path_;") 2577 pcmd("if (path) {") 2578 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2579 pcmd("}") 2580 } else { 2581 pcmd("const char *path = (const char *)path_;") 2582 pcmd("if (res == 0) {") 2583 pcmd(" if (path) {") 2584 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2585 pcmd(" }") 2586 pcmd("}") 2587 } 2588 } else if (syscall == "__fstat50") { 2589 pcmd("/* Nothing to do */") 2590 } else if (syscall == "__lstat50") { 2591 if (mode == "pre") { 2592 pcmd("const char *path = (const char *)path_;") 2593 pcmd("if (path) {") 2594 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2595 pcmd("}") 2596 } else { 2597 pcmd("const char *path = (const char *)path_;") 2598 pcmd("if (res == 0) {") 2599 pcmd(" if (path) {") 2600 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2601 pcmd(" }") 2602 pcmd("}") 2603 } 2604 } else if (syscall == "____semctl50") { 2605 pcmd("/* Nothing to do */") 2606 } else if (syscall == "__shmctl50") { 2607 pcmd("/* Nothing to do */") 2608 } else if (syscall == "__msgctl50") { 2609 pcmd("/* Nothing to do */") 2610 } else if (syscall == "__getrusage50") { 2611 pcmd("/* Nothing to do */") 2612 } else if (syscall == "__timer_settime50") { 2613 if (mode == "pre") { 2614 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2615 pcmd("if (value) {") 2616 pcmd(" PRE_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2617 pcmd(" PRE_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2618 pcmd(" PRE_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2619 pcmd(" PRE_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2620 pcmd("}") 2621 } else { 2622 pcmd("struct __sanitizer_itimerval *value = (struct __sanitizer_itimerval *)value_;") 2623 pcmd("if (res == 0) {") 2624 pcmd(" if (value) {") 2625 pcmd(" POST_READ(&value->it_interval.tv_sec, sizeof(__sanitizer_time_t));") 2626 pcmd(" POST_READ(&value->it_interval.tv_usec, sizeof(__sanitizer_suseconds_t));") 2627 pcmd(" POST_READ(&value->it_value.tv_sec, sizeof(__sanitizer_time_t));") 2628 pcmd(" POST_READ(&value->it_value.tv_usec, sizeof(__sanitizer_suseconds_t));") 2629 pcmd(" }") 2630 pcmd("}") 2631 } 2632 } else if (syscall == "__timer_gettime50") { 2633 pcmd("/* Nothing to do */") 2634 } else if (syscall == "__ntp_gettime50") { 2635 pcmd("/* Nothing to do */") 2636 } else if (syscall == "__wait450") { 2637 pcmd("/* Nothing to do */") 2638 } else if (syscall == "__mknod50") { 2639 if (mode == "pre") { 2640 pcmd("const char *path = (const char *)path_;") 2641 pcmd("if (path) {") 2642 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2643 pcmd("}") 2644 } else { 2645 pcmd("const char *path = (const char *)path_;") 2646 pcmd("if (res == 0) {") 2647 pcmd(" if (path) {") 2648 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2649 pcmd(" }") 2650 pcmd("}") 2651 } 2652 } else if (syscall == "__fhstat50") { 2653 if (mode == "pre") { 2654 pcmd("if (fhp_) {") 2655 pcmd(" PRE_READ(fhp_, fh_size_);") 2656 pcmd("}") 2657 } else { 2658 pcmd("if (res == 0) {") 2659 pcmd(" if (fhp_) {") 2660 pcmd(" POST_READ(fhp_, fh_size_);") 2661 pcmd(" }") 2662 pcmd("}") 2663 } 2664 } else if (syscall == "pipe2") { 2665 pcmd("/* Nothing to do */") 2666 } else if (syscall == "dup3") { 2667 pcmd("/* Nothing to do */") 2668 } else if (syscall == "kqueue1") { 2669 pcmd("/* Nothing to do */") 2670 } else if (syscall == "paccept") { 2671 if (mode == "pre") { 2672 pcmd("if (mask_) {") 2673 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2674 pcmd("}") 2675 } else { 2676 pcmd("if (res >= 0) {") 2677 pcmd(" if (mask_) {") 2678 pcmd(" PRE_READ(mask_, sizeof(__sanitizer_sigset_t));") 2679 pcmd(" }") 2680 pcmd("}") 2681 } 2682 } else if (syscall == "linkat") { 2683 if (mode == "pre") { 2684 pcmd("const char *name1 = (const char *)name1_;") 2685 pcmd("const char *name2 = (const char *)name2_;") 2686 pcmd("if (name1) {") 2687 pcmd(" PRE_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2688 pcmd("}") 2689 pcmd("if (name2) {") 2690 pcmd(" PRE_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2691 pcmd("}") 2692 } else { 2693 pcmd("const char *name1 = (const char *)name1_;") 2694 pcmd("const char *name2 = (const char *)name2_;") 2695 pcmd("if (res == 0) {") 2696 pcmd(" if (name1) {") 2697 pcmd(" POST_READ(name1, __sanitizer::internal_strlen(name1) + 1);") 2698 pcmd(" }") 2699 pcmd(" if (name2) {") 2700 pcmd(" POST_READ(name2, __sanitizer::internal_strlen(name2) + 1);") 2701 pcmd(" }") 2702 pcmd("}") 2703 } 2704 } else if (syscall == "renameat") { 2705 if (mode == "pre") { 2706 pcmd("const char *from = (const char *)from_;") 2707 pcmd("const char *to = (const char *)to_;") 2708 pcmd("if (from) {") 2709 pcmd(" PRE_READ(from, __sanitizer::internal_strlen(from) + 1);") 2710 pcmd("}") 2711 pcmd("if (to) {") 2712 pcmd(" PRE_READ(to, __sanitizer::internal_strlen(to) + 1);") 2713 pcmd("}") 2714 } else { 2715 pcmd("const char *from = (const char *)from_;") 2716 pcmd("const char *to = (const char *)to_;") 2717 pcmd("if (res == 0) {") 2718 pcmd(" if (from) {") 2719 pcmd(" POST_READ(from, __sanitizer::internal_strlen(from) + 1);") 2720 pcmd(" }") 2721 pcmd(" if (to) {") 2722 pcmd(" POST_READ(to, __sanitizer::internal_strlen(to) + 1);") 2723 pcmd(" }") 2724 pcmd("}") 2725 } 2726 } else if (syscall == "mkfifoat") { 2727 if (mode == "pre") { 2728 pcmd("const char *path = (const char *)path_;") 2729 pcmd("if (path) {") 2730 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2731 pcmd("}") 2732 } else { 2733 pcmd("const char *path = (const char *)path_;") 2734 pcmd("if (res == 0) {") 2735 pcmd(" if (path) {") 2736 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2737 pcmd(" }") 2738 pcmd("}") 2739 } 2740 } else if (syscall == "mknodat") { 2741 if (mode == "pre") { 2742 pcmd("const char *path = (const char *)path_;") 2743 pcmd("if (path) {") 2744 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2745 pcmd("}") 2746 } else { 2747 pcmd("const char *path = (const char *)path_;") 2748 pcmd("if (res == 0) {") 2749 pcmd(" if (path) {") 2750 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2751 pcmd(" }") 2752 pcmd("}") 2753 } 2754 } else if (syscall == "mkdirat") { 2755 if (mode == "pre") { 2756 pcmd("const char *path = (const char *)path_;") 2757 pcmd("if (path) {") 2758 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2759 pcmd("}") 2760 } else { 2761 pcmd("const char *path = (const char *)path_;") 2762 pcmd("if (res == 0) {") 2763 pcmd(" if (path) {") 2764 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2765 pcmd(" }") 2766 pcmd("}") 2767 } 2768 } else if (syscall == "faccessat") { 2769 if (mode == "pre") { 2770 pcmd("const char *path = (const char *)path_;") 2771 pcmd("if (path) {") 2772 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2773 pcmd("}") 2774 } else { 2775 pcmd("const char *path = (const char *)path_;") 2776 pcmd("if (res == 0) {") 2777 pcmd(" if (path) {") 2778 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2779 pcmd(" }") 2780 pcmd("}") 2781 } 2782 } else if (syscall == "fchmodat") { 2783 if (mode == "pre") { 2784 pcmd("const char *path = (const char *)path_;") 2785 pcmd("if (path) {") 2786 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2787 pcmd("}") 2788 } else { 2789 pcmd("const char *path = (const char *)path_;") 2790 pcmd("if (res == 0) {") 2791 pcmd(" if (path) {") 2792 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2793 pcmd(" }") 2794 pcmd("}") 2795 } 2796 } else if (syscall == "fchownat") { 2797 if (mode == "pre") { 2798 pcmd("const char *path = (const char *)path_;") 2799 pcmd("if (path) {") 2800 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2801 pcmd("}") 2802 } else { 2803 pcmd("const char *path = (const char *)path_;") 2804 pcmd("if (res == 0) {") 2805 pcmd(" if (path) {") 2806 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2807 pcmd(" }") 2808 pcmd("}") 2809 } 2810 } else if (syscall == "fexecve") { 2811 pcmd("/* TODO */") 2812 } else if (syscall == "fstatat") { 2813 if (mode == "pre") { 2814 pcmd("const char *path = (const char *)path_;") 2815 pcmd("if (path) {") 2816 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2817 pcmd("}") 2818 } else { 2819 pcmd("const char *path = (const char *)path_;") 2820 pcmd("if (path) {") 2821 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2822 pcmd("}") 2823 } 2824 } else if (syscall == "utimensat") { 2825 if (mode == "pre") { 2826 pcmd("const char *path = (const char *)path_;") 2827 pcmd("if (path) {") 2828 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2829 pcmd("}") 2830 pcmd("if (tptr_) {") 2831 pcmd(" PRE_READ(tptr_, struct_timespec_sz);") 2832 pcmd("}") 2833 } else { 2834 pcmd("const char *path = (const char *)path_;") 2835 pcmd("if (res > 0) {") 2836 pcmd(" if (path) {") 2837 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2838 pcmd(" }") 2839 pcmd(" if (tptr_) {") 2840 pcmd(" POST_READ(tptr_, struct_timespec_sz);") 2841 pcmd(" }") 2842 pcmd("}") 2843 } 2844 } else if (syscall == "openat") { 2845 if (mode == "pre") { 2846 pcmd("const char *path = (const char *)path_;") 2847 pcmd("if (path) {") 2848 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2849 pcmd("}") 2850 } else { 2851 pcmd("const char *path = (const char *)path_;") 2852 pcmd("if (res > 0) {") 2853 pcmd(" if (path) {") 2854 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2855 pcmd(" }") 2856 pcmd("}") 2857 } 2858 } else if (syscall == "readlinkat") { 2859 if (mode == "pre") { 2860 pcmd("const char *path = (const char *)path_;") 2861 pcmd("if (path) {") 2862 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2863 pcmd("}") 2864 } else { 2865 pcmd("const char *path = (const char *)path_;") 2866 pcmd("if (res > 0) {") 2867 pcmd(" if (path) {") 2868 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2869 pcmd(" }") 2870 pcmd("}") 2871 } 2872 } else if (syscall == "symlinkat") { 2873 if (mode == "pre") { 2874 pcmd("const char *path1 = (const char *)path1_;") 2875 pcmd("const char *path2 = (const char *)path2_;") 2876 pcmd("if (path1) {") 2877 pcmd(" PRE_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2878 pcmd("}") 2879 pcmd("if (path2) {") 2880 pcmd(" PRE_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2881 pcmd("}") 2882 } else { 2883 pcmd("const char *path1 = (const char *)path1_;") 2884 pcmd("const char *path2 = (const char *)path2_;") 2885 pcmd("if (res == 0) {") 2886 pcmd(" if (path1) {") 2887 pcmd(" POST_READ(path1, __sanitizer::internal_strlen(path1) + 1);") 2888 pcmd(" }") 2889 pcmd(" if (path2) {") 2890 pcmd(" POST_READ(path2, __sanitizer::internal_strlen(path2) + 1);") 2891 pcmd(" }") 2892 pcmd("}") 2893 } 2894 } else if (syscall == "unlinkat") { 2895 if (mode == "pre") { 2896 pcmd("const char *path = (const char *)path_;") 2897 pcmd("if (path) {") 2898 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2899 pcmd("}") 2900 } else { 2901 pcmd("const char *path = (const char *)path_;") 2902 pcmd("if (res == 0) {") 2903 pcmd(" if (path) {") 2904 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2905 pcmd(" }") 2906 pcmd("}") 2907 } 2908 } else if (syscall == "futimens") { 2909 if (mode == "pre") { 2910 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2911 pcmd("if (tptr) {") 2912 pcmd(" PRE_READ(tptr[0], struct_timespec_sz);") 2913 pcmd(" PRE_READ(tptr[1], struct_timespec_sz);") 2914 pcmd("}") 2915 } else { 2916 pcmd("struct __sanitizer_timespec **tptr = (struct __sanitizer_timespec **)tptr_;") 2917 pcmd("if (res == 0) {") 2918 pcmd(" if (tptr) {") 2919 pcmd(" POST_READ(tptr[0], struct_timespec_sz);") 2920 pcmd(" POST_READ(tptr[1], struct_timespec_sz);") 2921 pcmd(" }") 2922 pcmd("}") 2923 } 2924 } else if (syscall == "__quotactl") { 2925 if (mode == "pre") { 2926 pcmd("const char *path = (const char *)path_;") 2927 pcmd("if (path) {") 2928 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2929 pcmd("}") 2930 } else { 2931 pcmd("const char *path = (const char *)path_;") 2932 pcmd("if (res == 0) {") 2933 pcmd(" if (path) {") 2934 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2935 pcmd(" }") 2936 pcmd("}") 2937 } 2938 } else if (syscall == "posix_spawn") { 2939 if (mode == "pre") { 2940 pcmd("const char *path = (const char *)path_;") 2941 pcmd("if (path) {") 2942 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 2943 pcmd("}") 2944 } else { 2945 pcmd("const char *path = (const char *)path_;") 2946 pcmd("if (pid_) {") 2947 pcmd(" if (path) {") 2948 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 2949 pcmd(" }") 2950 pcmd("}") 2951 } 2952 } else if (syscall == "recvmmsg") { 2953 if (mode == "pre") { 2954 pcmd("if (timeout_) {") 2955 pcmd(" PRE_READ(timeout_, struct_timespec_sz);") 2956 pcmd("}") 2957 } else { 2958 pcmd("if (res >= 0) {") 2959 pcmd(" if (timeout_) {") 2960 pcmd(" POST_READ(timeout_, struct_timespec_sz);") 2961 pcmd(" }") 2962 pcmd("}") 2963 } 2964 } else if (syscall == "sendmmsg") { 2965 if (mode == "pre") { 2966 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2967 pcmd("if (mmsg) {") 2968 pcmd(" PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2969 pcmd("}") 2970 } else { 2971 pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;") 2972 pcmd("if (res >= 0) {") 2973 pcmd(" if (mmsg) {") 2974 pcmd(" POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));") 2975 pcmd(" }") 2976 pcmd("}") 2977 } 2978 } else if (syscall == "clock_nanosleep") { 2979 if (mode == "pre") { 2980 pcmd("if (rqtp_) {") 2981 pcmd(" PRE_READ(rqtp_, struct_timespec_sz);") 2982 pcmd("}") 2983 } else { 2984 pcmd("if (rqtp_) {") 2985 pcmd(" POST_READ(rqtp_, struct_timespec_sz);") 2986 pcmd("}") 2987 } 2988 } else if (syscall == "___lwp_park60") { 2989 if (mode == "pre") { 2990 pcmd("if (ts_) {") 2991 pcmd(" PRE_READ(ts_, struct_timespec_sz);") 2992 pcmd("}") 2993 } else { 2994 pcmd("if (res == 0) {") 2995 pcmd(" if (ts_) {") 2996 pcmd(" POST_READ(ts_, struct_timespec_sz);") 2997 pcmd(" }") 2998 pcmd("}") 2999 } 3000 } else if (syscall == "posix_fallocate") { 3001 pcmd("/* Nothing to do */") 3002 } else if (syscall == "fdiscard") { 3003 pcmd("/* Nothing to do */") 3004 } else if (syscall == "wait6") { 3005 pcmd("/* Nothing to do */") 3006 } else if (syscall == "clock_getcpuclockid2") { 3007 pcmd("/* Nothing to do */") 3008 } else if (syscall == "__getvfsstat90") { 3009 pcmd("/* Nothing to do */") 3010 } else if (syscall == "__statvfs190") { 3011 if (mode == "pre") { 3012 pcmd("const char *path = (const char *)path_;") 3013 pcmd("if (path) {") 3014 pcmd(" PRE_READ(path, __sanitizer::internal_strlen(path) + 1);") 3015 pcmd("}") 3016 } else { 3017 pcmd("const char *path = (const char *)path_;") 3018 pcmd("if (path) {") 3019 pcmd(" POST_READ(path, __sanitizer::internal_strlen(path) + 1);") 3020 pcmd("}") 3021 } 3022 } else if (syscall == "__fstatvfs190") { 3023 pcmd("/* Nothing to do */") 3024 } else if (syscall == "__fhstatvfs190") { 3025 if (mode == "pre") { 3026 pcmd("if (fhp_) {") 3027 pcmd(" PRE_READ(fhp_, fh_size_);") 3028 pcmd("}") 3029 } 3030 } else { 3031 print "Unrecognized syscall: " syscall 3032 abnormal_exit = 1 3033 exit 1 3034 } 3035} 3036