Skip to content

Commit 473286e

Browse files
committed
[MERGE #6420 @boingoing] ChakraCore Servicing Update for 2020.04B
Merge pull request #6420 from boingoing:servicing_2004_b ChakraCore Servicing Update for 2020.04B Changes to address the following issues: [CVE-2020-0970] [CVE-2020-0969]
2 parents 9298227 + d75b21c commit 473286e

9 files changed

+65
-20
lines changed

Diff for: Build/NuGet/.pack-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.11.17
1+
1.11.18

Diff for: lib/Common/ChakraCoreVersion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// ChakraCore version number definitions (used in ChakraCore binary metadata)
1818
#define CHAKRA_CORE_MAJOR_VERSION 1
1919
#define CHAKRA_CORE_MINOR_VERSION 11
20-
#define CHAKRA_CORE_PATCH_VERSION 17
20+
#define CHAKRA_CORE_PATCH_VERSION 18
2121
#define CHAKRA_CORE_VERSION_RELEASE_QFE 0 // Redundant with PATCH_VERSION. Keep this value set to 0.
2222

2323
// -------------

Diff for: lib/Runtime/ByteCode/ByteCodeEmitter.cpp

+37-15
Original file line numberDiff line numberDiff line change
@@ -4262,21 +4262,33 @@ void ByteCodeGenerator::EmitLoadInstance(Symbol *sym, IdentPtr pid, Js::RegSlot
42624262
funcInfo->FindOrAddReferencedPropertyId(propertyId),
42634263
envIndex + Js::FrameDisplay::GetOffsetOfScopes() / sizeof(Js::Var));
42644264

4265-
Js::RegSlot tmpReg = funcInfo->AcquireTmpRegister();
4266-
42674265
AssertOrFailFast(scope->GetIsObject());
4268-
this->m_writer.SlotI1(Js::OpCode::LdEnvObj, tmpReg,
4269-
envIndex + Js::FrameDisplay::GetOffsetOfScopes() / sizeof(Js::Var));
4270-
4271-
Js::OpCode op = unwrapWithObj ? Js::OpCode::UnwrapWithObj : Js::OpCode::Ld_A;
42724266

4273-
this->m_writer.Reg2(op, instLocation, tmpReg);
4274-
if (thisLocation != Js::Constants::NoRegister)
4267+
if (unwrapWithObj)
42754268
{
4276-
this->m_writer.Reg2(op, thisLocation, tmpReg);
4269+
Js::RegSlot tmpReg = funcInfo->AcquireTmpRegister();
4270+
4271+
this->m_writer.SlotI1(Js::OpCode::LdEnvObj, tmpReg,
4272+
envIndex + Js::FrameDisplay::GetOffsetOfScopes() / sizeof(Js::Var));
4273+
4274+
this->m_writer.Reg2(Js::OpCode::UnwrapWithObj, instLocation, tmpReg);
4275+
if (thisLocation != Js::Constants::NoRegister)
4276+
{
4277+
this->m_writer.Reg2(Js::OpCode::UnwrapWithObj, thisLocation, tmpReg);
4278+
}
4279+
4280+
funcInfo->ReleaseTmpRegister(tmpReg);
42774281
}
4282+
else
4283+
{
4284+
this->m_writer.SlotI1(Js::OpCode::LdEnvObj, instLocation,
4285+
envIndex + Js::FrameDisplay::GetOffsetOfScopes() / sizeof(Js::Var));
42784286

4279-
funcInfo->ReleaseTmpRegister(tmpReg);
4287+
if (thisLocation != Js::Constants::NoRegister)
4288+
{
4289+
this->m_writer.Reg2(Js::OpCode::Ld_A, thisLocation, funcInfo->undefinedConstantRegister);
4290+
}
4291+
}
42804292
}
42814293
else if (scopeLocation != Js::Constants::NoRegister && scopeLocation == funcInfo->frameObjRegister)
42824294
{
@@ -4288,19 +4300,29 @@ void ByteCodeGenerator::EmitLoadInstance(Symbol *sym, IdentPtr pid, Js::RegSlot
42884300
this->m_writer.Reg1(Js::OpCode::LdLocalObj, instLocation);
42894301
if (thisLocation != Js::Constants::NoRegister)
42904302
{
4291-
this->m_writer.Reg1(Js::OpCode::LdLocalObj, thisLocation);
4303+
this->m_writer.Reg2(Js::OpCode::Ld_A, thisLocation, funcInfo->undefinedConstantRegister);
42924304
}
42934305
}
42944306
else
42954307
{
42964308
this->m_writer.BrProperty(Js::OpCode::BrOnNoProperty, nextLabel, scopeLocation,
42974309
funcInfo->FindOrAddReferencedPropertyId(propertyId));
42984310

4299-
Js::OpCode op = unwrapWithObj ? Js::OpCode::UnwrapWithObj : Js::OpCode::Ld_A;
4300-
this->m_writer.Reg2(op, instLocation, scopeLocation);
4301-
if (thisLocation != Js::Constants::NoRegister)
4311+
if (unwrapWithObj)
43024312
{
4303-
this->m_writer.Reg2(op, thisLocation, scopeLocation);
4313+
this->m_writer.Reg2(Js::OpCode::UnwrapWithObj, instLocation, scopeLocation);
4314+
if (thisLocation != Js::Constants::NoRegister)
4315+
{
4316+
this->m_writer.Reg2(Js::OpCode::UnwrapWithObj, thisLocation, scopeLocation);
4317+
}
4318+
}
4319+
else
4320+
{
4321+
this->m_writer.Reg2(Js::OpCode::Ld_A, instLocation, scopeLocation);
4322+
if (thisLocation != Js::Constants::NoRegister)
4323+
{
4324+
this->m_writer.Reg2(Js::OpCode::Ld_A, thisLocation, funcInfo->undefinedConstantRegister);
4325+
}
43044326
}
43054327
}
43064328

Diff for: lib/Runtime/Language/JavascriptOperators.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2072,8 +2072,7 @@ using namespace Js;
20722072
// HasProperty will call UnscopablesWrapperObject's HasProperty which will do the filtering
20732073
// All we have to do here is unwrap the object hence the api call
20742074

2075-
*thisVar = obj->GetThisObjectOrUnWrap();
2076-
return *thisVar;
2075+
return obj->GetThisAndUnwrappedInstance(thisVar);
20772076
}
20782077
}
20792078

