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
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-1022] Inline segment is passed to another array - Internal
  • Loading branch information
akroshg authored and MSLaguana committed May 8, 2018
commit 28928cba24968ed11022608f466c4ccc3470e64d
13 changes: 11 additions & 2 deletions lib/Runtime/Library/JavascriptArray.inl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 155,7 @@ namespace Js
DetermineInlineHeadSegmentPointer<T, InlinePropertySlots, false>(array);
if(wasZeroAllocated)
{
AssertOrFailFast(size <= SparseArraySegmentBase::INLINE_CHUNK_SIZE);
if(length != 0)
{
head->length = length;
Expand Down Expand Up @@ -238,6 239,14 @@ namespace Js
DetermineAllocationSize<className, inlineSlots>(length, &allocationPlusSize, &alignedInlineElementSlots);
}

// alignedInlineElementSlots is actually the 'size' of the segment. The size of the segment should not be greater than InlineHead segment limit, otherwise the inline
// segment may not be interpreted as inline segment if the length extends to the size.
// the size could increase because of allignment.
// Update the size so that it does not exceed SparseArraySegmentBase::INLINE_CHUNK_SIZE.

uint inlineChunkSize = SparseArraySegmentBase::INLINE_CHUNK_SIZE;
uint size = min(alignedInlineElementSlots, inlineChunkSize);

array = RecyclerNewPlusZ(recycler, allocationPlusSize, className, length, arrayType);

// An new array's head segment length is initialized to zero despite the array length being nonzero because the segment
Expand All @@ -250,9 259,9 @@ namespace Js
// a variable until it is fully initialized, there is no way for script code to use the array while it still has missing
// values.
SparseArraySegment<unitType> *head =
InitArrayAndHeadSegment<className, inlineSlots>(array, length, alignedInlineElementSlots, true);
InitArrayAndHeadSegment<className, inlineSlots>(array, length, size, true);

head->FillSegmentBuffer(length, alignedInlineElementSlots);
head->FillSegmentBuffer(length, size);

Assert(array->HasNoMissingValues());
return array;
Expand Down