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 1 commit
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
Prev Previous commit
Next Next commit
[CVE-2018-8137] Edge - chakra JIT array out of bound read/write vulne…
…rability lead to Remote Code Execution
  • Loading branch information
sigatrev authored and MSLaguana committed May 8, 2018
commit 6e362fe94bc4bba7c8b8c6f819c1bee94c51893c
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