Skip to content

Commit 5db4492

Browse files
Raymond Toymibrunin
authored andcommitted
[Backport] CVE-2021-30522: Use after free in WebAudio
Cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/2874771: Add AudioHandler to orphan handlers when context is suspended. If the context is suspended, pulling of the audio graph is stopped. But we still need to add the handler in this case so that when the context is resumed, the handler is still alive until it can be safely removed. Hence, we must still add the handler if the context is suspended. Test cases from issue 1176218 manually tested with no failures. Also this doesn't cause any regressions in issue 1003807 and issue 1017961. (Manually tested the test cases from those issues.) Bug: 1176218 Change-Id: Icd927c488505dfee9ff716866f98286e286d546a Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Raymond Toy <rtoy@chromium.org> Cr-Commit-Position: refs/heads/master@{#881533} Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
1 parent 0b959ee commit 5db4492

File tree

1 file changed

+6
-6
lines changed
  • chromium/third_party/blink/renderer/modules/webaudio

1 file changed

+6
-6
lines changed

chromium/third_party/blink/renderer/modules/webaudio/audio_node.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,13 @@ void AudioNode::Dispose() {
609609
BaseAudioContext::GraphAutoLocker locker(context());
610610
Handler().Dispose();
611611

612-
// Add the handler to the orphan list if the context is pulling on the audio
613-
// graph. This keeps the handler alive until it can be deleted at a safe
614-
// point (in pre/post handler task). If graph isn't being pulled, we can
615-
// delete the handler now since nothing on the audio thread will be touching
616-
// it.
612+
// Add the handler to the orphan list. This keeps the handler alive until it
613+
// can be deleted at a safe point (in pre/post handler task). If the graph is
614+
// being processed, the handler must be added. If the context is suspended,
615+
// the handler still needs to be added in case the context is resumed.
617616
DCHECK(context());
618-
if (context()->IsPullingAudioGraph()) {
617+
if (context()->IsPullingAudioGraph() ||
618+
context()->ContextState() == BaseAudioContext::kSuspended) {
619619
context()->GetDeferredTaskHandler().AddRenderingOrphanHandler(
620620
std::move(handler_));
621621
}

0 commit comments

Comments
 (0)