Skip to content

Commit a278643

Browse files
paolosevMSFTThomas Moore (CHAKRA)
authored andcommitted
[CVE-2018-8473] Edge - Chakra: Stack corruption in the presence of nested inlinees
In the presence of nested inlined functions, jitted code can bail out to the wrong function. This fix disables the inline-args-optimization when it detects that the value of the functionObject symbol for an inlinee has changed between its InlineeStart and its InlineeEnd.
1 parent 4d71463 commit a278643

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Backend/GlobOptBailOut.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,8 @@ GlobOpt::TrackCalls(IR::Instr * instr)
583583
instr->m_func->m_hasInlineArgsOpt = true;
584584
InlineeFrameInfo* frameInfo = InlineeFrameInfo::New(func->m_alloc);
585585
instr->m_func->frameInfo = frameInfo;
586+
frameInfo->functionSymStartValue = instr->GetSrc1()->GetSym() ?
587+
CurrentBlockData()->FindValue(instr->GetSrc1()->GetSym()) : nullptr;
586588
frameInfo->floatSyms = CurrentBlockData()->liveFloat64Syms->CopyNew(this->alloc);
587589
frameInfo->intSyms = CurrentBlockData()->liveInt32Syms->MinusNew(CurrentBlockData()->liveLossyInt32Syms, this->alloc);
588590
frameInfo->varSyms = CurrentBlockData()->liveVarSyms->CopyNew(this->alloc);
@@ -762,6 +764,15 @@ void GlobOpt::RecordInlineeFrameInfo(IR::Instr* inlineeEnd)
762764
}
763765
else
764766
{
767+
// If the value of the functionObject symbol has changed between the inlineeStart and the inlineeEnd,
768+
// we don't record the inlinee frame info (see OS#18318884).
769+
Assert(frameInfo->functionSymStartValue != nullptr);
770+
if (!frameInfo->functionSymStartValue->IsEqualTo(CurrentBlockData()->FindValue(functionObject->m_sym)))
771+
{
772+
argInstr->m_func->DisableCanDoInlineArgOpt();
773+
return true;
774+
}
775+
765776
frameInfo->function = InlineFrameInfoValue(functionObject->m_sym);
766777
}
767778
}

lib/Backend/InlineeFrameInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#pragma once
77

8+
class Value;
9+
810
struct BailoutConstantValue {
911
public:
1012
void InitIntConstValue(int32 value) { this->type = TyInt32; this->u.intConst.value = (IntConstType)value; };
@@ -150,6 +152,7 @@ struct InlineeFrameInfo
150152
BVSparse<JitArenaAllocator>* floatSyms;
151153
BVSparse<JitArenaAllocator>* intSyms;
152154
BVSparse<JitArenaAllocator>* varSyms;
155+
Value* functionSymStartValue;
153156

154157
bool isRecorded;
155158

0 commit comments

Comments
 (0)