WebKit Bugzilla
Attachment 362278 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
bug-194769-20190218113604.patch (text/plain), 4.43 KB, created by
Tadeu Zagallo
on 2019-02-18 02:36:40 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2019-02-18 02:36:40 PST
Size:
4.43 KB
patch
obsolete
>Subversion Revision: 241660 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index eeff7e648620c59aa5ef2982828c5962a794065f..625ee00174a02723c135aa82a3c9348626b10cec 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,22 @@ >+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 NOBODY (OOPS!). >+ >+ Add the boot UUID to the cached bytecode to enforce that it is not reused >+ across reboots. >+ >+ * runtime/CachedTypes.cpp: >+ (JSC::bootUUID): >+ (JSC::GenericCacheEntry::GenericCacheEntry): >+ (JSC::GenericCacheEntry::tag const): >+ (JSC::CacheEntry::CacheEntry): >+ (JSC::CacheEntry::decode const): >+ (JSC::GenericCacheEntry::decode const): >+ > 2019-02-18 Tadeu Zagallo <tzagallo@apple.com> > > Add version number to cached bytecode >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index ba29e6ef33c1b8eaeb82076ffbb6d4c159c8ad85..e3a09e578ce39de91158fb2ab4c9e702e23d01e9 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -38,13 +38,45 @@ > #include "UnlinkedMetadataTableInlines.h" > #include "UnlinkedModuleProgramCodeBlock.h" > #include "UnlinkedProgramCodeBlock.h" >+#include <wtf/ASCIICType.h> > #include <wtf/FastMalloc.h> > #include <wtf/Forward.h> > #include <wtf/Optional.h> > #include <wtf/text/AtomicStringImpl.h> > >+#if OS(DARWIN) >+#include <sys/sysctl.h> >+#endif >+ > namespace JSC { > >+using UUID = std::array<uint8_t, 16>; >+ >+static UUID bootUUID() >+{ >+ static UUID bootUUID = { }; >+#if OS(DARWIN) >+ static std::once_flag onceKey; >+ std::call_once(onceKey, [] { >+ size_t uuidlen = 37; >+ char uuid[uuidlen]; >+ if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidlen, nullptr, 0)) >+ return; >+ uint32_t offset = 0; >+ for (uint32_t i = 0; i < uuidlen - 1;) { >+ if (uuid[i] == '-') { >+ ++i; >+ continue; >+ } >+ bootUUID[offset++] = toASCIIHexValue(uuid[i], uuid[i+1]); >+ i += 2; >+ } >+ RELEASE_ASSERT(offset == sizeof(UUID)); >+ }); >+#endif >+ return bootUUID; >+} >+ > template <typename T, typename = void> > struct SourceTypeImpl { > using type = T; >@@ -1990,12 +2022,17 @@ public: > bool decode(Decoder&, std::pair<SourceCodeKey, UnlinkedCodeBlock*>&) const; > > protected: >- GenericCacheEntry(CachedCodeBlockTag tag) >- : m_tag(tag) >+ GenericCacheEntry(CachedCodeBlockTag tag, UUID bootUUID) >+ : m_bootUUID(bootUUID) >+ , m_tag(tag) > { > } > >+ CachedCodeBlockTag tag() const { return m_tag; } >+ >+private: > uint32_t m_cacheVersion { JSC_BYTECODE_CACHE_VERSION }; >+ UUID m_bootUUID; > CachedCodeBlockTag m_tag; > }; > >@@ -2003,7 +2040,7 @@ template<typename UnlinkedCodeBlockType> > class CacheEntry : public GenericCacheEntry { > public: > CacheEntry() >- : GenericCacheEntry(CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag) >+ : GenericCacheEntry(CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag, bootUUID()) > { > } > >@@ -2018,11 +2055,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 +2068,11 @@ private: > > bool GenericCacheEntry::decode(Decoder& decoder, std::pair<SourceCodeKey, UnlinkedCodeBlock*>& result) const > { >+ if (m_cacheVersion != JSC_BYTECODE_CACHE_VERSION) >+ return false; >+ if (m_bootUUID != bootUUID()) >+ return false; >+ > switch (m_tag) { > case CachedProgramCodeBlockTag: > return reinterpret_cast<const CacheEntry<UnlinkedProgramCodeBlock>*>(this)->decode(decoder, reinterpret_cast<std::pair<SourceCodeKey, UnlinkedProgramCodeBlock*>&>(result));
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