Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 48ccea3

Browse files
committed
[asan] Avoid hooking memchr() on Windows64
There is not enough padding in front of memchr(), and, the first 6 bytes contains a branch instruction. Basically the current interception will not work on memchr(). It was disabled before, but was missing the part to disable it for INTERCEPT_LIBRARY_FUNCTION. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22371 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275494 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 552ecd1 commit 48ccea3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/asan/asan_win_dll_thunk.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifdef ASAN_DLL_THUNK
2222
#include "asan_init_version.h"
2323
#include "interception/interception.h"
24+
#include "sanitizer_common/sanitizer_platform_interceptors.h"
2425

2526
// ---------- Function interception helper functions and macros ----------- {{{1
2627
extern "C" {
@@ -390,7 +391,9 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
390391

391392
INTERCEPT_LIBRARY_FUNCTION(frexp);
392393
INTERCEPT_LIBRARY_FUNCTION(longjmp);
394+
#if SANITIZER_INTERCEPT_MEMCHR
393395
INTERCEPT_LIBRARY_FUNCTION(memchr);
396+
#endif
394397
INTERCEPT_LIBRARY_FUNCTION(memcmp);
395398
INTERCEPT_LIBRARY_FUNCTION(memcpy);
396399
INTERCEPT_LIBRARY_FUNCTION(memmove);

lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@
8383
#define SANITIZER_INTERCEPT_MEMMOVE 1
8484
#define SANITIZER_INTERCEPT_MEMCPY 1
8585
#define SANITIZER_INTERCEPT_MEMCMP 1
86-
// TODO(wwchrome): Re-enable intercepting memchr() when ready.
8786
// The function memchr() contains a jump in the first 6 bytes
8887
// that is problematic to intercept correctly on Win64.
89-
// Disable memchr() interception for Win64 temporarily.
88+
// Disable memchr() interception for Win64.
9089
#if SANITIZER_WINDOWS64
9190
#define SANITIZER_INTERCEPT_MEMCHR 0
9291
#else

0 commit comments

Comments
 (0)