-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use-after-free in WebCore::AudioBufferSourceNode::renderFromBuffer
https://bugs.webkit.org/show_bug.cgi?id=270007 rdar://123510096 Reviewed by Jer Noble and Geoffrey Garen. JS sets the AudioBufferSourceNode.buffer attribute on the main thread. This buffer is then used on the audio thread for rendering. We were attempting to synchronize the threads via m_processLock. However, this only synchronizes the audio thread with AudioBufferSourceNode::setBuffer(). The JS could still modify the buffer's contents on the main thread via locking. Since the buffer's channels are backed by JS ArrayBuffers, the JS could even detach/transfer them. This could lead to use-after-free on the audio rendering thread when the JS does so. To address the issue, we improve the "acquire the buffer content" logic in the specification [1] When the buffer gets set and the node is already playing, or when the node starts playing, we copy the contents of the buffer provided by JS into m_outputChannels. The audio thread now only ever interacts with the copy in m_outputChannels. This is not as good performance-wise but it is needed for thread-safety. [1] https://webaudio.github.io/web-audio-api/#acquire-the-content * Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp: (WebCore::AudioBufferSourceNode::process): (WebCore::AudioBufferSourceNode::renderFromBuffer): (WebCore::AudioBufferSourceNode::setBufferForBindings): (WebCore::AudioBufferSourceNode::acquireBufferContent): (WebCore::AudioBufferSourceNode::startPlaying): (WebCore::AudioBufferSourceNode::adjustGrainParameters): (WebCore::AudioBufferSourceNode::totalPitchRate): (WebCore::AudioBufferSourceNode::propagatesSilence const): * Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h: Canonical link: https://commits.webkit.org/272448.614@safari-7618-branch
- Loading branch information
Showing
2 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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