Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChakraCore 2018-05 security updates #5116

Merged
merged 14 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Build/NuGet/.pack-version
Original file line number Diff line number Diff line change
@@ -1 1 @@
1.8.3
1.8.4
22 changes: 9 additions & 13 deletions lib/Backend/BackwardPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4124,8 4124,9 @@ BackwardPass::UpdateArrayBailOutKind(IR::Instr *const instr)

IR::BailOutKind includeBailOutKinds = IR::BailOutInvalid;
if(!baseValueType.IsNotNativeArray() &&
(!baseValueType.IsLikelyNativeArray() || instr->GetSrc1()->IsVar()) &&
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty())
(!baseValueType.IsLikelyNativeArray() || !instr->GetSrc1()->IsInt32()) &&
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty() &&
!(instr->GetBailOutKind() & IR::BailOutOnArrayAccessHelperCall))
{
// There is an upwards-exposed use of a native array. Since the array referenced by this instruction can be aliased,
// this instruction needs to bail out if it converts the native array even if this array specifically is not
Expand Down Expand Up @@ -4231,6 4232,11 @@ BackwardPass::ProcessStackSymUse(StackSym * stackSym, BOOLEAN isNonByteCodeUse)
return true;
}

if (this->DoMarkTempNumbers())
{
Assert((block->loop != nullptr) == block->tempNumberTracker->HasTempTransferDependencies());
block->tempNumberTracker->ProcessUse(stackSym, this);
}
if (this->DoMarkTempObjects())
{
Assert((block->loop != nullptr) == block->tempObjectTracker->HasTempTransferDependencies());
Expand Down Expand Up @@ -4293,17 4299,7 @@ BackwardPass::ProcessSymUse(Sym * sym, bool isRegOpndUse, BOOLEAN isNonByteCodeU
}
}

StackSym * stackSym = sym->AsStackSym();
bool isUsed = ProcessStackSymUse(stackSym, isNonByteCodeUse);

if (!IsCollectionPass() && isRegOpndUse && this->DoMarkTempNumbers())
{
// Collect mark temp number information
Assert((block->loop != nullptr) == block->tempNumberTracker->HasTempTransferDependencies());
block->tempNumberTracker->ProcessUse(stackSym, this);
}

return isUsed;
return ProcessStackSymUse(sym->AsStackSym(), isNonByteCodeUse);
}

bool
Expand Down
24 changes: 4 additions & 20 deletions lib/Backend/GlobOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6482,6 6482,8 @@ GlobOpt::OptConstPeep(IR::Instr *instr, IR::Opnd *constSrc, Value **pDstVal, Val

instr->m_opcode = Js::OpCode::Ld_A;

InvalidateInductionVariables(instr);

return true;
}

Expand Down Expand Up @@ -7088,16 7090,7 @@ GlobOpt::OptConstFoldUnary(
}
}

// If this is an induction variable, then treat it the way the prepass would have if it had seen
// the assignment and the resulting change to the value number, and mark it as indeterminate.
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
{
InductionVariable *iv = nullptr;
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
{
iv->SetChangeIsIndeterminate();
}
}
InvalidateInductionVariables(instr);

return true;
}
Expand Down Expand Up @@ -12422,16 12415,7 @@ GlobOpt::OptConstFoldBinary(
this->ToInt32Dst(instr, dst->AsRegOpnd(), this->currentBlock);
}

// If this is an induction variable, then treat it the way the prepass would have if it had seen
// the assignment and the resulting change to the value number, and mark it as indeterminate.
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
{
InductionVariable *iv = nullptr;
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
{
iv->SetChangeIsIndeterminate();
}
}
InvalidateInductionVariables(instr);

return true;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/GlobOpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 685,7 @@ class GlobOpt
void DetectUnknownChangesToInductionVariables(GlobOptBlockData *const blockData);
void SetInductionVariableValueNumbers(GlobOptBlockData *const blockData);
void FinalizeInductionVariables(Loop *const loop, GlobOptBlockData *const headerData);
void InvalidateInductionVariables(IR::Instr * instr);
enum class SymBoundType {OFFSET, VALUE, UNKNOWN};
SymBoundType DetermineSymBoundOffsetOrValueRelativeToLandingPad(StackSym *const sym, const bool landingPadValueIsLowerBound, ValueInfo *const valueInfo, const IntBounds *const bounds, GlobOptBlockData *const landingPadGlobOptBlockData, int *const boundOffsetOrValueRef);

Expand Down
24 changes: 24 additions & 0 deletions lib/Backend/GlobOptIntBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 1262,30 @@ void GlobOpt::FinalizeInductionVariables(Loop *const loop, GlobOptBlockData *con
}
}

void
GlobOpt::InvalidateInductionVariables(IR::Instr * instr)
{
Assert(instr->GetDst() != nullptr && instr->GetDst()->IsRegOpnd());

// Induction variables are always var syms.
StackSym * dstSym = instr->GetDst()->AsRegOpnd()->m_sym;
if (!dstSym->IsVar())
{
dstSym = dstSym->GetVarEquivSym(this->func);
}

// If this is an induction variable, then treat it the way the prepass would have if it had seen
// the assignment and the resulting change to the value number, and mark it as indeterminate.
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
{
InductionVariable *iv = nullptr;
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
{
iv->SetChangeIsIndeterminate();
}
}
}

GlobOpt::SymBoundType GlobOpt::DetermineSymBoundOffsetOrValueRelativeToLandingPad(
StackSym *const sym,
const bool landingPadValueIsLowerBound,
Expand Down
4 changes: 2 additions & 2 deletions lib/Backend/Inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,11 2089,11 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, const FunctionJITTimeInfo *
callInstr->m_opcode = inlineCallOpCode;
SetupInlineInstrForCallDirect(builtInFunctionId, callInstr, argoutInstr);

WrapArgsOutWithCoerse(builtInFunctionId, callInstr);

// Generate ByteCodeArgOutCaptures and move the ArgOut_A/ArgOut_A_Inline close to the call instruction
callInstr->MoveArgs(/*generateByteCodeCapture*/ true);

WrapArgsOutWithCoerse(builtInFunctionId, callInstr);

inlineBuiltInEndInstr = callInstr;
}
else
Expand Down
Loading