1 //===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines macro telling whether sanitizer tools can/should intercept 10 // given library functions on a given platform. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H 14 #define SANITIZER_PLATFORM_INTERCEPTORS_H 15 16 #include "sanitizer_glibc_version.h" 17 #include "sanitizer_internal_defs.h" 18 #include "sanitizer_platform.h" 19 20 #if SANITIZER_POSIX 21 #define SI_POSIX 1 22 #else 23 #define SI_POSIX 0 24 #endif 25 26 #if !SANITIZER_WINDOWS 27 #define SI_WINDOWS 0 28 #else 29 #define SI_WINDOWS 1 30 #endif 31 32 #if SI_WINDOWS && SI_POSIX 33 #error "Windows is not POSIX!" 34 #endif 35 36 #if SI_POSIX 37 #include "sanitizer_platform_limits_freebsd.h" 38 #include "sanitizer_platform_limits_netbsd.h" 39 #include "sanitizer_platform_limits_posix.h" 40 #include "sanitizer_platform_limits_solaris.h" 41 #endif 42 43 #if SANITIZER_LINUX && !SANITIZER_ANDROID 44 #define SI_LINUX_NOT_ANDROID 1 45 #else 46 #define SI_LINUX_NOT_ANDROID 0 47 #endif 48 49 #if SANITIZER_ANDROID 50 #define SI_ANDROID 1 51 #else 52 #define SI_ANDROID 0 53 #endif 54 55 #if SANITIZER_FREEBSD 56 #define SI_FREEBSD 1 57 #else 58 #define SI_FREEBSD 0 59 #endif 60 61 #if SANITIZER_NETBSD 62 #define SI_NETBSD 1 63 #else 64 #define SI_NETBSD 0 65 #endif 66 67 #if SANITIZER_LINUX 68 #define SI_LINUX 1 69 #else 70 #define SI_LINUX 0 71 #endif 72 73 #if SANITIZER_MAC 74 #define SI_MAC 1 75 #define SI_NOT_MAC 0 76 #else 77 #define SI_MAC 0 78 #define SI_NOT_MAC 1 79 #endif 80 81 #if SANITIZER_IOS 82 #define SI_IOS 1 83 #else 84 #define SI_IOS 0 85 #endif 86 87 #if SANITIZER_IOSSIM 88 #define SI_IOSSIM 1 89 #else 90 #define SI_IOSSIM 0 91 #endif 92 93 #if SANITIZER_WATCHOS 94 #define SI_WATCHOS 1 95 #else 96 #define SI_WATCHOS 0 97 #endif 98 99 #if SANITIZER_TVOS 100 #define SI_TVOS 1 101 #else 102 #define SI_TVOS 0 103 #endif 104 105 #if SANITIZER_FUCHSIA 106 #define SI_NOT_FUCHSIA 0 107 #else 108 #define SI_NOT_FUCHSIA 1 109 #endif 110 111 #if SANITIZER_RTEMS 112 #define SI_NOT_RTEMS 0 113 #else 114 #define SI_NOT_RTEMS 1 115 #endif 116 117 #if SANITIZER_SOLARIS 118 #define SI_SOLARIS 1 119 #else 120 #define SI_SOLARIS 0 121 #endif 122 123 #if SANITIZER_SOLARIS32 124 #define SI_SOLARIS32 1 125 #else 126 #define SI_SOLARIS32 0 127 #endif 128 129 #if SANITIZER_POSIX && !SANITIZER_MAC 130 #define SI_POSIX_NOT_MAC 1 131 #else 132 #define SI_POSIX_NOT_MAC 0 133 #endif 134 135 #if SANITIZER_LINUX && !SANITIZER_FREEBSD 136 #define SI_LINUX_NOT_FREEBSD 1 137 #else 138 #define SI_LINUX_NOT_FREEBSD 0 139 #endif 140 141 #define SANITIZER_INTERCEPT_STRLEN SI_NOT_FUCHSIA 142 #define SANITIZER_INTERCEPT_STRNLEN (SI_NOT_MAC && SI_NOT_FUCHSIA) 143 #define SANITIZER_INTERCEPT_STRCMP SI_NOT_FUCHSIA 144 #define SANITIZER_INTERCEPT_STRSTR SI_NOT_FUCHSIA 145 #define SANITIZER_INTERCEPT_STRCASESTR SI_POSIX 146 #define SANITIZER_INTERCEPT_STRTOK SI_NOT_FUCHSIA 147 #define SANITIZER_INTERCEPT_STRCHR SI_NOT_FUCHSIA 148 #define SANITIZER_INTERCEPT_STRCHRNUL SI_POSIX_NOT_MAC 149 #define SANITIZER_INTERCEPT_STRRCHR SI_NOT_FUCHSIA 150 #define SANITIZER_INTERCEPT_STRSPN SI_NOT_FUCHSIA 151 #define SANITIZER_INTERCEPT_STRPBRK SI_NOT_FUCHSIA 152 #define SANITIZER_INTERCEPT_TEXTDOMAIN SI_LINUX_NOT_ANDROID || SI_SOLARIS 153 #define SANITIZER_INTERCEPT_STRCASECMP SI_POSIX 154 #define SANITIZER_INTERCEPT_MEMSET 1 155 #define SANITIZER_INTERCEPT_MEMMOVE 1 156 #define SANITIZER_INTERCEPT_MEMCPY 1 157 #define SANITIZER_INTERCEPT_MEMCMP SI_NOT_FUCHSIA 158 #define SANITIZER_INTERCEPT_BCMP \ 159 SANITIZER_INTERCEPT_MEMCMP && \ 160 ((SI_POSIX && _GNU_SOURCE) || SI_NETBSD || SI_FREEBSD) 161 #define SANITIZER_INTERCEPT_STRNDUP SI_POSIX 162 #define SANITIZER_INTERCEPT___STRNDUP SI_LINUX_NOT_FREEBSD 163 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ 164 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 165 #define SI_MAC_DEPLOYMENT_BELOW_10_7 1 166 #else 167 #define SI_MAC_DEPLOYMENT_BELOW_10_7 0 168 #endif 169 // memmem on Darwin doesn't exist on 10.6 170 // FIXME: enable memmem on Windows. 171 #define SANITIZER_INTERCEPT_MEMMEM (SI_POSIX && !SI_MAC_DEPLOYMENT_BELOW_10_7) 172 #define SANITIZER_INTERCEPT_MEMCHR SI_NOT_FUCHSIA 173 #define SANITIZER_INTERCEPT_MEMRCHR (SI_FREEBSD || SI_LINUX || SI_NETBSD) 174 175 #define SANITIZER_INTERCEPT_READ SI_POSIX 176 #define SANITIZER_INTERCEPT_PREAD SI_POSIX 177 #define SANITIZER_INTERCEPT_WRITE SI_POSIX 178 #define SANITIZER_INTERCEPT_PWRITE SI_POSIX 179 180 #define SANITIZER_INTERCEPT_FREAD SI_POSIX 181 #define SANITIZER_INTERCEPT_FWRITE SI_POSIX 182 #define SANITIZER_INTERCEPT_FGETS SI_POSIX 183 #define SANITIZER_INTERCEPT_FPUTS SI_POSIX 184 #define SANITIZER_INTERCEPT_PUTS SI_POSIX 185 186 #define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32 187 #define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32 188 189 #define SANITIZER_INTERCEPT_READV SI_POSIX 190 #define SANITIZER_INTERCEPT_WRITEV SI_POSIX 191 192 #define SANITIZER_INTERCEPT_PREADV \ 193 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID) 194 #define SANITIZER_INTERCEPT_PWRITEV SI_LINUX_NOT_ANDROID 195 #define SANITIZER_INTERCEPT_PREADV64 SI_LINUX_NOT_ANDROID 196 #define SANITIZER_INTERCEPT_PWRITEV64 SI_LINUX_NOT_ANDROID 197 198 #define SANITIZER_INTERCEPT_PRCTL SI_LINUX 199 200 #define SANITIZER_INTERCEPT_LOCALTIME_AND_FRIENDS SI_POSIX 201 #define SANITIZER_INTERCEPT_STRPTIME SI_POSIX 202 203 #define SANITIZER_INTERCEPT_SCANF SI_POSIX 204 #define SANITIZER_INTERCEPT_ISOC99_SCANF SI_LINUX_NOT_ANDROID 205 206 #ifndef SANITIZER_INTERCEPT_PRINTF 207 #define SANITIZER_INTERCEPT_PRINTF SI_POSIX 208 #define SANITIZER_INTERCEPT_PRINTF_L (SI_FREEBSD || SI_NETBSD) 209 #define SANITIZER_INTERCEPT_ISOC99_PRINTF SI_LINUX_NOT_ANDROID 210 #endif 211 212 #define SANITIZER_INTERCEPT___PRINTF_CHK \ 213 (SANITIZER_INTERCEPT_PRINTF && SI_LINUX_NOT_ANDROID) 214 215 #define SANITIZER_INTERCEPT_FREXP SI_NOT_FUCHSIA 216 #define SANITIZER_INTERCEPT_FREXPF_FREXPL SI_POSIX 217 218 #define SANITIZER_INTERCEPT_GETPWNAM_AND_FRIENDS SI_POSIX 219 #define SANITIZER_INTERCEPT_GETPWNAM_R_AND_FRIENDS \ 220 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 221 #define SANITIZER_INTERCEPT_GETPWENT \ 222 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 223 #define SANITIZER_INTERCEPT_FGETGRENT_R \ 224 (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 225 #define SANITIZER_INTERCEPT_FGETPWENT SI_LINUX_NOT_ANDROID || SI_SOLARIS 226 #define SANITIZER_INTERCEPT_GETPWENT_R \ 227 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 228 #define SANITIZER_INTERCEPT_FGETPWENT_R \ 229 (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 230 #define SANITIZER_INTERCEPT_SETPWENT \ 231 (SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 232 #define SANITIZER_INTERCEPT_CLOCK_GETTIME \ 233 (SI_FREEBSD || SI_NETBSD || SI_LINUX || SI_SOLARIS) 234 #define SANITIZER_INTERCEPT_CLOCK_GETCPUCLOCKID SI_LINUX 235 #define SANITIZER_INTERCEPT_GETITIMER SI_POSIX 236 #define SANITIZER_INTERCEPT_TIME SI_POSIX 237 #define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID || SI_SOLARIS 238 #define SANITIZER_INTERCEPT_GLOB64 SI_LINUX_NOT_ANDROID 239 #define SANITIZER_INTERCEPT_WAIT SI_POSIX 240 #define SANITIZER_INTERCEPT_INET SI_POSIX 241 #define SANITIZER_INTERCEPT_PTHREAD_GETSCHEDPARAM SI_POSIX 242 #define SANITIZER_INTERCEPT_GETADDRINFO SI_POSIX 243 #define SANITIZER_INTERCEPT_GETNAMEINFO SI_POSIX 244 #define SANITIZER_INTERCEPT_GETSOCKNAME SI_POSIX 245 #define SANITIZER_INTERCEPT_GETHOSTBYNAME SI_POSIX 246 #define SANITIZER_INTERCEPT_GETHOSTBYNAME2 SI_POSIX && !SI_SOLARIS 247 #define SANITIZER_INTERCEPT_GETHOSTBYNAME_R \ 248 (SI_FREEBSD || SI_LINUX || SI_SOLARIS) 249 #define SANITIZER_INTERCEPT_GETHOSTBYNAME2_R \ 250 (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 251 #define SANITIZER_INTERCEPT_GETHOSTBYADDR_R \ 252 (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 253 #define SANITIZER_INTERCEPT_GETHOSTENT_R \ 254 (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 255 #define SANITIZER_INTERCEPT_GETSOCKOPT SI_POSIX 256 #define SANITIZER_INTERCEPT_ACCEPT SI_POSIX 257 #define SANITIZER_INTERCEPT_ACCEPT4 (SI_LINUX_NOT_ANDROID || SI_NETBSD) 258 #define SANITIZER_INTERCEPT_PACCEPT SI_NETBSD 259 #define SANITIZER_INTERCEPT_MODF SI_POSIX 260 #define SANITIZER_INTERCEPT_RECVMSG SI_POSIX 261 #define SANITIZER_INTERCEPT_SENDMSG SI_POSIX 262 #define SANITIZER_INTERCEPT_RECVMMSG SI_LINUX 263 #define SANITIZER_INTERCEPT_SENDMMSG SI_LINUX 264 #define SANITIZER_INTERCEPT_SYSMSG SI_LINUX_NOT_ANDROID 265 #define SANITIZER_INTERCEPT_GETPEERNAME SI_POSIX 266 #define SANITIZER_INTERCEPT_IOCTL SI_POSIX 267 #define SANITIZER_INTERCEPT_INET_ATON SI_POSIX 268 #define SANITIZER_INTERCEPT_SYSINFO SI_LINUX 269 #define SANITIZER_INTERCEPT_READDIR SI_POSIX 270 #define SANITIZER_INTERCEPT_READDIR64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32 271 #if SI_LINUX_NOT_ANDROID && \ 272 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \ 273 defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \ 274 defined(__s390__) || SANITIZER_RISCV64) 275 #define SANITIZER_INTERCEPT_PTRACE 1 276 #else 277 #define SANITIZER_INTERCEPT_PTRACE 0 278 #endif 279 #define SANITIZER_INTERCEPT_SETLOCALE SI_POSIX 280 #define SANITIZER_INTERCEPT_GETCWD SI_POSIX 281 #define SANITIZER_INTERCEPT_GET_CURRENT_DIR_NAME SI_LINUX_NOT_ANDROID 282 #define SANITIZER_INTERCEPT_STRTOIMAX SI_POSIX 283 #define SANITIZER_INTERCEPT_MBSTOWCS SI_POSIX 284 #define SANITIZER_INTERCEPT_MBSNRTOWCS \ 285 (SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 286 #define SANITIZER_INTERCEPT_WCSTOMBS SI_POSIX 287 #define SANITIZER_INTERCEPT_STRXFRM SI_POSIX 288 #define SANITIZER_INTERCEPT___STRXFRM_L SI_LINUX 289 #define SANITIZER_INTERCEPT_WCSXFRM SI_POSIX 290 #define SANITIZER_INTERCEPT___WCSXFRM_L SI_LINUX 291 #define SANITIZER_INTERCEPT_WCSNRTOMBS \ 292 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 293 #define SANITIZER_INTERCEPT_WCRTOMB \ 294 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 295 #define SANITIZER_INTERCEPT_WCTOMB \ 296 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 297 #define SANITIZER_INTERCEPT_TCGETATTR SI_LINUX_NOT_ANDROID || SI_SOLARIS 298 #define SANITIZER_INTERCEPT_REALPATH SI_POSIX 299 #define SANITIZER_INTERCEPT_CANONICALIZE_FILE_NAME \ 300 (SI_LINUX_NOT_ANDROID || SI_SOLARIS) 301 #define SANITIZER_INTERCEPT_CONFSTR \ 302 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 303 #define SANITIZER_INTERCEPT_SCHED_GETAFFINITY SI_LINUX_NOT_ANDROID 304 #define SANITIZER_INTERCEPT_SCHED_GETPARAM SI_LINUX_NOT_ANDROID || SI_SOLARIS 305 #define SANITIZER_INTERCEPT_STRERROR SI_POSIX 306 #define SANITIZER_INTERCEPT_STRERROR_R SI_POSIX 307 #define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID 308 #define SANITIZER_INTERCEPT_SCANDIR \ 309 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 310 #define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32 311 #define SANITIZER_INTERCEPT_GETGROUPS SI_POSIX 312 #define SANITIZER_INTERCEPT_POLL SI_POSIX 313 #define SANITIZER_INTERCEPT_PPOLL SI_LINUX_NOT_ANDROID || SI_SOLARIS 314 #define SANITIZER_INTERCEPT_WORDEXP \ 315 (SI_FREEBSD || SI_NETBSD || (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID || \ 316 SI_SOLARIS) // NOLINT 317 #define SANITIZER_INTERCEPT_SIGWAIT SI_POSIX 318 #define SANITIZER_INTERCEPT_SIGWAITINFO SI_LINUX_NOT_ANDROID || SI_SOLARIS 319 #define SANITIZER_INTERCEPT_SIGTIMEDWAIT SI_LINUX_NOT_ANDROID || SI_SOLARIS 320 #define SANITIZER_INTERCEPT_SIGSETOPS \ 321 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 322 #define SANITIZER_INTERCEPT_SIGSET_LOGICOPS SI_LINUX_NOT_ANDROID 323 #define SANITIZER_INTERCEPT_SIGPENDING SI_POSIX 324 #define SANITIZER_INTERCEPT_SIGPROCMASK SI_POSIX 325 #define SANITIZER_INTERCEPT_PTHREAD_SIGMASK SI_POSIX 326 #define SANITIZER_INTERCEPT_BACKTRACE \ 327 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 328 #define SANITIZER_INTERCEPT_GETMNTENT SI_LINUX 329 #define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID 330 #define SANITIZER_INTERCEPT_STATFS \ 331 (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 332 #define SANITIZER_INTERCEPT_STATFS64 \ 333 (((SI_MAC && !TARGET_CPU_ARM64) && !SI_IOS) || SI_LINUX_NOT_ANDROID) 334 #define SANITIZER_INTERCEPT_STATVFS \ 335 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID) 336 #define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID 337 #define SANITIZER_INTERCEPT_INITGROUPS SI_POSIX 338 #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_POSIX 339 #define SANITIZER_INTERCEPT_ETHER_HOST \ 340 (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID) 341 #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) 342 #define SANITIZER_INTERCEPT_SHMCTL \ 343 (((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64) || \ 344 SI_NETBSD || SI_SOLARIS) // NOLINT 345 #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 346 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX 347 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \ 348 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 349 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETAFFINITY_NP SI_LINUX_NOT_ANDROID 350 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET_SCHED SI_POSIX 351 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPSHARED \ 352 (SI_POSIX && !SI_NETBSD) 353 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETTYPE SI_POSIX 354 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPROTOCOL \ 355 (SI_MAC || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 356 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPRIOCEILING \ 357 (SI_MAC || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 358 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST \ 359 (SI_LINUX_NOT_ANDROID || SI_SOLARIS) 360 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST_NP SI_LINUX_NOT_ANDROID 361 #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETPSHARED \ 362 (SI_POSIX && !SI_NETBSD) 363 #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETKIND_NP SI_LINUX_NOT_ANDROID 364 #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETPSHARED (SI_POSIX && !SI_NETBSD) 365 #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETCLOCK \ 366 (SI_LINUX_NOT_ANDROID || SI_SOLARIS) 367 #define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED \ 368 (SI_LINUX_NOT_ANDROID && !SI_NETBSD) 369 #define SANITIZER_INTERCEPT_THR_EXIT SI_FREEBSD 370 #define SANITIZER_INTERCEPT_TMPNAM SI_POSIX 371 #define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID || SI_SOLARIS 372 #define SANITIZER_INTERCEPT_PTSNAME SI_LINUX 373 #define SANITIZER_INTERCEPT_PTSNAME_R SI_LINUX 374 #define SANITIZER_INTERCEPT_TTYNAME SI_POSIX 375 #define SANITIZER_INTERCEPT_TTYNAME_R SI_POSIX 376 #define SANITIZER_INTERCEPT_TEMPNAM SI_POSIX 377 #define SANITIZER_INTERCEPT_SINCOS SI_LINUX || SI_SOLARIS 378 #define SANITIZER_INTERCEPT_REMQUO SI_POSIX 379 #define SANITIZER_INTERCEPT_REMQUOL (SI_POSIX && !SI_NETBSD) 380 #define SANITIZER_INTERCEPT_LGAMMA SI_POSIX 381 #define SANITIZER_INTERCEPT_LGAMMAL (SI_POSIX && !SI_NETBSD) 382 #define SANITIZER_INTERCEPT_LGAMMA_R (SI_FREEBSD || SI_LINUX || SI_SOLARIS) 383 #define SANITIZER_INTERCEPT_LGAMMAL_R SI_LINUX_NOT_ANDROID || SI_SOLARIS 384 #define SANITIZER_INTERCEPT_DRAND48_R SI_LINUX_NOT_ANDROID 385 #define SANITIZER_INTERCEPT_RAND_R \ 386 (SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 387 #define SANITIZER_INTERCEPT_ICONV \ 388 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 389 #define SANITIZER_INTERCEPT_TIMES SI_POSIX 390 391 // FIXME: getline seems to be available on OSX 10.7 392 #define SANITIZER_INTERCEPT_GETLINE \ 393 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 394 395 #define SANITIZER_INTERCEPT__EXIT \ 396 (SI_LINUX || SI_FREEBSD || SI_NETBSD || SI_MAC || SI_SOLARIS) 397 398 #define SANITIZER_INTERCEPT_PTHREAD_MUTEX SI_POSIX 399 #define SANITIZER_INTERCEPT___PTHREAD_MUTEX SI_LINUX_NOT_ANDROID 400 #define SANITIZER_INTERCEPT___LIBC_MUTEX SI_NETBSD 401 #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \ 402 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 403 #define SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP \ 404 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 405 406 #define SANITIZER_INTERCEPT_TLS_GET_ADDR \ 407 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) 408 409 #define SANITIZER_INTERCEPT_LISTXATTR SI_LINUX 410 #define SANITIZER_INTERCEPT_GETXATTR SI_LINUX 411 #define SANITIZER_INTERCEPT_GETRESID SI_LINUX 412 #define SANITIZER_INTERCEPT_GETIFADDRS \ 413 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC || SI_SOLARIS) 414 #define SANITIZER_INTERCEPT_IF_INDEXTONAME \ 415 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC || SI_SOLARIS) 416 #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID 417 #if SI_LINUX && defined(__arm__) 418 #define SANITIZER_INTERCEPT_AEABI_MEM 1 419 #else 420 #define SANITIZER_INTERCEPT_AEABI_MEM 0 421 #endif 422 #define SANITIZER_INTERCEPT___BZERO SI_MAC || SI_LINUX_NOT_ANDROID 423 #define SANITIZER_INTERCEPT_BZERO SI_LINUX_NOT_ANDROID 424 #define SANITIZER_INTERCEPT_FTIME (!SI_FREEBSD && !SI_NETBSD && SI_POSIX) 425 #define SANITIZER_INTERCEPT_XDR SI_LINUX_NOT_ANDROID || SI_SOLARIS 426 #define SANITIZER_INTERCEPT_XDRREC SI_LINUX_NOT_ANDROID 427 #define SANITIZER_INTERCEPT_TSEARCH \ 428 (SI_LINUX_NOT_ANDROID || SI_MAC || SI_NETBSD || SI_SOLARIS) 429 #define SANITIZER_INTERCEPT_LIBIO_INTERNALS SI_LINUX_NOT_ANDROID 430 #define SANITIZER_INTERCEPT_FOPEN SI_POSIX 431 #define SANITIZER_INTERCEPT_FOPEN64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32 432 #define SANITIZER_INTERCEPT_OPEN_MEMSTREAM \ 433 (SI_LINUX_NOT_ANDROID || SI_NETBSD || SI_SOLARIS) 434 #define SANITIZER_INTERCEPT_OBSTACK SI_LINUX_NOT_ANDROID 435 #define SANITIZER_INTERCEPT_FFLUSH SI_POSIX 436 #define SANITIZER_INTERCEPT_FCLOSE SI_POSIX 437 438 #ifndef SANITIZER_INTERCEPT_DLOPEN_DLCLOSE 439 #define SANITIZER_INTERCEPT_DLOPEN_DLCLOSE \ 440 (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC || SI_SOLARIS) 441 #endif 442 443 #define SANITIZER_INTERCEPT_GETPASS \ 444 (SI_LINUX_NOT_ANDROID || SI_MAC || SI_NETBSD) 445 #define SANITIZER_INTERCEPT_TIMERFD SI_LINUX_NOT_ANDROID 446 447 #define SANITIZER_INTERCEPT_MLOCKX SI_POSIX 448 #define SANITIZER_INTERCEPT_FOPENCOOKIE SI_LINUX_NOT_ANDROID 449 #define SANITIZER_INTERCEPT_SEM \ 450 (SI_LINUX || SI_FREEBSD || SI_NETBSD || SI_SOLARIS) 451 #define SANITIZER_INTERCEPT_PTHREAD_SETCANCEL SI_POSIX 452 #define SANITIZER_INTERCEPT_MINCORE (SI_LINUX || SI_NETBSD || SI_SOLARIS) 453 #define SANITIZER_INTERCEPT_PROCESS_VM_READV SI_LINUX 454 #define SANITIZER_INTERCEPT_CTERMID \ 455 (SI_LINUX || SI_MAC || SI_FREEBSD || SI_NETBSD || SI_SOLARIS) 456 #define SANITIZER_INTERCEPT_CTERMID_R (SI_MAC || SI_FREEBSD || SI_SOLARIS) 457 458 #define SANITIZER_INTERCEPTOR_HOOKS \ 459 (SI_LINUX || SI_MAC || SI_WINDOWS || SI_NETBSD || SI_SOLARIS) 460 #define SANITIZER_INTERCEPT_RECV_RECVFROM SI_POSIX 461 #define SANITIZER_INTERCEPT_SEND_SENDTO SI_POSIX 462 #define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX 463 464 #define SANITIZER_INTERCEPT_STAT \ 465 (SI_FREEBSD || SI_MAC || SI_ANDROID || SI_NETBSD || SI_SOLARIS) 466 #define SANITIZER_INTERCEPT_LSTAT (SI_NETBSD || SI_FREEBSD) 467 #define SANITIZER_INTERCEPT___XSTAT (!SANITIZER_INTERCEPT_STAT && SI_POSIX) 468 #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID 469 #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT 470 #define SANITIZER_INTERCEPT___LXSTAT64 SI_LINUX_NOT_ANDROID 471 472 #define SANITIZER_INTERCEPT_UTMP \ 473 (SI_POSIX && !SI_MAC && !SI_FREEBSD && !SI_NETBSD) 474 #define SANITIZER_INTERCEPT_UTMPX \ 475 (SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD || SI_NETBSD) 476 477 #define SANITIZER_INTERCEPT_GETLOADAVG \ 478 (SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD || SI_NETBSD) 479 480 #define SANITIZER_INTERCEPT_MMAP SI_POSIX 481 #define SANITIZER_INTERCEPT_MMAP64 SI_LINUX_NOT_ANDROID 482 #define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO \ 483 (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \ 484 !SI_SOLARIS) // NOLINT 485 #define SANITIZER_INTERCEPT_MEMALIGN \ 486 (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_RTEMS) 487 #define SANITIZER_INTERCEPT___LIBC_MEMALIGN \ 488 (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && !SI_OPENBSD && SI_NOT_RTEMS && \ 489 !SI_ANDROID) // NOLINT 490 #define SANITIZER_INTERCEPT_PVALLOC \ 491 (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \ 492 !SI_SOLARIS) // NOLINT 493 #define SANITIZER_INTERCEPT_CFREE \ 494 (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \ 495 !SI_SOLARIS && !SANITIZER_ANDROID) // NOLINT 496 #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX 497 #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC && SI_NOT_RTEMS) 498 #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD) 499 #define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID 500 #define SANITIZER_INTERCEPT_WCSCAT SI_POSIX 501 #define SANITIZER_INTERCEPT_WCSDUP SI_POSIX 502 #define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA) 503 #define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID 504 505 #define SANITIZER_INTERCEPT_ACCT (SI_NETBSD || SI_FREEBSD) 506 #define SANITIZER_INTERCEPT_USER_FROM_UID SI_NETBSD 507 #define SANITIZER_INTERCEPT_UID_FROM_USER SI_NETBSD 508 #define SANITIZER_INTERCEPT_GROUP_FROM_GID SI_NETBSD 509 #define SANITIZER_INTERCEPT_GID_FROM_GROUP SI_NETBSD 510 #define SANITIZER_INTERCEPT_ACCESS (SI_NETBSD || SI_FREEBSD) 511 #define SANITIZER_INTERCEPT_FACCESSAT (SI_NETBSD || SI_FREEBSD) 512 #define SANITIZER_INTERCEPT_GETGROUPLIST SI_NETBSD 513 #define SANITIZER_INTERCEPT_STRLCPY \ 514 (SI_NETBSD || SI_FREEBSD || SI_MAC || SI_ANDROID) 515 516 #define SANITIZER_INTERCEPT_NAME_TO_HANDLE_AT SI_LINUX_NOT_ANDROID 517 #define SANITIZER_INTERCEPT_OPEN_BY_HANDLE_AT SI_LINUX_NOT_ANDROID 518 519 #define SANITIZER_INTERCEPT_READLINK SI_POSIX 520 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ 521 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000 522 #define SI_MAC_DEPLOYMENT_BELOW_10_10 1 523 #else 524 #define SI_MAC_DEPLOYMENT_BELOW_10_10 0 525 #endif 526 #define SANITIZER_INTERCEPT_READLINKAT \ 527 (SI_POSIX && !SI_MAC_DEPLOYMENT_BELOW_10_10) 528 529 #define SANITIZER_INTERCEPT_DEVNAME (SI_NETBSD || SI_FREEBSD) 530 #define SANITIZER_INTERCEPT_DEVNAME_R (SI_NETBSD || SI_FREEBSD) 531 #define SANITIZER_INTERCEPT_FGETLN (SI_NETBSD || SI_FREEBSD) 532 #define SANITIZER_INTERCEPT_STRMODE (SI_NETBSD || SI_FREEBSD) 533 #define SANITIZER_INTERCEPT_TTYENT SI_NETBSD 534 #define SANITIZER_INTERCEPT_PROTOENT (SI_NETBSD || SI_LINUX) 535 #define SANITIZER_INTERCEPT_PROTOENT_R (SI_LINUX_NOT_ANDROID) 536 #define SANITIZER_INTERCEPT_NETENT SI_NETBSD 537 #define SANITIZER_INTERCEPT_SETVBUF \ 538 (SI_NETBSD || SI_FREEBSD || SI_LINUX || SI_MAC) 539 #define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD || SI_MAC) 540 #define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD 541 #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD 542 #define SANITIZER_INTERCEPT_REGEX (SI_NETBSD || SI_FREEBSD || SI_LINUX) 543 #define SANITIZER_INTERCEPT_REGEXSUB SI_NETBSD 544 #define SANITIZER_INTERCEPT_FTS (SI_NETBSD || SI_FREEBSD) 545 #define SANITIZER_INTERCEPT_SYSCTL (SI_NETBSD || SI_FREEBSD || SI_MAC) 546 #define SANITIZER_INTERCEPT_ASYSCTL SI_NETBSD 547 #define SANITIZER_INTERCEPT_SYSCTLGETMIBINFO SI_NETBSD 548 #define SANITIZER_INTERCEPT_NL_LANGINFO (SI_NETBSD || SI_FREEBSD || SI_MAC) 549 #define SANITIZER_INTERCEPT_MODCTL SI_NETBSD 550 #define SANITIZER_INTERCEPT_CAPSICUM SI_FREEBSD 551 #define SANITIZER_INTERCEPT_STRTONUM (SI_NETBSD || SI_FREEBSD) 552 #define SANITIZER_INTERCEPT_FPARSELN SI_NETBSD 553 #define SANITIZER_INTERCEPT_STATVFS1 SI_NETBSD 554 #define SANITIZER_INTERCEPT_STRTOI SI_NETBSD 555 #define SANITIZER_INTERCEPT_CAPSICUM SI_FREEBSD 556 #define SANITIZER_INTERCEPT_SHA1 SI_NETBSD 557 #define SANITIZER_INTERCEPT_MD4 SI_NETBSD 558 #define SANITIZER_INTERCEPT_RMD160 SI_NETBSD 559 #define SANITIZER_INTERCEPT_MD5 SI_NETBSD 560 #define SANITIZER_INTERCEPT_FSEEK (SI_NETBSD || SI_FREEBSD) 561 #define SANITIZER_INTERCEPT_MD2 SI_NETBSD 562 #define SANITIZER_INTERCEPT_SHA2 SI_NETBSD 563 #define SANITIZER_INTERCEPT_CDB SI_NETBSD 564 #define SANITIZER_INTERCEPT_VIS (SI_NETBSD || SI_FREEBSD) 565 #define SANITIZER_INTERCEPT_POPEN SI_POSIX 566 #define SANITIZER_INTERCEPT_POPENVE SI_NETBSD 567 #define SANITIZER_INTERCEPT_PCLOSE SI_POSIX 568 #define SANITIZER_INTERCEPT_FUNOPEN (SI_NETBSD || SI_FREEBSD) 569 #define SANITIZER_INTERCEPT_FUNOPEN2 SI_NETBSD 570 #define SANITIZER_INTERCEPT_GETFSENT (SI_FREEBSD || SI_NETBSD || SI_MAC) 571 #define SANITIZER_INTERCEPT_ARC4RANDOM (SI_FREEBSD || SI_NETBSD || SI_MAC) 572 #define SANITIZER_INTERCEPT_FDEVNAME SI_FREEBSD 573 #define SANITIZER_INTERCEPT_GETUSERSHELL (SI_POSIX && !SI_ANDROID) 574 #define SANITIZER_INTERCEPT_SL_INIT (SI_FREEBSD || SI_NETBSD) 575 #define SANITIZER_INTERCEPT_CRYPT (SI_POSIX && !SI_ANDROID) 576 #define SANITIZER_INTERCEPT_CRYPT_R (SI_LINUX && !SI_ANDROID) 577 578 #define SANITIZER_INTERCEPT_GETRANDOM \ 579 ((SI_LINUX && __GLIBC_PREREQ(2, 25)) || SI_FREEBSD) 580 #define SANITIZER_INTERCEPT___CXA_ATEXIT SI_NETBSD 581 #define SANITIZER_INTERCEPT_ATEXIT SI_NETBSD 582 #define SANITIZER_INTERCEPT_PTHREAD_ATFORK SI_NETBSD 583 #define SANITIZER_INTERCEPT_GETENTROPY SI_FREEBSD 584 #define SANITIZER_INTERCEPT_QSORT \ 585 (SI_POSIX && !SI_IOSSIM && !SI_WATCHOS && !SI_TVOS && !SI_ANDROID) 586 #define SANITIZER_INTERCEPT_QSORT_R (SI_LINUX && !SI_ANDROID) 587 // sigaltstack on i386 macOS cannot be intercepted due to setjmp() 588 // calling it and assuming that it does not clobber registers. 589 #define SANITIZER_INTERCEPT_SIGALTSTACK \ 590 (SI_POSIX && !(SANITIZER_MAC && SANITIZER_I386)) 591 #define SANITIZER_INTERCEPT_UNAME (SI_POSIX && !SI_FREEBSD) 592 #define SANITIZER_INTERCEPT___XUNAME SI_FREEBSD 593 594 #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H 595