Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 #define ENABLE_SECURITY_ASSERT 0 | 239 #define ENABLE_SECURITY_ASSERT 0 |
| 240 #endif | 240 #endif |
| 241 | 241 |
| 242 // SECURITY_DCHECK and SECURITY_CHECK | 242 // SECURITY_DCHECK and SECURITY_CHECK |
| 243 // Use in places where failure of the assertion indicates a possible security | 243 // Use in places where failure of the assertion indicates a possible security |
| 244 // vulnerability. Classes of these vulnerabilities include bad casts, out of | 244 // vulnerability. Classes of these vulnerabilities include bad casts, out of |
| 245 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these | 245 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these |
| 246 // failures using the security template: | 246 // failures using the security template: |
| 247 // https://bugs.chromium.org/p/chromium/issues/entry?template=Security%20Bug | 247 // https://bugs.chromium.org/p/chromium/issues/entry?template=Security%20Bug |
| 248 #if ENABLE_SECURITY_ASSERT | 248 #if ENABLE_SECURITY_ASSERT |
| 249 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security chec k failed: " #condition ". " | 249 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security DCHE CK failed: " #condition ". " |
|
mmoroz
2016/08/25 13:44:04
After the discussion in previous patchset, I propo
| |
| 250 // TODO(tkent): Should we make SECURITY_CHECK different from SECURITY_DCHECK? | |
| 251 // A SECURITY_CHECK failure is actually not vulnerable. | 250 // A SECURITY_CHECK failure is actually not vulnerable. |
| 252 #define SECURITY_CHECK(condition) SECURITY_DCHECK(condition) | 251 #define SECURITY_CHECK(condition) LOG_IF(FATAL, !(condition)) << "Security CHECK failed: " #condition ". " |
| 253 #else | 252 #else |
| 254 #define SECURITY_DCHECK(condition) ((void)0) | 253 #define SECURITY_DCHECK(condition) ((void)0) |
| 255 #define SECURITY_CHECK(condition) CHECK(condition) | 254 #define SECURITY_CHECK(condition) CHECK(condition) |
| 256 #endif | 255 #endif |
| 257 | 256 |
| 258 // RELEASE_ASSERT | 257 // RELEASE_ASSERT |
| 259 // Use in places where failure of an assertion indicates a definite security | 258 // Use in places where failure of an assertion indicates a definite security |
| 260 // vulnerability from which execution must not continue even in a release build. | 259 // vulnerability from which execution must not continue even in a release build. |
| 261 // Please sure to file bugs for these failures using the security template: | 260 // Please sure to file bugs for these failures using the security template: |
| 262 // http://code.google.com/p/chromium/issues/entry?template=Security%20Bug | 261 // http://code.google.com/p/chromium/issues/entry?template=Security%20Bug |
| 263 // RELEASE_ASSERT is deprecated. We should use CHECK() instead. | 262 // RELEASE_ASSERT is deprecated. We should use CHECK() instead. |
| 264 #if ENABLE(ASSERT) | 263 #if ENABLE(ASSERT) |
| 265 #define RELEASE_ASSERT(assertion) ASSERT(assertion) | 264 #define RELEASE_ASSERT(assertion) ASSERT(assertion) |
| 265 #elif defined(ADDRESS_SANITIZER) | |
| 266 #define RELEASE_ASSERT(condition) LOG_IF(FATAL, !(condition)) << "Security CHECK failed: " #condition ". " | |
|
inferno
2016/08/25 15:03:06
Why not #define RELEASE_ASSERT(condition) SECURITY
mmoroz
2016/08/26 08:10:00
Oh, yes! Thanks.
| |
| 266 #else | 267 #else |
| 267 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0) | 268 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0) |
| 268 #endif | 269 #endif |
| 269 // TODO(tkent): Move this to base/logging.h? | 270 // TODO(tkent): Move this to base/logging.h? |
| 270 #define RELEASE_NOTREACHED() LOG(FATAL) | 271 #define RELEASE_NOTREACHED() LOG(FATAL) |
| 271 | 272 |
| 272 // DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES | 273 // DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES |
| 273 // Allow equality comparisons of Objects by reference or pointer, | 274 // Allow equality comparisons of Objects by reference or pointer, |
| 274 // interchangeably. This can be only used on types whose equality makes no | 275 // interchangeably. This can be only used on types whose equality makes no |
| 275 // other sense than pointer equality. | 276 // other sense than pointer equality. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 302 } \ | 303 } \ |
| 303 inline const thisType& to##thisType(const argumentType& argumentName) \ | 304 inline const thisType& to##thisType(const argumentType& argumentName) \ |
| 304 { \ | 305 { \ |
| 305 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 306 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
| 306 return static_cast<const thisType&>(argumentName); \ | 307 return static_cast<const thisType&>(argumentName); \ |
| 307 } \ | 308 } \ |
| 308 void to##thisType(const thisType*); \ | 309 void to##thisType(const thisType*); \ |
| 309 void to##thisType(const thisType&) | 310 void to##thisType(const thisType&) |
| 310 | 311 |
| 311 #endif // WTF_Assertions_h | 312 #endif // WTF_Assertions_h |
| OLD | NEW |