[PATCH] Implement variable-sized alloca instrumentation.

Kostya Serebryany kcc at google.com
Fri Oct 31 15:23:14 PDT 2014


This does not handle stack-use-after-return for alloca, right? 
I don't insist you implement that now, but consider for the next patch.

================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:591
@@ +590,3 @@
+    if (isDynamicAlloca(AI))
+      DynamicAllocaVec.push_back(&AI);
+    else
----------------
Please do it under a flag, off by default for now. 

================
Comment at: lib/asan/asan_interface_internal.h:181
@@ +180,3 @@
+
+// Runtime calls this function to poison redzones for dynamic allocas. Addr is
+  // base address of user memory, size is size of user memory.
----------------
indent

================
Comment at: lib/asan/asan_internal.h:140
@@ +139,3 @@
+const int kAsanAllocaLeftMagic = 0xca;
+const int kAsanAllocaPartialMagic = 0xcb;
+const int kAsanAllocaRightMagic = 0xcc;
----------------
I think kAsanAllocaPartialMagic is redundant, just use kAsanAllocaRightMagic
(we may want to get rid of kAsanStackPartialRedzoneMagic separately)

================
Comment at: lib/asan/asan_report.cc:992
@@ +991,3 @@
+      case kAsanAllocaLeftMagic:
+        bug_descr = "alloca-underflow";
+        break;
----------------
Maybe dynamic-stack-buffer-overflow (for both left and right cases)?

http://reviews.llvm.org/D6055






More information about the llvm-commits mailing list