msan_interceptors.cc revision c2918bf11fc65b1f9551eee03719e9bdf02eedd5
1//===-- msan_interceptors.cc ----------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of MemorySanitizer. 11// 12// Interceptors for standard library functions. 13// 14// FIXME: move as many interceptors as possible into 15// sanitizer_common/sanitizer_common_interceptors.h 16//===----------------------------------------------------------------------===// 17 18#include "interception/interception.h" 19#include "msan.h" 20#include "sanitizer_common/sanitizer_platform_limits_posix.h" 21#include "sanitizer_common/sanitizer_allocator.h" 22#include "sanitizer_common/sanitizer_common.h" 23#include "sanitizer_common/sanitizer_stackdepot.h" 24#include "sanitizer_common/sanitizer_libc.h" 25#include "sanitizer_common/sanitizer_linux.h" 26 27#include <stdarg.h> 28// ACHTUNG! No other system header includes in this file. 29// Ideally, we should get rid of stdarg.h as well. 30 31using namespace __msan; 32 33// True if this is a nested interceptor. 34static THREADLOCAL int in_interceptor_scope; 35 36struct InterceptorScope { 37 InterceptorScope() { ++in_interceptor_scope; } 38 ~InterceptorScope() { --in_interceptor_scope; } 39}; 40 41bool IsInInterceptorScope() { 42 return in_interceptor_scope; 43} 44 45#define ENSURE_MSAN_INITED() do { \ 46 CHECK(!msan_init_is_running); \ 47 if (!msan_inited) { \ 48 __msan_init(); \ 49 } \ 50} while (0) 51 52// Check that [x, x+n) range is unpoisoned. 53#define CHECK_UNPOISONED_0(x, n) \ 54 do { \ 55 sptr offset = __msan_test_shadow(x, n); \ 56 if (__msan::IsInSymbolizer()) break; \ 57 if (offset >= 0 && __msan::flags()->report_umrs) { \ 58 GET_CALLER_PC_BP_SP; \ 59 (void) sp; \ 60 Printf("UMR in %s at offset %d inside [%p, +%d) \n", __FUNCTION__, \ 61 offset, x, n); \ 62 __msan::PrintWarningWithOrigin(pc, bp, \ 63 __msan_get_origin((char *)x + offset)); \ 64 if (!__msan::flags()->keep_going) { \ 65 Printf("Exiting\n"); \ 66 Die(); \ 67 } \ 68 } \ 69 } while (0) 70 71// Check that [x, x+n) range is unpoisoned unless we are in a nested 72// interceptor. 73#define CHECK_UNPOISONED(x, n) \ 74 if (!IsInInterceptorScope()) CHECK_UNPOISONED_0(x, n); 75 76static void *fast_memset(void *ptr, int c, SIZE_T n); 77static void *fast_memcpy(void *dst, const void *src, SIZE_T n); 78 79INTERCEPTOR(SIZE_T, fread, void *ptr, SIZE_T size, SIZE_T nmemb, void *file) { 80 ENSURE_MSAN_INITED(); 81 SIZE_T res = REAL(fread)(ptr, size, nmemb, file); 82 if (res > 0) 83 __msan_unpoison(ptr, res *size); 84 return res; 85} 86 87INTERCEPTOR(SIZE_T, fread_unlocked, void *ptr, SIZE_T size, SIZE_T nmemb, 88 void *file) { 89 ENSURE_MSAN_INITED(); 90 SIZE_T res = REAL(fread_unlocked)(ptr, size, nmemb, file); 91 if (res > 0) 92 __msan_unpoison(ptr, res *size); 93 return res; 94} 95 96INTERCEPTOR(SSIZE_T, readlink, const char *path, char *buf, SIZE_T bufsiz) { 97 ENSURE_MSAN_INITED(); 98 SSIZE_T res = REAL(readlink)(path, buf, bufsiz); 99 if (res > 0) 100 __msan_unpoison(buf, res); 101 return res; 102} 103 104INTERCEPTOR(void *, memcpy, void *dest, const void *src, SIZE_T n) { 105 return __msan_memcpy(dest, src, n); 106} 107 108INTERCEPTOR(void *, memmove, void *dest, const void *src, SIZE_T n) { 109 return __msan_memmove(dest, src, n); 110} 111 112INTERCEPTOR(void *, memset, void *s, int c, SIZE_T n) { 113 return __msan_memset(s, c, n); 114} 115 116INTERCEPTOR(int, posix_memalign, void **memptr, SIZE_T alignment, SIZE_T size) { 117 GET_MALLOC_STACK_TRACE; 118 CHECK_EQ(alignment & (alignment - 1), 0); 119 CHECK_NE(memptr, 0); 120 *memptr = MsanReallocate(&stack, 0, size, alignment, false); 121 CHECK_NE(*memptr, 0); 122 __msan_unpoison(memptr, sizeof(*memptr)); 123 return 0; 124} 125 126INTERCEPTOR(void, free, void *ptr) { 127 ENSURE_MSAN_INITED(); 128 if (ptr == 0) return; 129 MsanDeallocate(ptr); 130} 131 132INTERCEPTOR(SIZE_T, strlen, const char *s) { 133 ENSURE_MSAN_INITED(); 134 SIZE_T res = REAL(strlen)(s); 135 CHECK_UNPOISONED(s, res + 1); 136 return res; 137} 138 139INTERCEPTOR(SIZE_T, strnlen, const char *s, SIZE_T n) { 140 ENSURE_MSAN_INITED(); 141 SIZE_T res = REAL(strnlen)(s, n); 142 SIZE_T scan_size = (res == n) ? res : res + 1; 143 CHECK_UNPOISONED(s, scan_size); 144 return res; 145} 146 147// FIXME: Add stricter shadow checks in str* interceptors (ex.: strcpy should 148// check the shadow of the terminating \0 byte). 149 150INTERCEPTOR(char *, strcpy, char *dest, const char *src) { // NOLINT 151 ENSURE_MSAN_INITED(); 152 SIZE_T n = REAL(strlen)(src); 153 char *res = REAL(strcpy)(dest, src); // NOLINT 154 __msan_copy_poison(dest, src, n + 1); 155 return res; 156} 157 158INTERCEPTOR(char *, strncpy, char *dest, const char *src, SIZE_T n) { // NOLINT 159 ENSURE_MSAN_INITED(); 160 SIZE_T copy_size = REAL(strnlen)(src, n); 161 if (copy_size < n) 162 copy_size++; // trailing \0 163 char *res = REAL(strncpy)(dest, src, n); // NOLINT 164 __msan_copy_poison(dest, src, copy_size); 165 return res; 166} 167 168INTERCEPTOR(char *, strdup, char *src) { 169 ENSURE_MSAN_INITED(); 170 SIZE_T n = REAL(strlen)(src); 171 char *res = REAL(strdup)(src); 172 __msan_copy_poison(res, src, n + 1); 173 return res; 174} 175 176INTERCEPTOR(char *, __strdup, char *src) { 177 ENSURE_MSAN_INITED(); 178 SIZE_T n = REAL(strlen)(src); 179 char *res = REAL(__strdup)(src); 180 __msan_copy_poison(res, src, n + 1); 181 return res; 182} 183 184INTERCEPTOR(char *, strndup, char *src, SIZE_T n) { 185 ENSURE_MSAN_INITED(); 186 SIZE_T copy_size = REAL(strnlen)(src, n); 187 char *res = REAL(strndup)(src, n); 188 __msan_copy_poison(res, src, copy_size); 189 __msan_unpoison(res + copy_size, 1); // \0 190 return res; 191} 192 193INTERCEPTOR(char *, __strndup, char *src, SIZE_T n) { 194 ENSURE_MSAN_INITED(); 195 SIZE_T copy_size = REAL(strnlen)(src, n); 196 char *res = REAL(__strndup)(src, n); 197 __msan_copy_poison(res, src, copy_size); 198 __msan_unpoison(res + copy_size, 1); // \0 199 return res; 200} 201 202INTERCEPTOR(char *, gcvt, double number, SIZE_T ndigit, char *buf) { 203 ENSURE_MSAN_INITED(); 204 char *res = REAL(gcvt)(number, ndigit, buf); 205 // DynamoRio tool will take care of unpoisoning gcvt result for us. 206 if (!__msan_has_dynamic_component()) { 207 SIZE_T n = REAL(strlen)(buf); 208 __msan_unpoison(buf, n + 1); 209 } 210 return res; 211} 212 213INTERCEPTOR(char *, strcat, char *dest, const char *src) { // NOLINT 214 ENSURE_MSAN_INITED(); 215 SIZE_T src_size = REAL(strlen)(src); 216 SIZE_T dest_size = REAL(strlen)(dest); 217 char *res = REAL(strcat)(dest, src); // NOLINT 218 __msan_copy_poison(dest + dest_size, src, src_size + 1); 219 return res; 220} 221 222INTERCEPTOR(char *, strncat, char *dest, const char *src, SIZE_T n) { // NOLINT 223 ENSURE_MSAN_INITED(); 224 SIZE_T dest_size = REAL(strlen)(dest); 225 SIZE_T copy_size = REAL(strlen)(src); 226 if (copy_size < n) 227 copy_size++; // trailing \0 228 char *res = REAL(strncat)(dest, src, n); // NOLINT 229 __msan_copy_poison(dest + dest_size, src, copy_size); 230 return res; 231} 232 233INTERCEPTOR(long, strtol, const char *nptr, char **endptr, // NOLINT 234 int base) { 235 ENSURE_MSAN_INITED(); 236 long res = REAL(strtol)(nptr, endptr, base); // NOLINT 237 if (!__msan_has_dynamic_component()) { 238 __msan_unpoison(endptr, sizeof(*endptr)); 239 } 240 return res; 241} 242 243INTERCEPTOR(long long, strtoll, const char *nptr, char **endptr, // NOLINT 244 int base) { 245 ENSURE_MSAN_INITED(); 246 long res = REAL(strtoll)(nptr, endptr, base); //NOLINT 247 if (!__msan_has_dynamic_component()) { 248 __msan_unpoison(endptr, sizeof(*endptr)); 249 } 250 return res; 251} 252 253INTERCEPTOR(unsigned long, strtoul, const char *nptr, char **endptr, // NOLINT 254 int base) { 255 ENSURE_MSAN_INITED(); 256 unsigned long res = REAL(strtoul)(nptr, endptr, base); // NOLINT 257 if (!__msan_has_dynamic_component()) { 258 __msan_unpoison(endptr, sizeof(*endptr)); 259 } 260 return res; 261} 262 263INTERCEPTOR(unsigned long long, strtoull, const char *nptr, // NOLINT 264 char **endptr, int base) { 265 ENSURE_MSAN_INITED(); 266 unsigned long res = REAL(strtoull)(nptr, endptr, base); // NOLINT 267 if (!__msan_has_dynamic_component()) { 268 __msan_unpoison(endptr, sizeof(*endptr)); 269 } 270 return res; 271} 272 273INTERCEPTOR(double, strtod, const char *nptr, char **endptr) { // NOLINT 274 ENSURE_MSAN_INITED(); 275 double res = REAL(strtod)(nptr, endptr); // NOLINT 276 if (!__msan_has_dynamic_component()) { 277 __msan_unpoison(endptr, sizeof(*endptr)); 278 } 279 return res; 280} 281 282INTERCEPTOR(float, strtof, const char *nptr, char **endptr) { // NOLINT 283 ENSURE_MSAN_INITED(); 284 float res = REAL(strtof)(nptr, endptr); // NOLINT 285 if (!__msan_has_dynamic_component()) { 286 __msan_unpoison(endptr, sizeof(*endptr)); 287 } 288 return res; 289} 290 291INTERCEPTOR(long double, strtold, const char *nptr, char **endptr) { // NOLINT 292 ENSURE_MSAN_INITED(); 293 long double res = REAL(strtold)(nptr, endptr); // NOLINT 294 if (!__msan_has_dynamic_component()) { 295 __msan_unpoison(endptr, sizeof(*endptr)); 296 } 297 return res; 298} 299 300INTERCEPTOR(int, vasprintf, char **strp, const char *format, va_list ap) { 301 ENSURE_MSAN_INITED(); 302 int res = REAL(vasprintf)(strp, format, ap); 303 if (res >= 0 && !__msan_has_dynamic_component()) { 304 __msan_unpoison(strp, sizeof(*strp)); 305 __msan_unpoison(*strp, res + 1); 306 } 307 return res; 308} 309 310INTERCEPTOR(int, asprintf, char **strp, const char *format, ...) { // NOLINT 311 ENSURE_MSAN_INITED(); 312 va_list ap; 313 va_start(ap, format); 314 int res = vasprintf(strp, format, ap); // NOLINT 315 va_end(ap); 316 return res; 317} 318 319INTERCEPTOR(int, vsnprintf, char *str, uptr size, 320 const char *format, va_list ap) { 321 ENSURE_MSAN_INITED(); 322 int res = REAL(vsnprintf)(str, size, format, ap); 323 if (res >= 0 && !__msan_has_dynamic_component()) { 324 __msan_unpoison(str, res + 1); 325 } 326 return res; 327} 328 329INTERCEPTOR(int, vsprintf, char *str, const char *format, va_list ap) { 330 ENSURE_MSAN_INITED(); 331 int res = REAL(vsprintf)(str, format, ap); 332 if (res >= 0 && !__msan_has_dynamic_component()) { 333 __msan_unpoison(str, res + 1); 334 } 335 return res; 336} 337 338INTERCEPTOR(int, vswprintf, void *str, uptr size, void *format, va_list ap) { 339 ENSURE_MSAN_INITED(); 340 int res = REAL(vswprintf)(str, size, format, ap); 341 if (res >= 0 && !__msan_has_dynamic_component()) { 342 __msan_unpoison(str, 4 * (res + 1)); 343 } 344 return res; 345} 346 347INTERCEPTOR(int, sprintf, char *str, const char *format, ...) { // NOLINT 348 ENSURE_MSAN_INITED(); 349 va_list ap; 350 va_start(ap, format); 351 int res = vsprintf(str, format, ap); // NOLINT 352 va_end(ap); 353 return res; 354} 355 356INTERCEPTOR(int, snprintf, char *str, uptr size, const char *format, ...) { 357 ENSURE_MSAN_INITED(); 358 va_list ap; 359 va_start(ap, format); 360 int res = vsnprintf(str, size, format, ap); 361 va_end(ap); 362 return res; 363} 364 365INTERCEPTOR(int, swprintf, void *str, uptr size, void *format, ...) { 366 ENSURE_MSAN_INITED(); 367 va_list ap; 368 va_start(ap, format); 369 int res = vswprintf(str, size, format, ap); 370 va_end(ap); 371 return res; 372} 373 374// SIZE_T strftime(char *s, SIZE_T max, const char *format,const struct tm *tm); 375INTERCEPTOR(SIZE_T, strftime, char *s, SIZE_T max, const char *format, 376 void *tm) { 377 ENSURE_MSAN_INITED(); 378 SIZE_T res = REAL(strftime)(s, max, format, tm); 379 if (res) __msan_unpoison(s, res + 1); 380 return res; 381} 382 383INTERCEPTOR(SIZE_T, wcstombs, void *dest, void *src, SIZE_T size) { 384 ENSURE_MSAN_INITED(); 385 SIZE_T res = REAL(wcstombs)(dest, src, size); 386 if (res != (SIZE_T)-1) __msan_unpoison(dest, res + 1); 387 return res; 388} 389 390// SIZE_T mbstowcs(wchar_t *dest, const char *src, SIZE_T n); 391INTERCEPTOR(SIZE_T, mbstowcs, wchar_t *dest, const char *src, SIZE_T n) { 392 ENSURE_MSAN_INITED(); 393 SIZE_T res = REAL(mbstowcs)(dest, src, n); 394 if (res != (SIZE_T)-1) __msan_unpoison(dest, (res + 1) * sizeof(wchar_t)); 395 return res; 396} 397 398INTERCEPTOR(SIZE_T, wcslen, const wchar_t *s) { 399 ENSURE_MSAN_INITED(); 400 SIZE_T res = REAL(wcslen)(s); 401 CHECK_UNPOISONED(s, sizeof(wchar_t) * (res + 1)); 402 return res; 403} 404 405// wchar_t *wcschr(const wchar_t *wcs, wchar_t wc); 406INTERCEPTOR(wchar_t *, wcschr, void *s, wchar_t wc, void *ps) { 407 ENSURE_MSAN_INITED(); 408 wchar_t *res = REAL(wcschr)(s, wc, ps); 409 return res; 410} 411 412// wchar_t *wcscpy(wchar_t *dest, const wchar_t *src); 413INTERCEPTOR(wchar_t *, wcscpy, wchar_t *dest, const wchar_t *src) { 414 ENSURE_MSAN_INITED(); 415 wchar_t *res = REAL(wcscpy)(dest, src); 416 __msan_copy_poison(dest, src, sizeof(wchar_t) * (REAL(wcslen)(src) + 1)); 417 return res; 418} 419 420// wchar_t *wmemcpy(wchar_t *dest, const wchar_t *src, SIZE_T n); 421INTERCEPTOR(wchar_t *, wmemcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) { 422 ENSURE_MSAN_INITED(); 423 wchar_t *res = REAL(wmemcpy)(dest, src, n); 424 __msan_copy_poison(dest, src, n * sizeof(wchar_t)); 425 return res; 426} 427 428INTERCEPTOR(wchar_t *, wmemset, wchar_t *s, wchar_t c, SIZE_T n) { 429 CHECK(MEM_IS_APP(s)); 430 ENSURE_MSAN_INITED(); 431 wchar_t *res = (wchar_t *)fast_memset(s, c, n * sizeof(wchar_t)); 432 __msan_unpoison(s, n * sizeof(wchar_t)); 433 return res; 434} 435 436INTERCEPTOR(wchar_t *, wmemmove, wchar_t *dest, const wchar_t *src, SIZE_T n) { 437 ENSURE_MSAN_INITED(); 438 wchar_t *res = REAL(wmemmove)(dest, src, n); 439 __msan_move_poison(dest, src, n * sizeof(wchar_t)); 440 return res; 441} 442 443INTERCEPTOR(int, wcscmp, const wchar_t *s1, const wchar_t *s2) { 444 ENSURE_MSAN_INITED(); 445 int res = REAL(wcscmp)(s1, s2); 446 return res; 447} 448 449INTERCEPTOR(double, wcstod, const wchar_t *nptr, wchar_t **endptr) { 450 ENSURE_MSAN_INITED(); 451 double res = REAL(wcstod)(nptr, endptr); 452 __msan_unpoison(endptr, sizeof(*endptr)); 453 return res; 454} 455 456// #define UNSUPPORTED(name) \ 457// INTERCEPTOR(void, name, void) { \ 458// Printf("MSAN: Unsupported %s\n", __FUNCTION__); \ 459// Die(); \ 460// } 461 462// FIXME: intercept the following functions: 463// Note, they only matter when running without a dynamic tool. 464// UNSUPPORTED(wcscoll_l) 465// UNSUPPORTED(wcsnrtombs) 466// UNSUPPORTED(wcstol) 467// UNSUPPORTED(wcstoll) 468// UNSUPPORTED(wcstold) 469// UNSUPPORTED(wcstoul) 470// UNSUPPORTED(wcstoull) 471// UNSUPPORTED(wcsxfrm_l) 472// UNSUPPORTED(wcsdup) 473// UNSUPPORTED(wcsftime) 474// UNSUPPORTED(wcsstr) 475// UNSUPPORTED(wcsrchr) 476// UNSUPPORTED(wctob) 477 478INTERCEPTOR(int, gettimeofday, void *tv, void *tz) { 479 ENSURE_MSAN_INITED(); 480 int res = REAL(gettimeofday)(tv, tz); 481 if (tv) 482 __msan_unpoison(tv, 16); 483 if (tz) 484 __msan_unpoison(tz, 8); 485 return res; 486} 487 488INTERCEPTOR(char *, fcvt, double x, int a, int *b, int *c) { 489 ENSURE_MSAN_INITED(); 490 char *res = REAL(fcvt)(x, a, b, c); 491 if (!__msan_has_dynamic_component()) { 492 __msan_unpoison(b, sizeof(*b)); 493 __msan_unpoison(c, sizeof(*c)); 494 } 495 return res; 496} 497 498INTERCEPTOR(char *, getenv, char *name) { 499 ENSURE_MSAN_INITED(); 500 char *res = REAL(getenv)(name); 501 if (!__msan_has_dynamic_component()) { 502 if (res) 503 __msan_unpoison(res, REAL(strlen)(res) + 1); 504 } 505 return res; 506} 507 508INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) { 509 ENSURE_MSAN_INITED(); 510 int res = REAL(__fxstat)(magic, fd, buf); 511 if (!res) 512 __msan_unpoison(buf, __sanitizer::struct_stat_sz); 513 return res; 514} 515 516INTERCEPTOR(int, __fxstat64, int magic, int fd, void *buf) { 517 ENSURE_MSAN_INITED(); 518 int res = REAL(__fxstat64)(magic, fd, buf); 519 if (!res) 520 __msan_unpoison(buf, __sanitizer::struct_stat64_sz); 521 return res; 522} 523 524INTERCEPTOR(int, __xstat, int magic, char *path, void *buf) { 525 ENSURE_MSAN_INITED(); 526 int res = REAL(__xstat)(magic, path, buf); 527 if (!res) 528 __msan_unpoison(buf, __sanitizer::struct_stat_sz); 529 return res; 530} 531 532INTERCEPTOR(int, __xstat64, int magic, char *path, void *buf) { 533 ENSURE_MSAN_INITED(); 534 int res = REAL(__xstat64)(magic, path, buf); 535 if (!res) 536 __msan_unpoison(buf, __sanitizer::struct_stat64_sz); 537 return res; 538} 539 540INTERCEPTOR(int, __lxstat, int magic, char *path, void *buf) { 541 ENSURE_MSAN_INITED(); 542 int res = REAL(__lxstat)(magic, path, buf); 543 if (!res) 544 __msan_unpoison(buf, __sanitizer::struct_stat_sz); 545 return res; 546} 547 548INTERCEPTOR(int, __lxstat64, int magic, char *path, void *buf) { 549 ENSURE_MSAN_INITED(); 550 int res = REAL(__lxstat64)(magic, path, buf); 551 if (!res) 552 __msan_unpoison(buf, __sanitizer::struct_stat64_sz); 553 return res; 554} 555 556INTERCEPTOR(int, pipe, int pipefd[2]) { 557 if (msan_init_is_running) 558 return REAL(pipe)(pipefd); 559 ENSURE_MSAN_INITED(); 560 int res = REAL(pipe)(pipefd); 561 if (!res) 562 __msan_unpoison(pipefd, sizeof(int[2])); 563 return res; 564} 565 566INTERCEPTOR(int, pipe2, int pipefd[2], int flags) { 567 ENSURE_MSAN_INITED(); 568 int res = REAL(pipe2)(pipefd, flags); 569 if (!res) 570 __msan_unpoison(pipefd, sizeof(int[2])); 571 return res; 572} 573 574INTERCEPTOR(int, socketpair, int domain, int type, int protocol, int sv[2]) { 575 ENSURE_MSAN_INITED(); 576 int res = REAL(socketpair)(domain, type, protocol, sv); 577 if (!res) 578 __msan_unpoison(sv, sizeof(int[2])); 579 return res; 580} 581 582INTERCEPTOR(char *, fgets, char *s, int size, void *stream) { 583 ENSURE_MSAN_INITED(); 584 char *res = REAL(fgets)(s, size, stream); 585 if (res) 586 __msan_unpoison(s, REAL(strlen)(s) + 1); 587 return res; 588} 589 590INTERCEPTOR(char *, fgets_unlocked, char *s, int size, void *stream) { 591 ENSURE_MSAN_INITED(); 592 char *res = REAL(fgets_unlocked)(s, size, stream); 593 if (res) 594 __msan_unpoison(s, REAL(strlen)(s) + 1); 595 return res; 596} 597 598INTERCEPTOR(char *, getcwd, char *buf, SIZE_T size) { 599 ENSURE_MSAN_INITED(); 600 char *res = REAL(getcwd)(buf, size); 601 if (res) 602 __msan_unpoison(res, REAL(strlen)(res) + 1); 603 return res; 604} 605 606INTERCEPTOR(char *, realpath, char *path, char *abspath) { 607 ENSURE_MSAN_INITED(); 608 char *res = REAL(realpath)(path, abspath); 609 if (res) 610 __msan_unpoison(abspath, REAL(strlen)(abspath) + 1); 611 return res; 612} 613 614INTERCEPTOR(int, getrlimit, int resource, void *rlim) { 615 if (msan_init_is_running) 616 return REAL(getrlimit)(resource, rlim); 617 ENSURE_MSAN_INITED(); 618 int res = REAL(getrlimit)(resource, rlim); 619 if (!res) 620 __msan_unpoison(rlim, __sanitizer::struct_rlimit_sz); 621 return res; 622} 623 624INTERCEPTOR(int, getrlimit64, int resource, void *rlim) { 625 if (msan_init_is_running) 626 return REAL(getrlimit64)(resource, rlim); 627 ENSURE_MSAN_INITED(); 628 int res = REAL(getrlimit64)(resource, rlim); 629 if (!res) 630 __msan_unpoison(rlim, __sanitizer::struct_rlimit64_sz); 631 return res; 632} 633 634INTERCEPTOR(int, statfs, const char *s, void *buf) { 635 ENSURE_MSAN_INITED(); 636 int res = REAL(statfs)(s, buf); 637 if (!res) 638 __msan_unpoison(buf, __sanitizer::struct_statfs_sz); 639 return res; 640} 641 642INTERCEPTOR(int, fstatfs, int fd, void *buf) { 643 ENSURE_MSAN_INITED(); 644 int res = REAL(fstatfs)(fd, buf); 645 if (!res) 646 __msan_unpoison(buf, __sanitizer::struct_statfs_sz); 647 return res; 648} 649 650INTERCEPTOR(int, statfs64, const char *s, void *buf) { 651 ENSURE_MSAN_INITED(); 652 int res = REAL(statfs64)(s, buf); 653 if (!res) 654 __msan_unpoison(buf, __sanitizer::struct_statfs64_sz); 655 return res; 656} 657 658INTERCEPTOR(int, fstatfs64, int fd, void *buf) { 659 ENSURE_MSAN_INITED(); 660 int res = REAL(fstatfs64)(fd, buf); 661 if (!res) 662 __msan_unpoison(buf, __sanitizer::struct_statfs64_sz); 663 return res; 664} 665 666INTERCEPTOR(int, uname, void *utsname) { 667 ENSURE_MSAN_INITED(); 668 int res = REAL(uname)(utsname); 669 if (!res) { 670 __msan_unpoison(utsname, __sanitizer::struct_utsname_sz); 671 } 672 return res; 673} 674 675INTERCEPTOR(int, gethostname, char *name, SIZE_T len) { 676 ENSURE_MSAN_INITED(); 677 int res = REAL(gethostname)(name, len); 678 if (!res) { 679 SIZE_T real_len = REAL(strnlen)(name, len); 680 if (real_len < len) 681 ++real_len; 682 __msan_unpoison(name, real_len); 683 } 684 return res; 685} 686 687INTERCEPTOR(int, epoll_wait, int epfd, void *events, int maxevents, 688 int timeout) { 689 ENSURE_MSAN_INITED(); 690 int res = REAL(epoll_wait)(epfd, events, maxevents, timeout); 691 if (res > 0) { 692 __msan_unpoison(events, __sanitizer::struct_epoll_event_sz * res); 693 } 694 return res; 695} 696 697INTERCEPTOR(int, epoll_pwait, int epfd, void *events, int maxevents, 698 int timeout, void *sigmask) { 699 ENSURE_MSAN_INITED(); 700 int res = REAL(epoll_pwait)(epfd, events, maxevents, timeout, sigmask); 701 if (res > 0) { 702 __msan_unpoison(events, __sanitizer::struct_epoll_event_sz * res); 703 } 704 return res; 705} 706 707INTERCEPTOR(SSIZE_T, recv, int fd, void *buf, SIZE_T len, int flags) { 708 ENSURE_MSAN_INITED(); 709 SSIZE_T res = REAL(recv)(fd, buf, len, flags); 710 if (res > 0) 711 __msan_unpoison(buf, res); 712 return res; 713} 714 715INTERCEPTOR(SSIZE_T, recvfrom, int fd, void *buf, SIZE_T len, int flags, 716 void *srcaddr, int *addrlen) { 717 ENSURE_MSAN_INITED(); 718 SIZE_T srcaddr_sz; 719 if (srcaddr) srcaddr_sz = *addrlen; 720 SSIZE_T res = REAL(recvfrom)(fd, buf, len, flags, srcaddr, addrlen); 721 if (res > 0) { 722 __msan_unpoison(buf, res); 723 if (srcaddr) { 724 SIZE_T sz = *addrlen; 725 __msan_unpoison(srcaddr, (sz < srcaddr_sz) ? sz : srcaddr_sz); 726 } 727 } 728 return res; 729} 730 731INTERCEPTOR(void *, calloc, SIZE_T nmemb, SIZE_T size) { 732 if (CallocShouldReturnNullDueToOverflow(size, nmemb)) return 0; 733 GET_MALLOC_STACK_TRACE; 734 if (!msan_inited) { 735 // Hack: dlsym calls calloc before REAL(calloc) is retrieved from dlsym. 736 const SIZE_T kCallocPoolSize = 1024; 737 static uptr calloc_memory_for_dlsym[kCallocPoolSize]; 738 static SIZE_T allocated; 739 SIZE_T size_in_words = ((nmemb * size) + kWordSize - 1) / kWordSize; 740 void *mem = (void*)&calloc_memory_for_dlsym[allocated]; 741 allocated += size_in_words; 742 CHECK(allocated < kCallocPoolSize); 743 return mem; 744 } 745 return MsanReallocate(&stack, 0, nmemb * size, sizeof(u64), true); 746} 747 748INTERCEPTOR(void *, realloc, void *ptr, SIZE_T size) { 749 GET_MALLOC_STACK_TRACE; 750 return MsanReallocate(&stack, ptr, size, sizeof(u64), false); 751} 752 753INTERCEPTOR(void *, malloc, SIZE_T size) { 754 GET_MALLOC_STACK_TRACE; 755 return MsanReallocate(&stack, 0, size, sizeof(u64), false); 756} 757 758void __msan_allocated_memory(const void* data, uptr size) { 759 GET_MALLOC_STACK_TRACE; 760 if (flags()->poison_in_malloc) 761 __msan_poison(data, size); 762 if (__msan_get_track_origins()) { 763 u32 stack_id = StackDepotPut(stack.trace, stack.size); 764 CHECK(stack_id); 765 CHECK_EQ((stack_id >> 31), 0); // Higher bit is occupied by stack origins. 766 __msan_set_origin(data, size, stack_id); 767 } 768} 769 770INTERCEPTOR(void *, mmap, void *addr, SIZE_T length, int prot, int flags, 771 int fd, OFF_T offset) { 772 ENSURE_MSAN_INITED(); 773 void *res = REAL(mmap)(addr, length, prot, flags, fd, offset); 774 if (res != (void*)-1) 775 __msan_unpoison(res, RoundUpTo(length, GetPageSize())); 776 return res; 777} 778 779INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags, 780 int fd, OFF64_T offset) { 781 ENSURE_MSAN_INITED(); 782 void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset); 783 if (res != (void*)-1) 784 __msan_unpoison(res, RoundUpTo(length, GetPageSize())); 785 return res; 786} 787 788struct dlinfo { 789 char *dli_fname; 790 void *dli_fbase; 791 char *dli_sname; 792 void *dli_saddr; 793}; 794 795INTERCEPTOR(int, dladdr, void *addr, dlinfo *info) { 796 ENSURE_MSAN_INITED(); 797 int res = REAL(dladdr)(addr, info); 798 if (res != 0) { 799 __msan_unpoison(info, sizeof(*info)); 800 if (info->dli_fname) 801 __msan_unpoison(info->dli_fname, REAL(strlen)(info->dli_fname) + 1); 802 if (info->dli_sname) 803 __msan_unpoison(info->dli_sname, REAL(strlen)(info->dli_sname) + 1); 804 } 805 return res; 806} 807 808// dlopen() ultimately calls mmap() down inside the loader, which generally 809// doesn't participate in dynamic symbol resolution. Therefore we won't 810// intercept its calls to mmap, and we have to hook it here. The loader 811// initializes the module before returning, so without the dynamic component, we 812// won't be able to clear the shadow before the initializers. Fixing this would 813// require putting our own initializer first to clear the shadow. 814INTERCEPTOR(void *, dlopen, const char *filename, int flag) { 815 ENSURE_MSAN_INITED(); 816 EnterLoader(); 817 link_map *map = (link_map *)REAL(dlopen)(filename, flag); 818 ExitLoader(); 819 if (!__msan_has_dynamic_component() && map) { 820 // If msandr didn't clear the shadow before the initializers ran, we do it 821 // ourselves afterwards. 822 UnpoisonMappedDSO(map); 823 } 824 return (void *)map; 825} 826 827typedef int (*dl_iterate_phdr_cb)(__sanitizer_dl_phdr_info *info, SIZE_T size, 828 void *data); 829struct dl_iterate_phdr_data { 830 dl_iterate_phdr_cb callback; 831 void *data; 832}; 833 834static int msan_dl_iterate_phdr_cb(__sanitizer_dl_phdr_info *info, SIZE_T size, 835 void *data) { 836 if (info) { 837 __msan_unpoison(info, size); 838 if (info->dlpi_name) 839 __msan_unpoison(info->dlpi_name, REAL(strlen)(info->dlpi_name) + 1); 840 } 841 dl_iterate_phdr_data *cbdata = (dl_iterate_phdr_data *)data; 842 UnpoisonParam(3); 843 return cbdata->callback(info, size, cbdata->data); 844} 845 846INTERCEPTOR(int, dl_iterate_phdr, dl_iterate_phdr_cb callback, void *data) { 847 ENSURE_MSAN_INITED(); 848 EnterLoader(); 849 dl_iterate_phdr_data cbdata; 850 cbdata.callback = callback; 851 cbdata.data = data; 852 int res = REAL(dl_iterate_phdr)(msan_dl_iterate_phdr_cb, (void *)&cbdata); 853 ExitLoader(); 854 return res; 855} 856 857INTERCEPTOR(int, getrusage, int who, void *usage) { 858 ENSURE_MSAN_INITED(); 859 int res = REAL(getrusage)(who, usage); 860 if (res == 0) { 861 __msan_unpoison(usage, __sanitizer::struct_rusage_sz); 862 } 863 return res; 864} 865 866const int kMaxSignals = 1024; 867static uptr sigactions[kMaxSignals]; 868static StaticSpinMutex sigactions_mu; 869 870static void SignalHandler(int signo) { 871 typedef void (*signal_cb)(int x); 872 signal_cb cb = (signal_cb)sigactions[signo]; 873 cb(signo); 874} 875 876static void SignalAction(int signo, void *si, void *uc) { 877 UnpoisonParam(3); 878 __msan_unpoison(si, __sanitizer::struct_sigaction_sz); 879 __msan_unpoison(uc, __sanitizer::ucontext_t_sz); 880 881 typedef void (*sigaction_cb)(int, void *, void *); 882 sigaction_cb cb = (sigaction_cb)sigactions[signo]; 883 cb(signo, si, uc); 884} 885 886INTERCEPTOR(int, sigaction, int signo, const __sanitizer_sigaction *act, 887 __sanitizer_sigaction *oldact) { 888 ENSURE_MSAN_INITED(); 889 // FIXME: check that *act is unpoisoned. 890 // That requires intercepting all of sigemptyset, sigfillset, etc. 891 int res; 892 if (flags()->wrap_signals) { 893 SpinMutexLock lock(&sigactions_mu); 894 CHECK_LT(signo, kMaxSignals); 895 uptr old_cb = sigactions[signo]; 896 __sanitizer_sigaction new_act; 897 __sanitizer_sigaction *pnew_act = act ? &new_act : 0; 898 if (act) { 899 internal_memcpy(pnew_act, act, __sanitizer::struct_sigaction_sz); 900 uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(pnew_act); 901 uptr new_cb = 902 __sanitizer::__sanitizer_get_sigaction_sa_siginfo(pnew_act) ? 903 (uptr)SignalAction : (uptr)SignalHandler; 904 if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) { 905 sigactions[signo] = cb; 906 __sanitizer::__sanitizer_set_sigaction_sa_sigaction(pnew_act, new_cb); 907 } 908 } 909 res = REAL(sigaction)(signo, pnew_act, oldact); 910 if (res == 0 && oldact) { 911 uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(oldact); 912 if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) { 913 __sanitizer::__sanitizer_set_sigaction_sa_sigaction(oldact, old_cb); 914 } 915 } 916 } else { 917 res = REAL(sigaction)(signo, act, oldact); 918 } 919 920 if (res == 0 && oldact) { 921 __msan_unpoison(oldact, __sanitizer::struct_sigaction_sz); 922 } 923 return res; 924} 925 926INTERCEPTOR(int, signal, int signo, uptr cb) { 927 ENSURE_MSAN_INITED(); 928 if (flags()->wrap_signals) { 929 CHECK_LT(signo, kMaxSignals); 930 SpinMutexLock lock(&sigactions_mu); 931 if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) { 932 sigactions[signo] = cb; 933 cb = (uptr) SignalHandler; 934 } 935 return REAL(signal)(signo, cb); 936 } else { 937 return REAL(signal)(signo, cb); 938 } 939} 940 941extern "C" int pthread_attr_init(void *attr); 942extern "C" int pthread_attr_destroy(void *attr); 943extern "C" int pthread_attr_setstacksize(void *attr, uptr stacksize); 944extern "C" int pthread_attr_getstack(void *attr, uptr *stack, uptr *stacksize); 945 946INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*), 947 void * param) { 948 ENSURE_MSAN_INITED(); // for GetTlsSize() 949 __sanitizer_pthread_attr_t myattr; 950 if (attr == 0) { 951 pthread_attr_init(&myattr); 952 attr = &myattr; 953 } 954 955 AdjustStackSizeLinux(attr, flags()->verbosity); 956 957 int res = REAL(pthread_create)(th, attr, callback, param); 958 if (attr == &myattr) 959 pthread_attr_destroy(&myattr); 960 if (!res) { 961 __msan_unpoison(th, __sanitizer::pthread_t_sz); 962 } 963 return res; 964} 965 966struct MSanInterceptorContext { 967 bool in_interceptor_scope; 968}; 969 970// A version of CHECK_UNPOISED using a saved scope value. Used in common 971// interceptors. 972#define CHECK_UNPOISONED_CTX(ctx, x, n) \ 973 if (!((MSanInterceptorContext *) ctx)->in_interceptor_scope) \ 974 CHECK_UNPOISONED_0(x, n); 975 976#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \ 977 __msan_unpoison(ptr, size) 978#define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \ 979 CHECK_UNPOISONED_CTX(ctx, ptr, size); 980#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \ 981 if (msan_init_is_running) return REAL(func)(__VA_ARGS__); \ 982 MSanInterceptorContext msan_ctx = {IsInInterceptorScope()}; \ 983 ctx = (void *)&msan_ctx; \ 984 InterceptorScope interceptor_scope; \ 985 ENSURE_MSAN_INITED(); 986#define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \ 987 do { \ 988 } while (false) 989#define COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd) \ 990 do { \ 991 } while (false) 992#define COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, newfd) \ 993 do { \ 994 } while (false) 995#define COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, name) \ 996 do { \ 997 } while (false) // FIXME 998#include "sanitizer_common/sanitizer_common_interceptors.inc" 999 1000#define COMMON_SYSCALL_PRE_READ_RANGE(p, s) CHECK_UNPOISONED(p, s) 1001#define COMMON_SYSCALL_PRE_WRITE_RANGE(p, s) 1002#define COMMON_SYSCALL_POST_READ_RANGE(p, s) 1003#define COMMON_SYSCALL_POST_WRITE_RANGE(p, s) __msan_unpoison(p, s) 1004#include "sanitizer_common/sanitizer_common_syscalls.inc" 1005 1006// static 1007void *fast_memset(void *ptr, int c, SIZE_T n) { 1008 // hack until we have a really fast internal_memset 1009 if (sizeof(uptr) == 8 && 1010 (n % 8) == 0 && 1011 ((uptr)ptr % 8) == 0 && 1012 (c == 0 || c == -1)) { 1013 // Printf("memset %p %zd %x\n", ptr, n, c); 1014 uptr to_store = c ? -1L : 0L; 1015 uptr *p = (uptr*)ptr; 1016 for (SIZE_T i = 0; i < n / 8; i++) 1017 p[i] = to_store; 1018 return ptr; 1019 } 1020 return internal_memset(ptr, c, n); 1021} 1022 1023// static 1024void *fast_memcpy(void *dst, const void *src, SIZE_T n) { 1025 // Same hack as in fast_memset above. 1026 if (sizeof(uptr) == 8 && 1027 (n % 8) == 0 && 1028 ((uptr)dst % 8) == 0 && 1029 ((uptr)src % 8) == 0) { 1030 uptr *d = (uptr*)dst; 1031 uptr *s = (uptr*)src; 1032 for (SIZE_T i = 0; i < n / 8; i++) 1033 d[i] = s[i]; 1034 return dst; 1035 } 1036 return internal_memcpy(dst, src, n); 1037} 1038 1039// These interface functions reside here so that they can use 1040// fast_memset, etc. 1041void __msan_unpoison(const void *a, uptr size) { 1042 if (!MEM_IS_APP(a)) return; 1043 fast_memset((void*)MEM_TO_SHADOW((uptr)a), 0, size); 1044} 1045 1046void __msan_poison(const void *a, uptr size) { 1047 if (!MEM_IS_APP(a)) return; 1048 fast_memset((void*)MEM_TO_SHADOW((uptr)a), 1049 __msan::flags()->poison_heap_with_zeroes ? 0 : -1, size); 1050} 1051 1052void __msan_poison_stack(void *a, uptr size) { 1053 if (!MEM_IS_APP(a)) return; 1054 fast_memset((void*)MEM_TO_SHADOW((uptr)a), 1055 __msan::flags()->poison_stack_with_zeroes ? 0 : -1, size); 1056} 1057 1058void __msan_clear_and_unpoison(void *a, uptr size) { 1059 fast_memset(a, 0, size); 1060 fast_memset((void*)MEM_TO_SHADOW((uptr)a), 0, size); 1061} 1062 1063void __msan_copy_origin(void *dst, const void *src, uptr size) { 1064 if (!__msan_get_track_origins()) return; 1065 if (!MEM_IS_APP(dst) || !MEM_IS_APP(src)) return; 1066 uptr d = MEM_TO_ORIGIN(dst); 1067 uptr s = MEM_TO_ORIGIN(src); 1068 uptr beg = d & ~3UL; // align down. 1069 uptr end = (d + size + 3) & ~3UL; // align up. 1070 s = s & ~3UL; // align down. 1071 fast_memcpy((void*)beg, (void*)s, end - beg); 1072} 1073 1074void __msan_copy_poison(void *dst, const void *src, uptr size) { 1075 if (!MEM_IS_APP(dst)) return; 1076 if (!MEM_IS_APP(src)) return; 1077 fast_memcpy((void*)MEM_TO_SHADOW((uptr)dst), 1078 (void*)MEM_TO_SHADOW((uptr)src), size); 1079 __msan_copy_origin(dst, src, size); 1080} 1081 1082void __msan_move_poison(void *dst, const void *src, uptr size) { 1083 if (!MEM_IS_APP(dst)) return; 1084 if (!MEM_IS_APP(src)) return; 1085 internal_memmove((void*)MEM_TO_SHADOW((uptr)dst), 1086 (void*)MEM_TO_SHADOW((uptr)src), size); 1087 __msan_copy_origin(dst, src, size); 1088} 1089 1090void *__msan_memcpy(void *dest, const void *src, SIZE_T n) { 1091 ENSURE_MSAN_INITED(); 1092 void *res = fast_memcpy(dest, src, n); 1093 __msan_copy_poison(dest, src, n); 1094 return res; 1095} 1096 1097void *__msan_memset(void *s, int c, SIZE_T n) { 1098 ENSURE_MSAN_INITED(); 1099 void *res = fast_memset(s, c, n); 1100 __msan_unpoison(s, n); 1101 return res; 1102} 1103 1104void *__msan_memmove(void *dest, const void *src, SIZE_T n) { 1105 ENSURE_MSAN_INITED(); 1106 void *res = REAL(memmove)(dest, src, n); 1107 __msan_move_poison(dest, src, n); 1108 return res; 1109} 1110 1111namespace __msan { 1112void InitializeInterceptors() { 1113 static int inited = 0; 1114 CHECK_EQ(inited, 0); 1115 SANITIZER_COMMON_INTERCEPTORS_INIT; 1116 1117 INTERCEPT_FUNCTION(mmap); 1118 INTERCEPT_FUNCTION(mmap64); 1119 INTERCEPT_FUNCTION(posix_memalign); 1120 INTERCEPT_FUNCTION(malloc); 1121 INTERCEPT_FUNCTION(calloc); 1122 INTERCEPT_FUNCTION(realloc); 1123 INTERCEPT_FUNCTION(free); 1124 INTERCEPT_FUNCTION(fread); 1125 INTERCEPT_FUNCTION(fread_unlocked); 1126 INTERCEPT_FUNCTION(readlink); 1127 INTERCEPT_FUNCTION(memcpy); 1128 INTERCEPT_FUNCTION(memset); 1129 INTERCEPT_FUNCTION(memmove); 1130 INTERCEPT_FUNCTION(wmemset); 1131 INTERCEPT_FUNCTION(wmemcpy); 1132 INTERCEPT_FUNCTION(wmemmove); 1133 INTERCEPT_FUNCTION(strcpy); // NOLINT 1134 INTERCEPT_FUNCTION(strdup); 1135 INTERCEPT_FUNCTION(__strdup); 1136 INTERCEPT_FUNCTION(strndup); 1137 INTERCEPT_FUNCTION(__strndup); 1138 INTERCEPT_FUNCTION(strncpy); // NOLINT 1139 INTERCEPT_FUNCTION(strlen); 1140 INTERCEPT_FUNCTION(strnlen); 1141 INTERCEPT_FUNCTION(gcvt); 1142 INTERCEPT_FUNCTION(strcat); // NOLINT 1143 INTERCEPT_FUNCTION(strncat); // NOLINT 1144 INTERCEPT_FUNCTION(strtol); 1145 INTERCEPT_FUNCTION(strtoll); 1146 INTERCEPT_FUNCTION(strtoul); 1147 INTERCEPT_FUNCTION(strtoull); 1148 INTERCEPT_FUNCTION(strtod); 1149 INTERCEPT_FUNCTION(strtof); 1150 INTERCEPT_FUNCTION(strtold); 1151 INTERCEPT_FUNCTION(vasprintf); 1152 INTERCEPT_FUNCTION(asprintf); 1153 INTERCEPT_FUNCTION(vsprintf); 1154 INTERCEPT_FUNCTION(vsnprintf); 1155 INTERCEPT_FUNCTION(vswprintf); 1156 INTERCEPT_FUNCTION(sprintf); // NOLINT 1157 INTERCEPT_FUNCTION(snprintf); 1158 INTERCEPT_FUNCTION(swprintf); 1159 INTERCEPT_FUNCTION(strftime); 1160 INTERCEPT_FUNCTION(wcstombs); 1161 INTERCEPT_FUNCTION(mbstowcs); 1162 INTERCEPT_FUNCTION(wcslen); 1163 INTERCEPT_FUNCTION(wcschr); 1164 INTERCEPT_FUNCTION(wcscpy); 1165 INTERCEPT_FUNCTION(wcscmp); 1166 INTERCEPT_FUNCTION(wcstod); 1167 INTERCEPT_FUNCTION(getenv); 1168 INTERCEPT_FUNCTION(gettimeofday); 1169 INTERCEPT_FUNCTION(fcvt); 1170 INTERCEPT_FUNCTION(__fxstat); 1171 INTERCEPT_FUNCTION(__xstat); 1172 INTERCEPT_FUNCTION(__lxstat); 1173 INTERCEPT_FUNCTION(__fxstat64); 1174 INTERCEPT_FUNCTION(__xstat64); 1175 INTERCEPT_FUNCTION(__lxstat64); 1176 INTERCEPT_FUNCTION(pipe); 1177 INTERCEPT_FUNCTION(pipe2); 1178 INTERCEPT_FUNCTION(socketpair); 1179 INTERCEPT_FUNCTION(fgets); 1180 INTERCEPT_FUNCTION(fgets_unlocked); 1181 INTERCEPT_FUNCTION(getcwd); 1182 INTERCEPT_FUNCTION(realpath); 1183 INTERCEPT_FUNCTION(getrlimit); 1184 INTERCEPT_FUNCTION(getrlimit64); 1185 INTERCEPT_FUNCTION(statfs); 1186 INTERCEPT_FUNCTION(fstatfs); 1187 INTERCEPT_FUNCTION(statfs64); 1188 INTERCEPT_FUNCTION(fstatfs64); 1189 INTERCEPT_FUNCTION(uname); 1190 INTERCEPT_FUNCTION(gethostname); 1191 INTERCEPT_FUNCTION(epoll_wait); 1192 INTERCEPT_FUNCTION(epoll_pwait); 1193 INTERCEPT_FUNCTION(recv); 1194 INTERCEPT_FUNCTION(recvfrom); 1195 INTERCEPT_FUNCTION(dladdr); 1196 INTERCEPT_FUNCTION(dlopen); 1197 INTERCEPT_FUNCTION(dl_iterate_phdr); 1198 INTERCEPT_FUNCTION(getrusage); 1199 INTERCEPT_FUNCTION(sigaction); 1200 INTERCEPT_FUNCTION(signal); 1201 INTERCEPT_FUNCTION(pthread_create); 1202 inited = 1; 1203} 1204} // namespace __msan 1205