Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 return ds->originalRequest().url(); | 195 return ds->originalRequest().url(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 NOINLINE static void CrashIntentionally() { | 198 NOINLINE static void CrashIntentionally() { |
| 199 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 199 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 200 // that the signature is easier to triage in crash reports. | 200 // that the signature is easier to triage in crash reports. |
| 201 volatile int* zero = NULL; | 201 volatile int* zero = NULL; |
| 202 *zero = 0; | 202 *zero = 0; |
| 203 } | 203 } |
| 204 | 204 |
| 205 #if defined(SYZYASAN) | |
| 206 #pragma warning(push) | |
| 207 #pragma warning(disable: 4509) | |
|
chrisha
2014/04/22 16:28:01
Comment as to what warning you are disabling?
Sébastien Marchand
2014/04/22 17:21:43
Done.
| |
| 208 NOINLINE static void CorruptMemoryBlock() { | |
| 209 // NOTE(sebmarchand): We intentionally corrupt a memory block her in order to | |
|
chrisha
2014/04/22 16:28:01
here* in order
Sébastien Marchand
2014/04/22 17:21:43
Done.
| |
| 210 // trigger an Address Sanitizer (ASAN) error report. | |
| 211 static const int kArraySize = 5; | |
| 212 scoped_ptr<int[]> array(new int[kArraySize]); | |
| 213 // Encapsulate the invalid memory access into a try-catch statement to prevent | |
| 214 // the function from being instrumented. This way the underflow won't be | |
|
chrisha
2014/04/22 16:28:01
this* function from being instrumented.
Sébastien Marchand
2014/04/22 17:21:43
Done.
| |
| 215 // detected but the corruption will (as the allocator will still be hooked). | |
| 216 __try { | |
| 217 int dummy = array[-1]--; | |
| 218 // Make sure the assignments to the dummy value aren't optimized away. | |
| 219 base::debug::Alias(&array); | |
| 220 } __except (EXCEPTION_EXECUTE_HANDLER) { | |
| 221 return; | |
| 222 } | |
| 223 } | |
| 224 #pragma warning(pop) | |
| 225 #endif | |
| 226 | |
| 205 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 227 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 206 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 228 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { |
| 207 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 229 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
| 208 // order to trigger an Address Sanitizer (ASAN) error report. | 230 // order to trigger an Address Sanitizer (ASAN) error report. |
| 209 static const char kCrashDomain[] = "crash"; | 231 static const char kCrashDomain[] = "crash"; |
| 210 static const char kHeapOverflow[] = "/heap-overflow"; | 232 static const char kHeapOverflow[] = "/heap-overflow"; |
| 211 static const char kHeapUnderflow[] = "/heap-underflow"; | 233 static const char kHeapUnderflow[] = "/heap-underflow"; |
| 212 static const char kUseAfterFree[] = "/use-after-free"; | 234 static const char kUseAfterFree[] = "/use-after-free"; |
| 235 #if defined(SYZYASAN) | |
| 236 static const char kHeapCorruptedBlock[] = "/heap-corrupted-block"; | |
| 237 #endif | |
| 213 static const int kArraySize = 5; | 238 static const int kArraySize = 5; |
| 214 | 239 |
| 215 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) | 240 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) |
| 216 return; | 241 return; |
| 217 | 242 |
| 218 if (!url.has_path()) | 243 if (!url.has_path()) |
| 219 return; | 244 return; |
| 220 | 245 |
| 221 scoped_ptr<int[]> array(new int[kArraySize]); | 246 scoped_ptr<int[]> array(new int[kArraySize]); |
| 222 std::string crash_type(url.path()); | 247 std::string crash_type(url.path()); |
| 223 int dummy = 0; | 248 int dummy = 0; |
| 224 if (crash_type == kHeapOverflow) { | 249 if (crash_type == kHeapOverflow) { |
| 225 dummy = array[kArraySize]; | 250 dummy = array[kArraySize]; |
| 226 } else if (crash_type == kHeapUnderflow ) { | 251 } else if (crash_type == kHeapUnderflow ) { |
| 227 dummy = array[-1]; | 252 dummy = array[-1]; |
| 228 } else if (crash_type == kUseAfterFree) { | 253 } else if (crash_type == kUseAfterFree) { |
| 229 int* dangling = array.get(); | 254 int* dangling = array.get(); |
| 230 array.reset(); | 255 array.reset(); |
| 231 dummy = dangling[kArraySize / 2]; | 256 dummy = dangling[kArraySize / 2]; |
| 257 #if defined(SYZYASAN) | |
| 258 } else if (crash_type == kHeapCorruptedBlock) { | |
| 259 CorruptMemoryBlock(); | |
| 260 #endif | |
| 232 } | 261 } |
| 233 | 262 |
| 234 // Make sure the assignments to the dummy value aren't optimized away. | 263 // Make sure the assignments to the dummy value aren't optimized away. |
| 235 base::debug::Alias(&dummy); | 264 base::debug::Alias(&dummy); |
| 236 } | 265 } |
| 237 #endif // ADDRESS_SANITIZER || SYZYASAN | 266 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 238 | 267 |
| 239 static void MaybeHandleDebugURL(const GURL& url) { | 268 static void MaybeHandleDebugURL(const GURL& url) { |
| 240 if (!url.SchemeIs(kChromeUIScheme)) | 269 if (!url.SchemeIs(kChromeUIScheme)) |
| 241 return; | 270 return; |
| (...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3169 selection_text_offset_ = offset; | 3198 selection_text_offset_ = offset; |
| 3170 selection_range_ = range; | 3199 selection_range_ = range; |
| 3171 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3200 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
| 3172 Send(new ViewHostMsg_SelectionChanged( | 3201 Send(new ViewHostMsg_SelectionChanged( |
| 3173 GetRenderWidget()->routing_id(), text, offset, range)); | 3202 GetRenderWidget()->routing_id(), text, offset, range)); |
| 3174 } | 3203 } |
| 3175 GetRenderWidget()->UpdateSelectionBounds(); | 3204 GetRenderWidget()->UpdateSelectionBounds(); |
| 3176 } | 3205 } |
| 3177 | 3206 |
| 3178 } // namespace content | 3207 } // namespace content |
| OLD | NEW |