Skip to content

Commit 8284359

Browse files
blendinCommit Bot
authored andcommitted
[builtins] Harden Array.prototype.concat.
Defence in depth patch to prevent JavaScript from executing from within IterateElements. [email protected] [email protected] Bug: chromium:1195977 Change-Id: Ie59d468b73b94818cea986a3ded0804f6dddd10b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2819941 Reviewed-by: Camillo Bruni <[email protected]> Reviewed-by: Igor Sheludko <[email protected]> Commit-Queue: Igor Sheludko <[email protected]> Cr-Commit-Position: refs/heads/master@{#73898}
1 parent 818dbad commit 8284359

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Ben Newman <[email protected]>
6969
Ben Noordhuis <[email protected]>
7070
Benjamin Tan <[email protected]>
7171
Bert Belder <[email protected]>
72+
Brendon Tiszka <[email protected]>
7273
Brice Dobry <[email protected]>
7374
Burcu Dogan <[email protected]>
7475
Caitlin Potter <[email protected]>

src/builtins/builtins-array.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
10891089
case HOLEY_SEALED_ELEMENTS:
10901090
case HOLEY_NONEXTENSIBLE_ELEMENTS:
10911091
case HOLEY_ELEMENTS: {
1092+
// Disallow execution so the cached elements won't change mid execution.
1093+
DisallowJavascriptExecution no_js(isolate);
1094+
10921095
// Run through the elements FixedArray and use HasElement and GetElement
10931096
// to check the prototype for missing elements.
10941097
Handle<FixedArray> elements(FixedArray::cast(array->elements()), isolate);
@@ -1115,6 +1118,9 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
11151118
}
11161119
case HOLEY_DOUBLE_ELEMENTS:
11171120
case PACKED_DOUBLE_ELEMENTS: {
1121+
// Disallow execution so the cached elements won't change mid execution.
1122+
DisallowJavascriptExecution no_js(isolate);
1123+
11181124
// Empty array is FixedArray but not FixedDoubleArray.
11191125
if (length == 0) break;
11201126
// Run through the elements FixedArray and use HasElement and GetElement
@@ -1151,6 +1157,9 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
11511157
}
11521158

11531159
case DICTIONARY_ELEMENTS: {
1160+
// Disallow execution so the cached dictionary won't change mid execution.
1161+
DisallowJavascriptExecution no_js(isolate);
1162+
11541163
Handle<NumberDictionary> dict(array->element_dictionary(), isolate);
11551164
std::vector<uint32_t> indices;
11561165
indices.reserve(dict->Capacity() / 2);

0 commit comments

Comments
 (0)