FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

/* * Copyright (C) 2019-2026 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "Integrity.h" #include "APICast.h" #include "CellSize.h" #include "IntegrityInlines.h" #include "JSCast.h" #include "JSCellInlines.h" #include "JSGlobalObject.h" #include "Options.h" #include "VMManager.h" #include #if OS(DARWIN) #include #endif namespace JSC { namespace Integrity { namespace IntegrityInternal { static constexpr bool verbose = false; } PrintStream& logFile() { #if OS(DARWIN) static PrintStream* s_file; static std::once_flag once; std::call_once(once, [] { // We want to use OS_LOG_TYPE_ERROR because we want to guarantee that the log makes it into // the file system, and is not potentially stuck in some memory buffer. Integrity audit logs // are used for debugging error states. So, this is an appropriate use of OS_LOG_TYPE_ERROR. s_file = OSLogPrintStream::open("com.apple.JavaScriptCore", "Integrity", OS_LOG_TYPE_ERROR).release(); }); return *s_file; #else return WTF::dataFile(); #endif } WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN void logF(const char* format, ...) { va_list argList; va_start(argList, format); logFile().vprintf(format, argList); va_end(argList); } void logLnF(const char* format, ...) { va_list argList; va_start(argList, format); logFile().vprintf(format, argList); va_end(argList); logFile().println(); } WTF_ALLOW_UNSAFE_BUFFER_USAGE_END Random::Random(VM& vm) { reloadAndCheckShouldAuditSlow(vm); } bool Random::reloadAndCheckShouldAuditSlow(VM& vm) { Locker locker { m_lock }; if (!Options::randomIntegrityAuditRate()) { m_triggerBits = 0; // Never trigger, and don't bother reloading. if (IntegrityInternal::verbose) dataLogLn("disabled Integrity audits: trigger bits ", RawHex(m_triggerBits)); return false; } // Reload the trigger bits. m_triggerBits = 1ull

Back | FazBrowse Home | New Git URL