[PATCH] D18413: [asan] Intercept all Heap* related imports from ucrtbase.dll

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 13:53:31 PDT 2016


rnk created this revision.
rnk added a reviewer: samsonov.
rnk added a subscriber: llvm-commits.

ucrtbase.dll appears to be built with some kind of cross-module
inlining, because there are calls to imported Heap* routines sprinkled
throughout the code. This inlining defeats our attempts to hotpatch
malloc, _malloc_base, and related functions. Failing to intercept an
allocation or deallocation results in a crash when the program attempts
to deallocate or reallocate memory with the wrong allocator.

This change patches the IAT of ucrtbase.dll to replace the addresses of
the imported Heap* functions with implementations provided by ASan.  We
don't globally intercept the win32 Heap* functions because they are
typically used by system DLLs that run before ASan initializes.
Eventually, we may want to intercept them, but for now I think this is
the minimal change that will keep ASan stable.

http://reviews.llvm.org/D18413

Files:
  lib/asan/asan_malloc_win.cc
  lib/interception/interception_win.cc
  lib/interception/interception_win.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18413.51467.patch
Type: text/x-patch
Size: 10256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160323/9532e12e/attachment.bin>


More information about the llvm-commits mailing list