WebKit Bugzilla
Attachment 362310 Details for
Bug 194769
: Bytecode cache should a have a boot-specific validation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-194769-20190218211118.patch (text/plain), 11.30 KB, created by
Tadeu Zagallo
on 2019-02-18 12:11:54 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2019-02-18 12:11:54 PST
Size:
11.30 KB
patch
obsolete
>Subversion Revision: 241660 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index eeff7e648620c59aa5ef2982828c5962a794065f..04d07a0e2d7613039a2960b705d1912dec192af5 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,23 @@ >+2019-02-18 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Bytecode cache should a have a boot-specific validation >+ https://bugs.webkit.org/show_bug.cgi?id=194769 >+ <rdar://problem/48149509> >+ >+ Reviewed by Keith Miller. >+ >+ Add the boot UUID to the cached bytecode to enforce that it is not reused >+ across reboots. >+ >+ * runtime/CachedTypes.cpp: >+ (JSC::Encoder::malloc): >+ (JSC::GenericCacheEntry::GenericCacheEntry): >+ (JSC::GenericCacheEntry::tag const): >+ (JSC::CacheEntry::CacheEntry): >+ (JSC::CacheEntry::decode const): >+ (JSC::GenericCacheEntry::decode const): >+ (JSC::encodeCodeBlock): >+ > 2019-02-18 Tadeu Zagallo <tzagallo@apple.com> > > Add version number to cached bytecode >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index ad61a22c006ec06fe080dd09b84a90c38049785d..023ba6a6ed3a3f7f140051db15a0069dc1cc171c 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,17 @@ >+2019-02-18 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Bytecode cache should a have a boot-specific validation >+ https://bugs.webkit.org/show_bug.cgi?id=194769 >+ <rdar://problem/48149509> >+ >+ Reviewed by Keith Miller. >+ >+ Add helper to get kern.bootsessionuuid from sysctl >+ >+ * wtf/UUID.cpp: >+ (WTF::bootSessionUUIDString): >+ * wtf/UUID.h: >+ > 2019-02-17 David Kilzer <ddkilzer@apple.com> > > Unreviewed, rolling out r241620. >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index ba29e6ef33c1b8eaeb82076ffbb6d4c159c8ad85..acd95dfa9650ed01346215da43799285cf4662f8 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -41,6 +41,7 @@ > #include <wtf/FastMalloc.h> > #include <wtf/Forward.h> > #include <wtf/Optional.h> >+#include <wtf/UUID.h> > #include <wtf/text/AtomicStringImpl.h> > > namespace JSC { >@@ -102,10 +103,10 @@ public: > return malloc(size); > } > >- template<typename T> >- T* malloc() >+ template<typename T, typename... Args> >+ T* malloc(Args&&... args) > { >- return new (malloc(sizeof(T)).buffer()) T(); >+ return new (malloc(sizeof(T)).buffer()) T(std::forward<Args>(args)...); > } > > ptrdiff_t offsetOf(const void* address) >@@ -1990,20 +1991,25 @@ public: > bool decode(Decoder&, std::pair<SourceCodeKey, UnlinkedCodeBlock*>&) const; > > protected: >- GenericCacheEntry(CachedCodeBlockTag tag) >+ GenericCacheEntry(Encoder& encoder, CachedCodeBlockTag tag) > : m_tag(tag) > { >+ m_bootSessionUUID.encode(encoder, bootSessionUUIDString()); > } > >+ CachedCodeBlockTag tag() const { return m_tag; } >+ >+private: > uint32_t m_cacheVersion { JSC_BYTECODE_CACHE_VERSION }; >+ CachedString m_bootSessionUUID; > CachedCodeBlockTag m_tag; > }; > > template<typename UnlinkedCodeBlockType> > class CacheEntry : public GenericCacheEntry { > public: >- CacheEntry() >- : GenericCacheEntry(CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag) >+ CacheEntry(Encoder& encoder) >+ : GenericCacheEntry(encoder, CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag) > { > } > >@@ -2018,11 +2024,7 @@ private: > > bool decode(Decoder& decoder, std::pair<SourceCodeKey, UnlinkedCodeBlockType*>& result) const > { >- if (m_cacheVersion != JSC_BYTECODE_CACHE_VERSION) >- return false; >- ASSERT(m_tag == CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag); >- if (m_tag != CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag) >- return false; >+ ASSERT(tag() == CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag); > SourceCodeKey decodedKey; > m_key.decode(decoder, decodedKey); > result = { WTFMove(decodedKey), m_codeBlock.decode(decoder) }; >@@ -2035,6 +2037,11 @@ private: > > bool GenericCacheEntry::decode(Decoder& decoder, std::pair<SourceCodeKey, UnlinkedCodeBlock*>& result) const > { >+ if (m_cacheVersion != JSC_BYTECODE_CACHE_VERSION) >+ return false; >+ if (m_bootSessionUUID.decode(decoder) != bootSessionUUIDString()) >+ return false; >+ > switch (m_tag) { > case CachedProgramCodeBlockTag: > return reinterpret_cast<const CacheEntry<UnlinkedProgramCodeBlock>*>(this)->decode(decoder, reinterpret_cast<std::pair<SourceCodeKey, UnlinkedProgramCodeBlock*>&>(result)); >@@ -2054,7 +2061,7 @@ bool GenericCacheEntry::decode(Decoder& decoder, std::pair<SourceCodeKey, Unlink > template<typename UnlinkedCodeBlockType> > void encodeCodeBlock(Encoder& encoder, const SourceCodeKey& key, const UnlinkedCodeBlock* codeBlock) > { >- auto* entry = encoder.template malloc<CacheEntry<UnlinkedCodeBlockType>>(); >+ auto* entry = encoder.template malloc<CacheEntry<UnlinkedCodeBlockType>>(encoder); > entry->encode(encoder, { key, jsCast<const UnlinkedCodeBlockType*>(codeBlock) }); > } > >diff --git a/Source/WTF/wtf/UUID.cpp b/Source/WTF/wtf/UUID.cpp >index 48d64ffb4e2a58b9b486de60d77554d222323d37..85968bf59116d13cad92396f339f204fe1dc2151 100644 >--- a/Source/WTF/wtf/UUID.cpp >+++ b/Source/WTF/wtf/UUID.cpp >@@ -31,10 +31,15 @@ > #include "config.h" > #include <wtf/UUID.h> > >+#include <mutex> > #include <wtf/CryptographicallyRandomNumber.h> > #include <wtf/HexNumber.h> > #include <wtf/text/StringBuilder.h> > >+#if OS(DARWIN) >+#include <sys/sysctl.h> >+#endif >+ > namespace WTF { > > String createCanonicalUUIDString() >@@ -59,4 +64,20 @@ String createCanonicalUUIDString() > return builder.toString(); > } > >+String bootSessionUUIDString() >+{ >+ static LazyNeverDestroyed<String> bootSessionUUID; >+#if OS(DARWIN) >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [] { >+ size_t uuidLength = 37; >+ char uuid[uuidLength]; >+ if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidLength, nullptr, 0)) >+ return; >+ bootSessionUUID.construct(static_cast<const char*>(uuid), uuidLength - 1); >+ }); >+#endif >+ return bootSessionUUID; >+} >+ > } // namespace WTF >diff --git a/Source/WTF/wtf/UUID.h b/Source/WTF/wtf/UUID.h >index 8a78755e998f941292dd4a3c71ff862b73faafd8..6acd4624d7df1a439b48750eb64a728a47e34adb 100644 >--- a/Source/WTF/wtf/UUID.h >+++ b/Source/WTF/wtf/UUID.h >@@ -45,6 +45,9 @@ namespace WTF { > > WTF_EXPORT_PRIVATE String createCanonicalUUIDString(); > >+WTF_EXPORT_PRIVATE String bootSessionUUIDString(); >+ > } > > using WTF::createCanonicalUUIDString; >+using WTF::bootSessionUUIDString; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f8cc1347df286e80ab24644a3de90da4e142a1b6..52612a22ead5c84694ffa68bbc10c5920ba8aaac 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2019-02-18 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Bytecode cache should a have a boot-specific validation >+ https://bugs.webkit.org/show_bug.cgi?id=194769 >+ <rdar://problem/48149509> >+ >+ Reviewed by Keith Miller. >+ >+ Add test for WTF::bootSessionUUIDString() >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WTF/UUID.cpp: Added. >+ (TEST): >+ > 2019-02-17 Fujii Hironori <Hironori.Fujii@sony.com> > > Use dumpJSConsoleLogInStdErr=true webkit-test-runner option for non-imported tests instead of using DumpJSConsoleLogInStdErr expectation in TestExpectations >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 7c6e12360b2183718034e701f9792b7beeb92d59..00a5fdb98e567c662b6c7b1c85725486b5518d6f 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -1352,6 +1352,7 @@ > 11B7FD22219F46DD0069B27F /* FirstMeaningfulPaintMilestone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirstMeaningfulPaintMilestone.cpp; sourceTree = "<group>"; }; > 11C2598C21FA618D004C9E23 /* async-script-load.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "async-script-load.html"; sourceTree = "<group>"; }; > 14464012167A8305000BD218 /* LayoutUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutUnit.cpp; sourceTree = "<group>"; }; >+ 144D40EC221B46A7004B474F /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UUID.cpp; sourceTree = "<group>"; }; > 14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SaturatedArithmeticOperations.cpp; sourceTree = "<group>"; }; > 1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; }; > 1A02C84E125D4A8400E3F4BD /* Find.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Find.cpp; sourceTree = "<group>"; }; >@@ -3292,6 +3293,7 @@ > 5C5E633D1D0B67940085A025 /* UniqueRef.cpp */, > E3A1E78021B25B79008C6007 /* URL.cpp */, > E3A1E78421B25B91008C6007 /* URLParser.cpp */, >+ 144D40EC221B46A7004B474F /* UUID.cpp */, > 7CD0D5AA1D5534DE000CC9E1 /* Variant.cpp */, > BC55F5F814AD78EE00484BE1 /* Vector.cpp */, > 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */, >diff --git a/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp b/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d7de3afc870f9a1b16f79361ea107a0cbf45ba40 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WTF/UUID.cpp >@@ -0,0 +1,33 @@ >+/* >+ * Copyright (C) 2019 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. AND ITS CONTRIBUTORS ``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 ITS 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 <wtf/UUID.h> >+ >+TEST(WTF, BootSessionUUIDIdentity) >+{ >+ EXPECT_EQ(bootSessionUUIDString(), bootSessionUUIDString()); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194769
:
362267
|
362278
|
362289
|
362308
| 362310