Changeset 278425 in webkit for trunk/Source/JavaScriptCore/jit/ExecutableAllocationFuzz.cpp
- Timestamp:
- Jun 3, 2021, 3:44:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jit/ExecutableAllocationFuzz.cpp
r278356 r278425 30 30 #include <wtf/Atomics.h> 31 31 #include <wtf/DataLog.h> 32 #include <wtf/WeakRandom.h>33 32 34 33 namespace JSC { … … 42 41 ExecutableAllocationFuzzResult doExecutableAllocationFuzzing() 43 42 { 44 static WeakRandom random(Options::seedOfVMRandomForFuzzer() ? Options::seedOfVMRandomForFuzzer() : cryptographicallyRandomNumber());45 46 43 ASSERT(Options::useExecutableAllocationFuzz()); 47 44 48 unsigned numChecks = s_numberOfExecutableAllocationFuzzChecks.value++; 49 50 if (numChecks == Options::fireExecutableAllocationFuzzAt()) { 45 unsigned oldValue; 46 unsigned newValue; 47 do { 48 oldValue = s_numberOfExecutableAllocationFuzzChecks.load(); 49 newValue = oldValue + 1; 50 } while (!s_numberOfExecutableAllocationFuzzChecks.compareExchangeWeak(oldValue, newValue)); 51 52 if (newValue == Options::fireExecutableAllocationFuzzAt()) { 51 53 if (Options::verboseExecutableAllocationFuzz()) { 52 54 dataLog("Will pretend to fail executable allocation.\n"); … … 55 57 return PretendToFailExecutableAllocation; 56 58 } 57 59 58 60 if (Options::fireExecutableAllocationFuzzAtOrAfter() 59 && n umChecks>= Options::fireExecutableAllocationFuzzAtOrAfter()) {61 && newValue >= Options::fireExecutableAllocationFuzzAtOrAfter()) { 60 62 if (Options::verboseExecutableAllocationFuzz()) { 61 63 dataLog("Will pretend to fail executable allocation.\n"); … … 63 65 } 64 66 return PretendToFailExecutableAllocation; 65 } else if (!Options::fireExecutableAllocationFuzzAt() && random.getUint32() < UINT_MAX * Options::randomIntegrityAuditRate()) 66 return PretendToFailExecutableAllocation; 67 } 67 68 68 69 return AllowNormalExecutableAllocation;
Note:
See TracChangeset
for help on using the changeset viewer.