Skip to content

Commit 71d7b38

Browse files
rajatdMSLaguana
authored andcommitted
[CVE-2018-0953] Edge Chakra - JIT: Magic value can cause type confusion - Google, Inc.
1 parent bee1e24 commit 71d7b38

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,8 +4124,9 @@ BackwardPass::UpdateArrayBailOutKind(IR::Instr *const instr)
41244124

41254125
IR::BailOutKind includeBailOutKinds = IR::BailOutInvalid;
41264126
if(!baseValueType.IsNotNativeArray() &&
4127-
(!baseValueType.IsLikelyNativeArray() || instr->GetSrc1()->IsVar()) &&
4128-
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty())
4127+
(!baseValueType.IsLikelyNativeArray() || !instr->GetSrc1()->IsInt32()) &&
4128+
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty() &&
4129+
!(instr->GetBailOutKind() & IR::BailOutOnArrayAccessHelperCall))
41294130
{
41304131
// There is an upwards-exposed use of a native array. Since the array referenced by this instruction can be aliased,
41314132
// this instruction needs to bail out if it converts the native array even if this array specifically is not

lib/Runtime/Language/JavascriptOperators.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,6 +4530,10 @@ namespace Js
45304530
ScriptContext* scriptContext,
45314531
PropertyOperationFlags flags)
45324532
{
4533+
4534+
INT_PTR vt = (INT_PTR)nullptr;
4535+
vt = VirtualTableInfoBase::GetVirtualTable(instance);
4536+
45334537
if (TaggedInt::Is(aElementIndex))
45344538
{
45354539
int32 indexInt = TaggedInt::ToInt32(aElementIndex);
@@ -4540,11 +4544,12 @@ namespace Js
45404544
{
45414545
arr->SetItem(indexInt, iValue);
45424546
}
4543-
return TRUE;
4547+
return vt != VirtualTableInfoBase::GetVirtualTable(instance);
45444548
}
45454549
}
45464550

4547-
return JavascriptOperators::OP_SetElementI(instance, aElementIndex, JavascriptNumber::ToVar(iValue, scriptContext), scriptContext, flags);
4551+
JavascriptOperators::OP_SetElementI(instance, aElementIndex, JavascriptNumber::ToVar(iValue, scriptContext), scriptContext, flags);
4552+
return vt != VirtualTableInfoBase::GetVirtualTable(instance);
45484553
}
45494554

45504555
BOOL JavascriptOperators::OP_SetNativeIntElementI_UInt32(
@@ -4586,6 +4591,10 @@ namespace Js
45864591
PropertyOperationFlags flags,
45874592
double dValue)
45884593
{
4594+
4595+
INT_PTR vt = (INT_PTR)nullptr;
4596+
vt = VirtualTableInfoBase::GetVirtualTable(instance);
4597+
45894598
if (TaggedInt::Is(aElementIndex))
45904599
{
45914600
int32 indexInt = TaggedInt::ToInt32(aElementIndex);
@@ -4596,16 +4605,17 @@ namespace Js
45964605
{
45974606
arr->SetItem(indexInt, dValue);
45984607
}
4599-
return TRUE;
4608+
return vt != VirtualTableInfoBase::GetVirtualTable(instance);
46004609
}
46014610
}
46024611

4603-
return JavascriptOperators::OP_SetElementI(instance, aElementIndex, JavascriptNumber::ToVarWithCheck(dValue, scriptContext), scriptContext, flags);
4612+
JavascriptOperators::OP_SetElementI(instance, aElementIndex, JavascriptNumber::ToVarWithCheck(dValue, scriptContext), scriptContext, flags);
4613+
return vt != VirtualTableInfoBase::GetVirtualTable(instance);
46044614
}
46054615

46064616
BOOL JavascriptOperators::OP_SetNativeFloatElementI_UInt32(
4607-
Var instance, uint32
4608-
aElementIndex,
4617+
Var instance,
4618+
uint32 aElementIndex,
46094619
ScriptContext* scriptContext,
46104620
PropertyOperationFlags flags,
46114621
double dValue)

0 commit comments

Comments
 (0)