This is an archive of the discontinued LLVM Phabricator instance.

[asan] Avoid hooking memchr() on Windows64
ClosedPublic

Authored by wang0109 on Jul 14 2016, 11:07 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

wang0109 updated this revision to Diff 64010.Jul 14 2016, 11:07 AM
wang0109 retitled this revision from to [asan] Avoid hooking memchr() on Windows64.
wang0109 updated this object.
wang0109 added subscribers: etienneb, chrisha.

This is fine to me.

But, in practice this error will occur again if someone disable an other hook.

#define SANITIZER_INTERCEPT_MEMSET 1
#define SANITIZER_INTERCEPT_MEMMOVE 1
#define SANITIZER_INTERCEPT_MEMCPY 1
#define SANITIZER_INTERCEPT_MEMCMP 1
#define SANITIZER_INTERCEPT_MEMCHR 1

But. we can postpone this fix.

Yes, I think the correct behavior is to let SANITIZER_INTERCEPTER_XXXX macros to control both library and non-library interceptions, meaning, we should surround those interceptions in lib/asan/asan_win_dll_thunk.cc with these macros. That is, another CL, since this one is about memchr() in particular.

rnk accepted this revision.Jul 14 2016, 11:39 AM
rnk added a reviewer: rnk.
rnk added a subscriber: rnk.

lgtm

This revision is now accepted and ready to land.Jul 14 2016, 11:39 AM
This revision was automatically updated to reflect the committed changes.