Repository navigation
src: fix SAB race in transcode and StringDecoder - #67647
Open
christianaurichzm wants to merge 1 commit into
Open
christianaurichzm wants to merge 1 commit into
christianaurichzm wants to merge 1 commit into
Conversation
buffer.transcode() and StringDecoder read SharedArrayBuffer-backed input in place, and their UTF-8/UTF-16 conversions size the output in one pass and fill it in another. A write from another thread in between makes them write past the end of the output. Copy shared input first, as StringSlice() and DecodeUTF8() already do. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67647 +/- ##
==========================================
+ Coverage 90.67% 90.72% +0.05%
==========================================
Files 800 801 +1
Lines 280932 280932
Branches 54285 54268 -17
==========================================
+ Hits 254731 254876 +145
+ Misses 16309 16247 -62
+ Partials 9892 9809 -83
🚀 New features to boost your workflow:
|
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.
StringDecoderandbuffer.transcode()can write past the end of their output if another thread changes theSharedArrayBufferthey're reading.Both read the memory in place, and their UTF-8/UTF-16 conversions size the output in one pass and fill it in another.
StringDecodergets there throughStringBytes::Encode()for UTF-8 input over 1 MiB, where theCHECK_EQabove only runs after the write.transcode()between UTF-8 and UTF-16LE has no check and ends in aSIGSEGVor a corrupted heap. This copies shared input first, as #63517 did forStringSlice()andDecodeUTF8().Refs: #63517