[PATCH] D15008: [sanitizer] Fix a crash in SizeClassAllocator32 with an out-of-range pointer
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 08:06:58 PDT 2016
kubabrecka updated this revision to Diff 55819.
kubabrecka added a comment.
Herald added a subscriber: kubabrecka.
Ping. Adding a test case.
http://reviews.llvm.org/D15008
Files:
lib/sanitizer_common/sanitizer_allocator.h
test/asan/TestCases/Darwin/malloc_size_crash.mm
Index: test/asan/TestCases/Darwin/malloc_size_crash.mm
===================================================================
--- test/asan/TestCases/Darwin/malloc_size_crash.mm
+++ test/asan/TestCases/Darwin/malloc_size_crash.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_asan %s -o %t -framework Foundation
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#import <Foundation/Foundation.h>
+#include <malloc/malloc.h>
+
+int main(int argc, char *argv[]) {
+ id obj = @0;
+ fprintf(stderr, "obj = %p\n", obj);
+ size_t size = malloc_size(obj);
+ fprintf(stderr, "size = 0x%zx\n", size);
+ fprintf(stderr, "Done.\n");
+ // CHECK: Done.
+ return 0;
+}
Index: lib/sanitizer_common/sanitizer_allocator.h
===================================================================
--- lib/sanitizer_common/sanitizer_allocator.h
+++ lib/sanitizer_common/sanitizer_allocator.h
@@ -769,6 +769,9 @@
}
bool PointerIsMine(const void *p) {
+ uptr mem = reinterpret_cast<uptr>(p);
+ if (mem < kSpaceBeg || mem >= kSpaceBeg + kSpaceSize)
+ return false;
return GetSizeClass(p) != 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15008.55819.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160502/57e9b7ae/attachment.bin>
More information about the llvm-commits
mailing list