[PATCH] Implement variable-sized alloca instrumentation (take 2).

Maxim Ostapenko m.ostapenko at partner.samsung.com
Mon Apr 6 10:49:30 PDT 2015


Hi!
I'm sorry for delay.
Here are some approaches we can follow for dynamic allocas:

1. We can instrument all allocas with runtime call for both UAR/non-UARcases (for non-UAR we'll just perform poisoning, for UAR allocate allocas using fake stacks). But this will lead to complex logic into unpoisoning functionality, since allocated memory chunks for UAR will not be consecutive.
2. We probably can allocate single memory chunk for dynamic stack area via asan_stack_malloc similarly to static stack area and use memset for unpoisoning, but since we don't know total size of dynamic area, this might be unfriendly for memory consumption.
3. We can ignore UAR detection for now and always allocate dynamic allocas on stack for both cases. This is the simplest solution, the only trick here is how to get a size parameter for memset, that would perform unpoisoning stuff before each ret and llvm.stackrestore instructions.

Generally, I don't see a convenient way to deal with UAR detection without code mess, perhaps we can skip it for now? Right now, I'm testing a patch for non-UAR case, it seems to be quite simple.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7098

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  lib/asan/asan_fake_stack.cc
  lib/asan/asan_interface_internal.h
  test/Instrumentation/AddressSanitizer/instrument-dynamic-allocas.ll
  test/Instrumentation/AddressSanitizer/undecidable-dynamic-alloca-1.ll
  test/asan/TestCases/Linux/interface_symbols_linux.c
  test/asan/TestCases/alloca_loop_unpoisoning.cc
  test/asan/TestCases/alloca_vla_interact.cc
  test/asan/TestCases/vla_chrome_testcase.cc
  test/asan/TestCases/vla_condition_overflow.cc
  test/asan/TestCases/vla_loop_overfow.cc

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7098.23276.patch
Type: text/x-patch
Size: 26272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150406/a7a171e1/attachment.bin>


More information about the llvm-commits mailing list