1 //===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===// 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 defines macro telling whether sanitizer tools can/should intercept 11 // given library functions on a given platform. 12 // 13 //===----------------------------------------------------------------------===// 14 #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H 15 #define SANITIZER_PLATFORM_INTERCEPTORS_H 16 17 #include "sanitizer_internal_defs.h" 18 19 #if !SANITIZER_WINDOWS 20 # define SI_NOT_WINDOWS 1 21 # include "sanitizer_platform_limits_posix.h" 22 #else 23 # define SI_NOT_WINDOWS 0 24 #endif 25 26 #if SANITIZER_LINUX && !SANITIZER_ANDROID 27 # define SI_LINUX_NOT_ANDROID 1 28 #else 29 # define SI_LINUX_NOT_ANDROID 0 30 #endif 31 32 #if SANITIZER_ANDROID 33 # define SI_ANDROID 1 34 #else 35 # define SI_ANDROID 0 36 #endif 37 38 #if SANITIZER_FREEBSD 39 # define SI_FREEBSD 1 40 #else 41 # define SI_FREEBSD 0 42 #endif 43 44 #if SANITIZER_LINUX 45 # define SI_LINUX 1 46 #else 47 # define SI_LINUX 0 48 #endif 49 50 #if SANITIZER_MAC 51 # define SI_MAC 1 52 # define SI_NOT_MAC 0 53 #else 54 # define SI_MAC 0 55 # define SI_NOT_MAC 1 56 #endif 57 58 #if SANITIZER_IOS 59 # define SI_IOS 1 60 #else 61 # define SI_IOS 0 62 #endif 63 64 #if !SANITIZER_WINDOWS && !SANITIZER_MAC 65 # define SI_UNIX_NOT_MAC 1 66 #else 67 # define SI_UNIX_NOT_MAC 0 68 #endif 69 70 #define SANITIZER_INTERCEPT_STRLEN 1 71 #define SANITIZER_INTERCEPT_STRNLEN SI_NOT_MAC 72 #define SANITIZER_INTERCEPT_STRCMP 1 73 #define SANITIZER_INTERCEPT_STRSTR 1 74 #define SANITIZER_INTERCEPT_STRCASESTR SI_NOT_WINDOWS 75 #define SANITIZER_INTERCEPT_STRCHR 1 76 #define SANITIZER_INTERCEPT_STRCHRNUL SI_UNIX_NOT_MAC 77 #define SANITIZER_INTERCEPT_STRRCHR 1 78 #define SANITIZER_INTERCEPT_STRSPN 1 79 #define SANITIZER_INTERCEPT_STRPBRK 1 80 #define SANITIZER_INTERCEPT_TEXTDOMAIN SI_LINUX_NOT_ANDROID 81 #define SANITIZER_INTERCEPT_STRCASECMP SI_NOT_WINDOWS 82 #define SANITIZER_INTERCEPT_MEMSET 1 83 #define SANITIZER_INTERCEPT_MEMMOVE 1 84 #define SANITIZER_INTERCEPT_MEMCPY 1 85 #define SANITIZER_INTERCEPT_MEMCMP 1 86 // TODO(wwchrome): Re-enable intercepting memchr() when ready. 87 // The function memchr() contains a jump in the first 6 bytes 88 // that is problematic to intercept correctly on Win64. 89 // Disable memchr() interception for Win64 temporarily. 90 #if SANITIZER_WINDOWS64 91 #define SANITIZER_INTERCEPT_MEMCHR 0 92 #else 93 #define SANITIZER_INTERCEPT_MEMCHR 1 94 #endif 95 #define SANITIZER_INTERCEPT_MEMRCHR SI_FREEBSD || SI_LINUX 96 97 #define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS 98 #define SANITIZER_INTERCEPT_PREAD SI_NOT_WINDOWS 99 #define SANITIZER_INTERCEPT_WRITE SI_NOT_WINDOWS 100 #define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS 101 102 #define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID 103 #define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID 104 105 #define SANITIZER_INTERCEPT_READV SI_NOT_WINDOWS 106 #define SANITIZER_INTERCEPT_WRITEV SI_NOT_WINDOWS 107 108 #define SANITIZER_INTERCEPT_PREADV SI_FREEBSD || SI_LINUX_NOT_ANDROID 109 #define SANITIZER_INTERCEPT_PWRITEV SI_LINUX_NOT_ANDROID 110 #define SANITIZER_INTERCEPT_PREADV64 SI_LINUX_NOT_ANDROID 111 #define SANITIZER_INTERCEPT_PWRITEV64 SI_LINUX_NOT_ANDROID 112 113 #define SANITIZER_INTERCEPT_PRCTL SI_LINUX 114 115 #define SANITIZER_INTERCEPT_LOCALTIME_AND_FRIENDS SI_NOT_WINDOWS 116 #define SANITIZER_INTERCEPT_STRPTIME SI_NOT_WINDOWS 117 118 #define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS 119 #define SANITIZER_INTERCEPT_ISOC99_SCANF SI_LINUX_NOT_ANDROID 120 121 #ifndef SANITIZER_INTERCEPT_PRINTF 122 # define SANITIZER_INTERCEPT_PRINTF SI_NOT_WINDOWS 123 # define SANITIZER_INTERCEPT_PRINTF_L SI_FREEBSD 124 # define SANITIZER_INTERCEPT_ISOC99_PRINTF SI_LINUX_NOT_ANDROID 125 #endif 126 127 #define SANITIZER_INTERCEPT_FREXP 1 128 #define SANITIZER_INTERCEPT_FREXPF_FREXPL SI_NOT_WINDOWS 129 130 #define SANITIZER_INTERCEPT_GETPWNAM_AND_FRIENDS SI_NOT_WINDOWS 131 #define SANITIZER_INTERCEPT_GETPWNAM_R_AND_FRIENDS \ 132 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 133 #define SANITIZER_INTERCEPT_GETPWENT \ 134 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 135 #define SANITIZER_INTERCEPT_FGETPWENT SI_LINUX_NOT_ANDROID 136 #define SANITIZER_INTERCEPT_GETPWENT_R SI_FREEBSD || SI_LINUX_NOT_ANDROID 137 #define SANITIZER_INTERCEPT_SETPWENT SI_MAC || SI_LINUX_NOT_ANDROID 138 #define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_FREEBSD || SI_LINUX 139 #define SANITIZER_INTERCEPT_GETITIMER SI_NOT_WINDOWS 140 #define SANITIZER_INTERCEPT_TIME SI_NOT_WINDOWS 141 #define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID 142 #define SANITIZER_INTERCEPT_WAIT SI_NOT_WINDOWS 143 #define SANITIZER_INTERCEPT_INET SI_NOT_WINDOWS 144 #define SANITIZER_INTERCEPT_PTHREAD_GETSCHEDPARAM SI_NOT_WINDOWS 145 #define SANITIZER_INTERCEPT_GETADDRINFO SI_NOT_WINDOWS 146 #define SANITIZER_INTERCEPT_GETNAMEINFO SI_NOT_WINDOWS 147 #define SANITIZER_INTERCEPT_GETSOCKNAME SI_NOT_WINDOWS 148 #define SANITIZER_INTERCEPT_GETHOSTBYNAME SI_NOT_WINDOWS 149 #define SANITIZER_INTERCEPT_GETHOSTBYNAME_R SI_FREEBSD || SI_LINUX 150 #define SANITIZER_INTERCEPT_GETHOSTBYNAME2_R SI_FREEBSD || SI_LINUX_NOT_ANDROID 151 #define SANITIZER_INTERCEPT_GETHOSTBYADDR_R SI_FREEBSD || SI_LINUX_NOT_ANDROID 152 #define SANITIZER_INTERCEPT_GETHOSTENT_R SI_FREEBSD || SI_LINUX_NOT_ANDROID 153 #define SANITIZER_INTERCEPT_GETSOCKOPT SI_NOT_WINDOWS 154 #define SANITIZER_INTERCEPT_ACCEPT SI_NOT_WINDOWS 155 #define SANITIZER_INTERCEPT_ACCEPT4 SI_LINUX_NOT_ANDROID 156 #define SANITIZER_INTERCEPT_MODF SI_NOT_WINDOWS 157 #define SANITIZER_INTERCEPT_RECVMSG SI_NOT_WINDOWS 158 #define SANITIZER_INTERCEPT_SENDMSG SI_NOT_WINDOWS 159 #define SANITIZER_INTERCEPT_GETPEERNAME SI_NOT_WINDOWS 160 #define SANITIZER_INTERCEPT_IOCTL SI_NOT_WINDOWS 161 #define SANITIZER_INTERCEPT_INET_ATON SI_NOT_WINDOWS 162 #define SANITIZER_INTERCEPT_SYSINFO SI_LINUX 163 #define SANITIZER_INTERCEPT_READDIR SI_NOT_WINDOWS 164 #define SANITIZER_INTERCEPT_READDIR64 SI_LINUX_NOT_ANDROID 165 #if SI_LINUX_NOT_ANDROID && \ 166 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \ 167 defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \ 168 defined(__s390__)) 169 #define SANITIZER_INTERCEPT_PTRACE 1 170 #else 171 #define SANITIZER_INTERCEPT_PTRACE 0 172 #endif 173 #define SANITIZER_INTERCEPT_SETLOCALE SI_NOT_WINDOWS 174 #define SANITIZER_INTERCEPT_GETCWD SI_NOT_WINDOWS 175 #define SANITIZER_INTERCEPT_GET_CURRENT_DIR_NAME SI_LINUX_NOT_ANDROID 176 #define SANITIZER_INTERCEPT_STRTOIMAX SI_NOT_WINDOWS 177 #define SANITIZER_INTERCEPT_MBSTOWCS SI_NOT_WINDOWS 178 #define SANITIZER_INTERCEPT_MBSNRTOWCS SI_MAC || SI_LINUX_NOT_ANDROID 179 #define SANITIZER_INTERCEPT_WCSTOMBS SI_NOT_WINDOWS 180 #define SANITIZER_INTERCEPT_WCSNRTOMBS \ 181 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 182 #define SANITIZER_INTERCEPT_WCRTOMB \ 183 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 184 #define SANITIZER_INTERCEPT_TCGETATTR SI_LINUX_NOT_ANDROID 185 #define SANITIZER_INTERCEPT_REALPATH SI_NOT_WINDOWS 186 #define SANITIZER_INTERCEPT_CANONICALIZE_FILE_NAME SI_LINUX_NOT_ANDROID 187 #define SANITIZER_INTERCEPT_CONFSTR \ 188 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 189 #define SANITIZER_INTERCEPT_SCHED_GETAFFINITY SI_LINUX_NOT_ANDROID 190 #define SANITIZER_INTERCEPT_SCHED_GETPARAM SI_LINUX_NOT_ANDROID 191 #define SANITIZER_INTERCEPT_STRERROR SI_NOT_WINDOWS 192 #define SANITIZER_INTERCEPT_STRERROR_R SI_NOT_WINDOWS 193 #define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID 194 #define SANITIZER_INTERCEPT_SCANDIR \ 195 SI_FREEBSD || SI_LINUX_NOT_ANDROID 196 #define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID 197 #define SANITIZER_INTERCEPT_GETGROUPS SI_NOT_WINDOWS 198 #define SANITIZER_INTERCEPT_POLL SI_NOT_WINDOWS 199 #define SANITIZER_INTERCEPT_PPOLL SI_LINUX_NOT_ANDROID 200 #define SANITIZER_INTERCEPT_WORDEXP \ 201 SI_FREEBSD || (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID 202 #define SANITIZER_INTERCEPT_SIGWAIT SI_NOT_WINDOWS 203 #define SANITIZER_INTERCEPT_SIGWAITINFO SI_LINUX_NOT_ANDROID 204 #define SANITIZER_INTERCEPT_SIGTIMEDWAIT SI_LINUX_NOT_ANDROID 205 #define SANITIZER_INTERCEPT_SIGSETOPS \ 206 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 207 #define SANITIZER_INTERCEPT_SIGPENDING SI_NOT_WINDOWS 208 #define SANITIZER_INTERCEPT_SIGPROCMASK SI_NOT_WINDOWS 209 #define SANITIZER_INTERCEPT_BACKTRACE SI_FREEBSD || SI_LINUX_NOT_ANDROID 210 #define SANITIZER_INTERCEPT_GETMNTENT SI_LINUX 211 #define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID 212 #define SANITIZER_INTERCEPT_STATFS SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 213 #define SANITIZER_INTERCEPT_STATFS64 \ 214 (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID 215 #define SANITIZER_INTERCEPT_STATVFS SI_FREEBSD || SI_LINUX_NOT_ANDROID 216 #define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID 217 #define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS 218 #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_NOT_WINDOWS 219 #define SANITIZER_INTERCEPT_ETHER_HOST \ 220 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 221 #define SANITIZER_INTERCEPT_ETHER_R SI_FREEBSD || SI_LINUX_NOT_ANDROID 222 #define SANITIZER_INTERCEPT_SHMCTL \ 223 ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64) 224 #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID 225 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_NOT_WINDOWS 226 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \ 227 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 228 #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETAFFINITY_NP SI_LINUX_NOT_ANDROID 229 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPSHARED SI_NOT_WINDOWS 230 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETTYPE SI_NOT_WINDOWS 231 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPROTOCOL \ 232 SI_MAC || SI_LINUX_NOT_ANDROID 233 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPRIOCEILING \ 234 SI_MAC || SI_LINUX_NOT_ANDROID 235 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST SI_LINUX_NOT_ANDROID 236 #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST_NP SI_LINUX_NOT_ANDROID 237 #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETPSHARED SI_NOT_WINDOWS 238 #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETKIND_NP SI_LINUX_NOT_ANDROID 239 #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETPSHARED SI_NOT_WINDOWS 240 #define SANITIZER_INTERCEPT_PTHREAD_CONDATTR_GETCLOCK SI_LINUX_NOT_ANDROID 241 #define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED SI_LINUX_NOT_ANDROID 242 #define SANITIZER_INTERCEPT_TMPNAM SI_NOT_WINDOWS 243 #define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID 244 #define SANITIZER_INTERCEPT_TEMPNAM SI_NOT_WINDOWS 245 #define SANITIZER_INTERCEPT_SINCOS SI_LINUX 246 #define SANITIZER_INTERCEPT_REMQUO SI_NOT_WINDOWS 247 #define SANITIZER_INTERCEPT_LGAMMA SI_NOT_WINDOWS 248 #define SANITIZER_INTERCEPT_LGAMMA_R SI_FREEBSD || SI_LINUX 249 #define SANITIZER_INTERCEPT_LGAMMAL_R SI_LINUX_NOT_ANDROID 250 #define SANITIZER_INTERCEPT_DRAND48_R SI_LINUX_NOT_ANDROID 251 #define SANITIZER_INTERCEPT_RAND_R \ 252 SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID 253 #define SANITIZER_INTERCEPT_ICONV SI_FREEBSD || SI_LINUX_NOT_ANDROID 254 #define SANITIZER_INTERCEPT_TIMES SI_NOT_WINDOWS 255 256 // FIXME: getline seems to be available on OSX 10.7 257 #define SANITIZER_INTERCEPT_GETLINE SI_FREEBSD || SI_LINUX_NOT_ANDROID 258 259 #define SANITIZER_INTERCEPT__EXIT SI_LINUX || SI_FREEBSD || SI_MAC 260 261 #define SANITIZER_INTERCEPT_PHTREAD_MUTEX SI_NOT_WINDOWS 262 #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \ 263 SI_FREEBSD || SI_LINUX_NOT_ANDROID 264 265 #define SANITIZER_INTERCEPT_TLS_GET_ADDR \ 266 SI_FREEBSD || SI_LINUX_NOT_ANDROID 267 268 #define SANITIZER_INTERCEPT_LISTXATTR SI_LINUX 269 #define SANITIZER_INTERCEPT_GETXATTR SI_LINUX 270 #define SANITIZER_INTERCEPT_GETRESID SI_LINUX 271 #define SANITIZER_INTERCEPT_GETIFADDRS \ 272 SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC 273 #define SANITIZER_INTERCEPT_IF_INDEXTONAME \ 274 SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC 275 #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID 276 #if SI_LINUX && defined(__arm__) 277 #define SANITIZER_INTERCEPT_AEABI_MEM 1 278 #else 279 #define SANITIZER_INTERCEPT_AEABI_MEM 0 280 #endif 281 #define SANITIZER_INTERCEPT___BZERO SI_MAC 282 #define SANITIZER_INTERCEPT_FTIME !SI_FREEBSD && SI_NOT_WINDOWS 283 #define SANITIZER_INTERCEPT_XDR SI_LINUX_NOT_ANDROID 284 #define SANITIZER_INTERCEPT_TSEARCH SI_LINUX_NOT_ANDROID || SI_MAC 285 #define SANITIZER_INTERCEPT_LIBIO_INTERNALS SI_LINUX_NOT_ANDROID 286 #define SANITIZER_INTERCEPT_FOPEN SI_NOT_WINDOWS 287 #define SANITIZER_INTERCEPT_FOPEN64 SI_LINUX_NOT_ANDROID 288 #define SANITIZER_INTERCEPT_OPEN_MEMSTREAM SI_LINUX_NOT_ANDROID 289 #define SANITIZER_INTERCEPT_OBSTACK SI_LINUX_NOT_ANDROID 290 #define SANITIZER_INTERCEPT_FFLUSH SI_NOT_WINDOWS 291 #define SANITIZER_INTERCEPT_FCLOSE SI_NOT_WINDOWS 292 293 #ifndef SANITIZER_INTERCEPT_DLOPEN_DLCLOSE 294 #define SANITIZER_INTERCEPT_DLOPEN_DLCLOSE \ 295 SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC 296 #endif 297 298 #define SANITIZER_INTERCEPT_GETPASS SI_LINUX_NOT_ANDROID || SI_MAC 299 #define SANITIZER_INTERCEPT_TIMERFD SI_LINUX_NOT_ANDROID 300 301 #define SANITIZER_INTERCEPT_MLOCKX SI_NOT_WINDOWS 302 #define SANITIZER_INTERCEPT_FOPENCOOKIE SI_LINUX_NOT_ANDROID 303 #define SANITIZER_INTERCEPT_SEM SI_LINUX || SI_FREEBSD 304 #define SANITIZER_INTERCEPT_PTHREAD_SETCANCEL SI_NOT_WINDOWS 305 #define SANITIZER_INTERCEPT_MINCORE SI_LINUX 306 #define SANITIZER_INTERCEPT_PROCESS_VM_READV SI_LINUX 307 #define SANITIZER_INTERCEPT_CTERMID SI_LINUX || SI_MAC || SI_FREEBSD 308 #define SANITIZER_INTERCEPT_CTERMID_R SI_MAC || SI_FREEBSD 309 310 #define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX 311 #define SANITIZER_INTERCEPT_RECV_RECVFROM SI_NOT_WINDOWS 312 #define SANITIZER_INTERCEPT_SEND_SENDTO SI_NOT_WINDOWS 313 #define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX 314 315 #define SANITIZER_INTERCEPT_STAT (SI_FREEBSD || SI_MAC || SI_ANDROID) 316 #define SANITIZER_INTERCEPT___XSTAT !SANITIZER_INTERCEPT_STAT && SI_NOT_WINDOWS 317 #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID 318 #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT 319 #define SANITIZER_INTERCEPT___LXSTAT64 SI_LINUX_NOT_ANDROID 320 #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H 321