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