-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged: [string] Fix regexp fast path in MaybeCallFunctionAtSymbol
The regexp fast path in MaybeCallFunctionAtSymbol had an issue in which we'd call ToString after checking that the given {object} was a fast regexp and deciding to take the fast path. This is invalid since ToString() can call into user-controlled JS and may mutate {object}. There's no way to place the ToString call correctly in this instance: 1 before BranchIfFastRegExp, it's a spec violation if we end up on the slow regexp path; 2 the problem with the current location is already described above; 3 and we can't place it into the fast-path regexp builtin (e.g. RegExpReplace) either due to the same reasons as 1. The solution in this CL is to restrict the fast path to string arguments only, i.e. cases where ToString would be a nop and can safely be skipped. NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true TBR=yangguo@chromium.org Bug: chromium:782145 Change-Id: Ifd35b3a9a6cf2e77c96cb860a8ec98eaec35aa85 Reviewed-on: https://chromium-review.googlesource.com/763207 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/branch-heads/6.2@{#88} Cr-Branched-From: efa2ac4-refs/heads/6.2.414@{#1} Cr-Branched-From: a861ebb-refs/heads/master@{#47693}
- Loading branch information
Showing
3 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2017 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
function newFastRegExp() { return new RegExp('.'); } | ||
function toSlowRegExp(re) { re.exec = 42; } | ||
|
||
let re = newFastRegExp(); | ||
const evil_nonstring = { [Symbol.toPrimitive]: () => toSlowRegExp(re) }; | ||
const empty_string = ""; | ||
|
||
String.prototype.replace.call(evil_nonstring, re, empty_string); | ||
|
||
re = newFastRegExp(); | ||
String.prototype.match.call(evil_nonstring, re, empty_string); | ||
|
||
re = newFastRegExp(); | ||
String.prototype.search.call(evil_nonstring, re, empty_string); | ||
|
||
re = newFastRegExp(); | ||
String.prototype.split.call(evil_nonstring, re, empty_string); |