Diff for: lib/Runtime/Types/PathTypeHandler.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,16 @@ namespace Js
20132013
{
20142014
newSetters = this->UpdateSetterSlots(recycler, oldSetters, oldPathSize, newTypePath->GetPathSize());
20152015
}
2016+
2017+
#if ENABLE_FIXED_FIELDS
2018+
#ifdef SUPPORT_FIXED_FIELDS_ON_PATH_TYPES
2019+
if (PathTypeHandlerBase::FixPropsOnPathTypes())
2020+
{
2021+
Assert(this->HasSingletonInstanceOnlyIfNeeded());
2022+
this->GetTypePath()->ClearSingletonInstanceIfSame(instance);
2023+
}
2024+
#endif
2025+
#endif
20162026
}
20172027
else if (growing)
20182028
{

Diff for: lib/Runtime/Types/RecyclableObject.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ namespace Js
331331
return this;
332332
}
333333

334+
RecyclableObject* RecyclableObject::GetThisAndUnwrappedInstance(Var* thisVar) const
335+
{
336+
*thisVar = this->GetLibrary()->GetUndefined();
337+
return (RecyclableObject*)this;
338+
}
339+
334340
// In order to avoid a branch, every object has an entry point if it gets called like a
335341
// function - however, if it can't be called like a function, it's set to DefaultEntryPoint
336342
// which will emit an error.

Diff for: lib/Runtime/Types/RecyclableObject.h

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ namespace Js {
353353
virtual uint GetSpecialPropertyCount() const { return 0; }
354354
virtual PropertyId const * GetSpecialPropertyIds() const { return nullptr; }
355355
virtual RecyclableObject* GetThisObjectOrUnWrap(); // Due to the withScope object there are times we need to unwrap
356+
virtual RecyclableObject* GetThisAndUnwrappedInstance(Var* thisVar) const;
356357

357358
virtual BOOL HasInstance(Var instance, ScriptContext* scriptContext, IsInstInlineCache* inlineCache = NULL);
358359

Diff for: lib/Runtime/Types/UnscopablesWrapperObject.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ namespace Js
2323
return static_cast<UnscopablesWrapperObject*>(aValue);
2424
}
2525

26+
RecyclableObject * UnscopablesWrapperObject::GetThisAndUnwrappedInstance(Var* thisVar) const
27+
{
28+
*thisVar = this->GetWrappedObject();
29+
return this->GetWrappedObject();
30+
}
31+
2632
PropertyQueryFlags UnscopablesWrapperObject::HasPropertyQuery(PropertyId propertyId, _Inout_opt_ PropertyValueInfo* info)
2733
{
2834
return JavascriptConversion::BooleanToPropertyQueryFlags(JavascriptOperators::HasPropertyUnscopables(wrappedObject, propertyId));

Diff for: lib/Runtime/Types/UnscopablesWrapperObject.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace Js
2828
static bool Is(Var aValue);
2929
static UnscopablesWrapperObject* FromVar(Var value);
3030
static UnscopablesWrapperObject* UnsafeFromVar(Var value);
31-
RecyclableObject *GetWrappedObject() { return wrappedObject; }
31+
RecyclableObject *GetWrappedObject() const { return wrappedObject; }
32+
virtual RecyclableObject* GetThisAndUnwrappedInstance(Var* thisVar) const override;
3233
virtual PropertyQueryFlags HasPropertyQuery(PropertyId propertyId, _Inout_opt_ PropertyValueInfo* info) override;
3334
virtual BOOL HasOwnProperty(PropertyId propertyId) override;
3435
virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;

0 commit comments

Comments
 (0)