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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 | 208 |
209 #define ASSERT(assertion) ((void)0) | 209 #define ASSERT(assertion) ((void)0) |
210 #define DCHECK_AT(assertion, file, line) EAT_STREAM_PARAMETERS | 210 #define DCHECK_AT(assertion, file, line) EAT_STREAM_PARAMETERS |
211 #define ASSERT_NOT_REACHED() ((void)0) | 211 #define ASSERT_NOT_REACHED() ((void)0) |
212 #define NO_RETURN_DUE_TO_ASSERT | 212 #define NO_RETURN_DUE_TO_ASSERT |
213 | 213 |
214 #define ASSERT_UNUSED(variable, assertion) ((void)variable) | 214 #define ASSERT_UNUSED(variable, assertion) ((void)variable) |
215 | 215 |
216 #endif | 216 #endif |
217 | 217 |
218 // ASSERT_WITH_SECURITY_IMPLICATION / RELEASE_ASSERT_WITH_SECURITY_IMPLICATION | 218 // ASSERT_WITH_SECURITY_IMPLICATION |
219 // They are deprecated. ASSERT_WITH_SECURITY_IMPLICATION should be replaced | 219 // It is deprecated. ASSERT_WITH_SECURITY_IMPLICATION should be replaced |
220 // with SECURITY_DCHECK, and RELEASE_ASSERT_WITH_SECURITY_IMPLICATION should be | 220 // with SECURITY_DCHECK. |
haraken
2016/03/31 00:54:58
SECURITY_DCHECK => SECURITY_CHECK ?
dcheng
2016/03/31 01:09:40
I'm not sure how expensive this will be, all the t
tkent
2016/03/31 05:26:12
SECURITY_DCHECK is correct here.
ASSERT -> DCHECK
| |
221 // replaced with RELEASE_ASSERT. | |
222 #ifdef ADDRESS_SANITIZER | 221 #ifdef ADDRESS_SANITIZER |
223 | 222 |
224 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \ | 223 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \ |
225 (!(assertion) ? \ | 224 (!(assertion) ? \ |
226 (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #ass ertion), \ | 225 (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #ass ertion), \ |
227 CRASH()) : \ | 226 CRASH()) : \ |
228 (void)0) | 227 (void)0) |
229 | 228 |
230 #define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT_WITH_SECURITY _IMPLICATION(assertion) | |
231 | |
232 #else | 229 #else |
233 | |
234 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT(assertion) | 230 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT(assertion) |
235 #define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) RELEASE_ASSERT(asser tion) | |
236 | |
237 #endif | 231 #endif |
238 | 232 |
239 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 233 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
240 // that code testing this macro has included this header. | 234 // that code testing this macro has included this header. |
241 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 235 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
242 #define ENABLE_SECURITY_ASSERT 1 | 236 #define ENABLE_SECURITY_ASSERT 1 |
243 #else | 237 #else |
244 #define ENABLE_SECURITY_ASSERT 0 | 238 #define ENABLE_SECURITY_ASSERT 0 |
245 #endif | 239 #endif |
246 | 240 |
247 // SECURITY_DCHECK | 241 // SECURITY_DCHECK and SECURITY_CHECK |
248 // Use in places where failure of the assertion indicates a possible security | 242 // Use in places where failure of the assertion indicates a possible security |
249 // vulnerability. Classes of these vulnerabilities include bad casts, out of | 243 // vulnerability. Classes of these vulnerabilities include bad casts, out of |
250 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these | 244 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these |
251 // failures using the security template: | 245 // failures using the security template: |
252 // http://code.google.com/p/chromium/issues/entry?template=Security%20Bug | 246 // https://bugs.chromium.org/p/chromium/issues/entry?template=Security%20Bug |
253 #if ENABLE_SECURITY_ASSERT | 247 #if ENABLE_SECURITY_ASSERT |
254 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security chec k failed: " #condition ". " | 248 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security chec k failed: " #condition ". " |
249 // TODO(tkent): Should we make SECURITY_CHECK different from SECURITY_DCHECK? | |
250 // A SECURITY_CHECK failure is actually not vulnerable. | |
haraken
2016/03/31 00:54:58
Maybe failures that are not vulnerable should use
dcheng
2016/03/31 01:09:40
(I think) the security team uses this as a signal
inferno
2016/03/31 04:04:18
Yes correct, otherwise we won't be able to disting
Oliver Chang
2016/03/31 06:13:39
Why do we need to distinguish between CHECK and SE
| |
251 #define SECURITY_CHECK(condition) SECURITY_DCHECK(condition) | |
255 #else | 252 #else |
256 #define SECURITY_DCHECK(condition) ((void)0) | 253 #define SECURITY_DCHECK(condition) ((void)0) |
254 #define SECURITY_CHECK(condition) CHECK(condition) | |
257 #endif | 255 #endif |
258 | 256 |
259 // WTF_LOG | 257 // WTF_LOG |
260 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works | 258 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works |
261 // only in debug build, or VLOG(verboselevel), which works in release build too. | 259 // only in debug build, or VLOG(verboselevel), which works in release build too. |
262 #if LOG_DISABLED | 260 #if LOG_DISABLED |
263 #define WTF_LOG(channel, ...) ((void)0) | 261 #define WTF_LOG(channel, ...) ((void)0) |
264 #else | 262 #else |
265 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P REFIX, channel), __VA_ARGS__) | 263 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P REFIX, channel), __VA_ARGS__) |
266 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF IX_LEVEL_2(prefix, channel) | 264 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF IX_LEVEL_2(prefix, channel) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 } \ | 320 } \ |
323 inline const thisType& to##thisType(const argumentType& argumentName) \ | 321 inline const thisType& to##thisType(const argumentType& argumentName) \ |
324 { \ | 322 { \ |
325 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 323 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
326 return static_cast<const thisType&>(argumentName); \ | 324 return static_cast<const thisType&>(argumentName); \ |
327 } \ | 325 } \ |
328 void to##thisType(const thisType*); \ | 326 void to##thisType(const thisType*); \ |
329 void to##thisType(const thisType&) | 327 void to##thisType(const thisType&) |
330 | 328 |
331 #endif /* WTF_Assertions_h */ | 329 #endif /* WTF_Assertions_h */ |
OLD | NEW |