Fix out-of-bounds read in blendLineCoverageMaskAvx2 - #592
Open
Graveflo wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FYI
Summary
blendLineCoverageMaskAvx2advances 32 pixels per iteration but guards the loopwith
i < len - 16. An iteration can therefore start within 32 pixels of theend and read 32 coverage bytes from a buffer holding only
len, then blend andstore up to 16 pixels past the end of the coverage run.
Any
MaskBlendfill whose path is wide enough to reach the vector loop can hitit.
Context.clipusesMaskBlendfor every clip after the first, so this isreachable from ordinary Canvas2D code.
Reproduction
Without a sanitizer the read lands on readable heap and the damage is visible
only as a few stray pixels past the right end of each scanline's coverage run —
which is why it has gone unnoticed.
The width that triggers it depends on where the 32-byte alignment prologue
leaves the index, so a single width is not a reliable reproduction.