Skip to content

Commit a24d5ad

Browse files
jakobkummerowCommit Bot
authored andcommitted
[csa] Fix is-neutered check in EmitBigTypedArrayElementStore
The ToBigInt conversion can have side effects, so the check for neutered-ness must happen afterwards. Bug: chromium:867776 Change-Id: I6e550c77a284da4cf132c21a6c3b1ed8f34eedc9 Reviewed-on: https://chromium-review.googlesource.com/1153553 Commit-Queue: Jakob Kummerow <[email protected]> Reviewed-by: Dan Elphick <[email protected]> Cr-Commit-Position: refs/heads/master@{#54761}
1 parent 43098ec commit a24d5ad

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/code-stub-assembler.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9243,13 +9243,14 @@ void CodeStubAssembler::EmitBigTypedArrayElementStore(
92439243
TNode<JSTypedArray> object, TNode<FixedTypedArrayBase> elements,
92449244
TNode<IntPtrT> intptr_key, TNode<Object> value, TNode<Context> context,
92459245
Label* opt_if_neutered) {
9246+
TNode<BigInt> bigint_value = ToBigInt(context, value);
9247+
92469248
if (opt_if_neutered != nullptr) {
9247-
// Check if buffer has been neutered.
9249+
// Check if buffer has been neutered. Must happen after {ToBigInt}!
92489250
Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset);
92499251
GotoIf(IsDetachedBuffer(buffer), opt_if_neutered);
92509252
}
92519253

9252-
TNode<BigInt> bigint_value = ToBigInt(context, value);
92539254
TNode<RawPtrT> backing_store = LoadFixedTypedArrayBackingStore(elements);
92549255
TNode<IntPtrT> offset = ElementOffsetFromIndex(intptr_key, BIGINT64_ELEMENTS,
92559256
INTPTR_PARAMETERS, 0);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax --expose-gc
6+
7+
for (var i = 0; i < 3; i++) {
8+
var array = new BigInt64Array(200);
9+
10+
function evil_callback() {
11+
%ArrayBufferNeuter(array.buffer);
12+
gc();
13+
return 1094795585n;
14+
}
15+
16+
var evil_object = {valueOf: evil_callback};
17+
var root;
18+
try {
19+
root = BigInt64Array.of.call(function() { return array }, evil_object);
20+
} catch(e) {}
21+
gc();
22+
}

0 commit comments

Comments
 (0)