Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9382b3b

Browse filesBrowse files
joyeecheungBridgeAR
authored andcommitted
deps: V8: cherry-pick e0a109c
Original commit message: [api] Implement StartupData::CanBeRehashed() for the snapshot blob This enables the embedder to check if the snapshot generated from SnapshotCreator::CreateBlob() can be rehashed and the seed can be recomputed during deserialization. The lack of this functionality resulted in a temporary vunerability in Node.js: #27365 Change-Id: I88d52337217c40f79c26438be3c87d2db874d980 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1578661 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#61175} Refs: v8/v8@e0a109c PR-URL: #27533 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 6014429 commit 9382b3b
Copy full SHA for 9382b3b

File tree

Expand file treeCollapse file tree

6 files changed

+20
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+20
-3
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.13',
41+
'v8_embedder_string': '-node.14',
4242

4343
##### V8 defaults for Node.js #####
4444

Collapse file

‎deps/v8/include/v8.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8.h
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8605,6 +8605,13 @@ class V8_EXPORT Isolate {
86058605

86068606
class V8_EXPORT StartupData {
86078607
public:
8608+
/**
8609+
* Whether the data created can be rehashed and and the hash seed can be
8610+
* recomputed when deserialized.
8611+
* Only valid for StartupData returned by SnapshotCreator::CreateBlob().
8612+
*/
8613+
bool CanBeRehashed() const;
8614+
86088615
const char* data;
86098616
int raw_size;
86108617
};
Collapse file

‎deps/v8/src/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,11 @@ StartupData SnapshotCreator::CreateBlob(
887887
return result;
888888
}
889889

890+
bool StartupData::CanBeRehashed() const {
891+
DCHECK(i::Snapshot::VerifyChecksum(this));
892+
return i::Snapshot::ExtractRehashability(this);
893+
}
894+
890895
void V8::SetDcheckErrorHandler(DcheckErrorCallback that) {
891896
v8::base::SetDcheckFunction(that);
892897
}
Collapse file

‎deps/v8/src/snapshot/snapshot-common.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/snapshot/snapshot-common.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ uint32_t Snapshot::ExtractContextOffset(const v8::StartupData* data,
229229

230230
bool Snapshot::ExtractRehashability(const v8::StartupData* data) {
231231
CHECK_LT(kRehashabilityOffset, static_cast<uint32_t>(data->raw_size));
232-
return GetHeaderValue(data, kRehashabilityOffset) != 0;
232+
uint32_t rehashability = GetHeaderValue(data, kRehashabilityOffset);
233+
CHECK_IMPLIES(rehashability != 0, rehashability == 1);
234+
return rehashability != 0;
233235
}
234236

235237
namespace {
Collapse file

‎deps/v8/src/snapshot/snapshot.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/snapshot/snapshot.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ class Snapshot : public AllStatic {
8787
static bool SnapshotIsValid(const v8::StartupData* snapshot_blob);
8888
#endif // DEBUG
8989

90+
static bool ExtractRehashability(const v8::StartupData* data);
91+
9092
private:
9193
static uint32_t ExtractNumContexts(const v8::StartupData* data);
9294
static uint32_t ExtractContextOffset(const v8::StartupData* data,
9395
uint32_t index);
94-
static bool ExtractRehashability(const v8::StartupData* data);
9596
static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
9697
static Vector<const byte> ExtractReadOnlyData(const v8::StartupData* data);
9798
static Vector<const byte> ExtractContextData(const v8::StartupData* data,
Collapse file

‎deps/v8/test/cctest/test-serialize.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-serialize.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,6 +3709,7 @@ UNINITIALIZED_TEST(ReinitializeHashSeedNotRehashable) {
37093709
}
37103710
blob =
37113711
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
3712+
CHECK(!blob.CanBeRehashed());
37123713
}
37133714

37143715
i::FLAG_hash_seed = 1337;
@@ -3774,6 +3775,7 @@ UNINITIALIZED_TEST(ReinitializeHashSeedRehashable) {
37743775
}
37753776
blob =
37763777
creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
3778+
CHECK(blob.CanBeRehashed());
37773779
}
37783780

37793781
i::FLAG_hash_seed = 1337;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.