New issue
Advanced search Search tips

Issue 663402 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android , Chrome
Pri: 1
Type: Bug-Security



Sign in to add a comment

Security: [arm] OOB r/w due to size computation bug in MacroAssembler::Allocate

Project Member Reported by jkummerow@chromium.org, Nov 8 2016

Issue description

VULNERABILITY DETAILS

The arm32 implementation of V8's MacroAssembler::Allocate(int object_size, ...) can get confused about its handrolled object_start + object_size computation: the "add" instructions (except for the first) erroneously use the "cc" condition (carry bit set), which is not updated by the allocation code sequence, but inherited from whatever code ran before. This results in a too-low object_end being compared against the allocation limit. The allocation appears to succeed, but the returned object has a larger size than what was checked and recorded, so it might extend beyond the end of the current page, or overlap with the next object.


VERSION
Chrome Version: 52 to ToT
Operating System: all arm32 platforms (Android, ChromeOS)


REPRODUCTION CASE

// Flags: --allow-natives-syntax

var g_eval = eval;
function emit_f(size) {
  var body = "function f(x) {" +
             "  if (x < 0) return x;" +
             "  var a = [1];" +
             "  if (x > 0) return [";
  for (var i = 0; i < size; i++) {
    body += "0.1, ";
  }
  body += "  ];" +
          "  return a;" +
          "}";
  g_eval(body);
}

// Length must be big enough to make the backing store's size not fit into
// a single instruction's immediate field (2^12).
var kLength = 701;
emit_f(kLength);
f(1);
f(1);
%OptimizeFunctionOnNextCall(f);
var a = f(1);

// Allocating something else should not disturb |a|.
var b = new Object();
for (var i = 0; i < kLength; i++) {
  assertEquals(0.1, a[i]);
}

// Allocating more should not crash.
for (var i = 0; i < 300; i++) {
  f(1);
}


FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION
Type of crash: tab
Crash State: segfault

 
Project Member

Comment 1 by bugdroid1@chromium.org, Nov 8 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/87332fdf677f1b53f71be7c05d025a285e5a5c73

commit 87332fdf677f1b53f71be7c05d025a285e5a5c73
Author: jkummerow <jkummerow@chromium.org>
Date: Tue Nov 08 18:19:01 2016

[arm] Fix custom addition in MacroAssembler::[Fast]Allocate

Don't rely on carry flags you didn't set yourself.

BUG= chromium:663402 

Review-Url: https://codereview.chromium.org/2484283002
Cr-Commit-Position: refs/heads/master@{#40848}

[modify] https://crrev.com/87332fdf677f1b53f71be7c05d025a285e5a5c73/src/arm/macro-assembler-arm.cc
[add] https://crrev.com/87332fdf677f1b53f71be7c05d025a285e5a5c73/test/mjsunit/regress/regress-crbug-663402.js

Labels: Security_Severity-High
Project Member

Comment 3 by sheriffbot@chromium.org, Nov 9 2016

Labels: M-54
Status: Fixed (was: Started)
Fixed on ToT by #1, waiting for Canary/Dev coverage before requesting backmerge.
Project Member

Comment 5 by sheriffbot@chromium.org, Nov 10 2016

Labels: -Restrict-View-SecurityTeam Restrict-View-SecurityNotify
Project Member

Comment 6 by sheriffbot@chromium.org, Nov 12 2016

Labels: Merge-Request-55

Comment 7 by dimu@chromium.org, Nov 12 2016

Labels: -Merge-Request-55 Merge-Approved-55 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M55 (branch: 2883)
Project Member

Comment 8 by bugdroid1@chromium.org, Nov 14 2016

Labels: merge-merged-5.5
The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/fb84109cd1f2c4115cf9b348d8a9971656aa4d8b

commit fb84109cd1f2c4115cf9b348d8a9971656aa4d8b
Author: Jakob Kummerow <jkummerow@chromium.org>
Date: Mon Nov 14 10:48:34 2016

Merged: [arm] Fix custom addition in MacroAssembler::[Fast]Allocate

Revision: 87332fdf677f1b53f71be7c05d025a285e5a5c73

BUG= chromium:663402 
LOG=N
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=cbruni@chromium.org

Review URL: https://codereview.chromium.org/2500843002 .

Cr-Commit-Position: refs/branch-heads/5.5@{#42}
Cr-Branched-From: 3cbd5838bd8376103daa45d69dade929ee4e0092-refs/heads/5.5.372@{#1}
Cr-Branched-From: b3c8b0ce2c9af0528837d8309625118d4096553b-refs/heads/master@{#40015}

[modify] https://crrev.com/fb84109cd1f2c4115cf9b348d8a9971656aa4d8b/src/arm/macro-assembler-arm.cc
[add] https://crrev.com/fb84109cd1f2c4115cf9b348d8a9971656aa4d8b/test/mjsunit/regress/regress-crbug-663402.js

Labels: -Hotlist-Merge-Approved -Merge-Approved-55
Project Member

Comment 10 by sheriffbot@chromium.org, Feb 16 2017

Labels: -Restrict-View-SecurityNotify allpublic
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment