Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef AddressSanitizer_h | 31 #ifndef AddressSanitizer_h |
| 32 #define AddressSanitizer_h | 32 #define AddressSanitizer_h |
| 33 | 33 |
| 34 // The following API isn't exposed by SyzyASan (current version of ASan on | 34 // The following API isn't exposed by SyzyASan (current version of ASan on |
| 35 // Windows). | 35 // Windows). |
| 36 // FIXME: Add Windows support here. | 36 // FIXME: Add Windows support here. |
| 37 #if defined(ADDRESS_SANITIZER) && !OS(WIN) | 37 #if defined(ADDRESS_SANITIZER) && !OS(WIN) |
|
kcc1
2014/02/06 13:44:06
remember that this part depends on
https://code.g
Mads Ager (chromium)
2014/02/06 14:15:17
Yes, I will. I'll land the change to use this head
| |
| 38 extern "C" { | 38 #include <sanitizer/asan_interface.h> |
| 39 // Marks memory region [addr, addr+size) as unaddressable. | |
| 40 // This memory must be previously allocated by the user program. Accessing | |
| 41 // addresses in this region from instrumented code is forbidden until | |
| 42 // this region is unpoisoned. This function is not guaranteed to poison | |
| 43 // the whole region - it may poison only subregion of [addr, addr+size) due | |
| 44 // to ASan alignment restrictions. | |
| 45 // Method is NOT thread-safe in the sense that no two threads can | |
| 46 // (un)poison memory in the same memory region simultaneously. | |
| 47 void __asan_poison_memory_region(void const volatile*, size_t); | |
| 48 // Marks memory region [addr, addr+size) as addressable. | |
| 49 // This memory must be previously allocated by the user program. Accessing | |
| 50 // addresses in this region is allowed until this region is poisoned again. | |
| 51 // This function may unpoison a superregion of [addr, addr+size) due to | |
| 52 // ASan alignment restrictions. | |
| 53 // Method is NOT thread-safe in the sense that no two threads can | |
| 54 // (un)poison memory in the same memory region simultaneously. | |
| 55 void __asan_unpoison_memory_region(void const volatile*, size_t); | |
| 56 | |
| 57 // User code should use macros instead of functions. | |
| 58 #define ASAN_POISON_MEMORY_REGION(addr, size) \ | |
| 59 __asan_poison_memory_region((addr), (size)) | |
| 60 #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ | |
| 61 __asan_unpoison_memory_region((addr), (size)) | |
| 62 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) | 39 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) |
| 63 } | |
| 64 #else | 40 #else |
| 65 #define ASAN_POISON_MEMORY_REGION(addr, size) \ | 41 #define ASAN_POISON_MEMORY_REGION(addr, size) \ |
| 66 ((void)(addr), (void)(size)) | 42 ((void)(addr), (void)(size)) |
| 67 #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ | 43 #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ |
| 68 ((void)(addr), (void)(size)) | 44 ((void)(addr), (void)(size)) |
| 69 #define NO_SANITIZE_ADDRESS | 45 #define NO_SANITIZE_ADDRESS |
| 70 #endif | 46 #endif |
| 71 | 47 |
| 72 const size_t asanMagic = 0xabefeed0; | 48 const size_t asanMagic = 0xabefeed0; |
| 73 const size_t asanDeferMemoryReuseCount = 2; | 49 const size_t asanDeferMemoryReuseCount = 2; |
| 74 const size_t asanDeferMemoryReuseMask = 0x3; | 50 const size_t asanDeferMemoryReuseMask = 0x3; |
| 75 | 51 |
| 76 #endif | 52 #endif |
| OLD | NEW |