OLD | NEW |
---|---|
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 // Various constants for identifying the beginnings of regions of memory. | 105 // Various constants for identifying the beginnings of regions of memory. |
106 static const uint16_t kBlockHeaderMagic = 0xCA80; | 106 static const uint16_t kBlockHeaderMagic = 0xCA80; |
107 | 107 |
108 // Various constants used for filling regions of memory. | 108 // Various constants used for filling regions of memory. |
109 static const uint8_t kBlockHeaderPaddingByte = 0x1C; | 109 static const uint8_t kBlockHeaderPaddingByte = 0x1C; |
110 static const uint8_t kBlockTrailerPaddingByte = 0xC3; | 110 static const uint8_t kBlockTrailerPaddingByte = 0xC3; |
111 static const uint8_t kBlockFloodFillByte = 0xFD; | 111 static const uint8_t kBlockFloodFillByte = 0xFD; |
112 | 112 |
113 // The number of bits in the checksum field. This is parameterized so that | 113 // The number of bits in the checksum field. This is parameterized so that |
114 // it can be referred to by the checksumming code. | 114 // it can be referred to by the checksumming code. |
115 static const size_t kBlockHeaderChecksumBits = 14; | 115 static const size_t kBlockHeaderChecksumBits = 13; |
116 | |
117 // The maximum allocation size that we can handle in SyzyAsan, this is | |
118 // constrained by the number of bits used to store the block size in the block | |
119 // header structure. | |
120 static const uint32_t kBlockMaxAllocSize = static_cast<uint32_t>(1 << 31) - 1; | |
chrisha
2016/11/24 17:23:23
Use a constexpr or a #define to store the value 31
Sébastien Marchand
2016/11/25 02:38:21
Done.
| |
116 | 121 |
117 // The state of an Asan block. These are in the order that reflects the typical | 122 // The state of an Asan block. These are in the order that reflects the typical |
118 // lifespan of an allocation. | 123 // lifespan of an allocation. |
119 enum BlockState { | 124 enum BlockState { |
120 // The block is allocated and valid for reading/writing. | 125 // The block is allocated and valid for reading/writing. |
121 ALLOCATED_BLOCK, | 126 ALLOCATED_BLOCK, |
122 // The block has been quarantined, and not valid for reading/writing. | 127 // The block has been quarantined, and not valid for reading/writing. |
123 // While in the quarantine it is still allocated as far as the underlying | 128 // While in the quarantine it is still allocated as far as the underlying |
124 // heap is concerned, and won't be reclaimed. | 129 // heap is concerned, and won't be reclaimed. |
125 QUARANTINED_BLOCK, | 130 QUARANTINED_BLOCK, |
(...skipping 24 matching lines...) Expand all Loading... | |
150 unsigned state : 2; | 155 unsigned state : 2; |
151 // If this bit is positive then header padding is present. The size of the | 156 // If this bit is positive then header padding is present. The size of the |
152 // header padding is encoded in the padding itself. | 157 // header padding is encoded in the padding itself. |
153 unsigned has_header_padding : 1; | 158 unsigned has_header_padding : 1; |
154 // If this bit is positive then trailer padding in excess of | 159 // If this bit is positive then trailer padding in excess of |
155 // kShadowRatio/2 is present, and the size of the trailer padding itself | 160 // kShadowRatio/2 is present, and the size of the trailer padding itself |
156 // will be encoded in these bytes. Otherwise it is implicit as | 161 // will be encoded in these bytes. Otherwise it is implicit as |
157 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). | 162 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). |
158 unsigned has_excess_trailer_padding : 1; | 163 unsigned has_excess_trailer_padding : 1; |
159 // The size of the body of the allocation, in bytes. | 164 // The size of the body of the allocation, in bytes. |
160 unsigned body_size : 30; | 165 unsigned body_size : 31; |
161 }; | 166 }; |
162 // TODO(loskutov): replace pointers with something more compact. | 167 // TODO(loskutov): replace pointers with something more compact. |
163 // The allocation stack of this block. | 168 // The allocation stack of this block. |
164 const common::StackCapture* alloc_stack; | 169 const common::StackCapture* alloc_stack; |
165 // The free stack of this block (NULL if not yet quarantined/freed). | 170 // The free stack of this block (NULL if not yet quarantined/freed). |
166 const common::StackCapture* free_stack; | 171 const common::StackCapture* free_stack; |
167 }; | 172 }; |
168 #pragma pack(pop) | 173 #pragma pack(pop) |
169 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, | 174 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, |
170 "Invalid BlockHeader mod size."); | 175 "Invalid BlockHeader mod size."); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 typedef base::Callback<void(EXCEPTION_POINTERS*)> OnExceptionCallback; | 522 typedef base::Callback<void(EXCEPTION_POINTERS*)> OnExceptionCallback; |
518 void SetOnExceptionCallback(OnExceptionCallback callback); | 523 void SetOnExceptionCallback(OnExceptionCallback callback); |
519 void ClearOnExceptionCallback(); | 524 void ClearOnExceptionCallback(); |
520 | 525 |
521 } // namespace asan | 526 } // namespace asan |
522 } // namespace agent | 527 } // namespace agent |
523 | 528 |
524 #include "syzygy/agent/asan/block_impl.h" | 529 #include "syzygy/agent/asan/block_impl.h" |
525 | 530 |
526 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ | 531 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ |
OLD | NEW |