Skip to content

Commit 1b62fe7

Browse files
committed
[1.11>master] [MERGE #6447 @rajeshpeter] ChakraCore Servicing Update for 2020.05B
Merge pull request #6447 from rajeshpeter:servicing/2005 **Changes to address the following issues:** **[CVE-2020-1037]** Ensure JIT bails out when there is an object marked as temporary during an implicit call, to prevent objects stored on the stack to be used outside of the function. This is done by preventing removal of the Bailout instruction for that case during the DeadStore pass of GlobOpt. **[CVE-2020-1065]** A previous MSRC fix removes the body scope of an enclosing function when a nested function is declared in the param scope of that enclosing function. This an result in us calculating incorrect envIndex for any symbols captured from enclosing scopes if this skipped body scope appears in the frameDisplay being passed to the nested function. This fix addresses the issue by marking the parameter scope also as mustInstantiate = true so we end up computing the correct envIndex. This problem and the fix only triggers when the enclosing function's param and body scopes are merged so the param and body scopes will never appear together in the scope stack and as such will not mess up the envIndex.
2 parents cf66462 + 5ed2985 commit 1b62fe7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Backend/GlobOptBailOut.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ GlobOpt::IsImplicitCallBailOutCurrentlyNeeded(IR::Instr * instr, Value const * s
13881388
NeedBailOnImplicitCallForCSE(block, isForwardPass) ||
13891389
NeedBailOnImplicitCallWithFieldOpts(block->loop, hasLiveFields) ||
13901390
NeedBailOnImplicitCallForArrayCheckHoist(block, isForwardPass) ||
1391+
(instr->HasBailOutInfo() && (instr->GetBailOutKind() & IR::BailOutMarkTempObject) != 0) ||
13911392
mayNeedLazyBailOut
13921393
) &&
13931394
(!instr->HasTypeCheckBailOut() && MayNeedBailOnImplicitCall(instr, src1Val, src2Val)))

lib/Runtime/ByteCode/ScopeInfo.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,23 @@ namespace Js
196196
ScopeInfo * scopeInfo = ScopeInfo::SaveScopeInfo(byteCodeGenerator, currentScope, byteCodeGenerator->GetScriptContext());
197197
if (scopeInfo != nullptr)
198198
{
199+
if (funcInfo->root->IsDeclaredInParamScope())
200+
{
201+
FuncInfo* func = byteCodeGenerator->GetEnclosingFuncInfo();
202+
Assert(func);
203+
204+
if (func->IsBodyAndParamScopeMerged())
205+
{
206+
Assert(currentScope == func->GetParamScope() && currentScope->GetScopeType() == ScopeType_Parameter);
207+
Assert(scopeInfo->GetScopeType() == ScopeType_Parameter);
208+
Assert(func->GetBodyScope());
209+
210+
// If the current function is nested in the param scope of it's enclosing function we may have
211+
// skipped the body scope and in may not be the scope stack but the body scope might still be
212+
// in the frame display and we will need to account for it. See ByteCodeGenerateor::FindScopeForSym.
213+
scopeInfo->mustInstantiate = func->GetBodyScope()->GetMustInstantiate();
214+
}
215+
}
199216
funcInfo->byteCodeFunction->SetScopeInfo(scopeInfo);
200217
}
201218
}

0 commit comments

Comments
 (0)