Skip to content

Commit 6d5532d

Browse files
Thomas Moore (CHAKRA)akroshg
authored andcommitted
[CVE-2018-0933] Chakra: JIT - Incomplete Fix for MSRC-41913 - Google, Inc.
This change addresses a scenario where a deepCopy of a native array is needed when its head segment is already on the heap. In this case, it bypasses the previous fix because the head is on the stack and thus fails to do a deepCopy. The fix is to unconditionally reallocate both the array object and its segments when deepCopy is true.
1 parent 6d0f5de commit 6d5532d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11700,8 +11700,11 @@ namespace Js
1170011700
}
1170111701

1170211702
const size_t inlineSlotsSize = instance->GetTypeHandler()->GetInlineSlotsSize();
11703-
if (ThreadContext::IsOnStack(instance->head))
11703+
if (ThreadContext::IsOnStack(instance->head) || deepCopy)
1170411704
{
11705+
// Reallocate both the object as well as the head segment when the head is on the stack or
11706+
// when a deep copy is needed. This is to prevent a scenario where box may leave either one
11707+
// on the stack when both must be on the heap.
1170511708
boxedInstance = RecyclerNewPlusZ(instance->GetRecycler(),
1170611709
inlineSlotsSize + sizeof(Js::SparseArraySegmentBase) + instance->head->size * sizeof(typename T::TElement),
1170711710
T, instance, true, deepCopy);

0 commit comments

Comments
 (0)