Title: [273692] trunk/Source/WebCore
Revision
273692
Author
[email protected]
Date
2021-03-01 14:29:17 -0800 (Mon, 01 Mar 2021)

Log Message

Protect AudioWorkletGlobalScope::registerProcessor() against re-entry
https://bugs.webkit.org/show_bug.cgi?id=222567
<rdar://74860464>

Reviewed by Eric Carlson.

AudioWorkletGlobalScope::registerProcessor() checks if 'name' is in m_processorConstructorMap
then does some checks that potentially run JS and thus call registerProcessor() again (potentially
with the same name). To address this, we now check the map again after potentially running the
JS code.

* Modules/webaudio/AudioWorkletGlobalScope.cpp:
(WebCore::AudioWorkletGlobalScope::registerProcessor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273691 => 273692)


--- trunk/Source/WebCore/ChangeLog	2021-03-01 22:02:30 UTC (rev 273691)
+++ trunk/Source/WebCore/ChangeLog	2021-03-01 22:29:17 UTC (rev 273692)
@@ -1,3 +1,19 @@
+2021-03-01  Chris Dumez  <[email protected]>
+
+        Protect AudioWorkletGlobalScope::registerProcessor() against re-entry
+        https://bugs.webkit.org/show_bug.cgi?id=222567
+        <rdar://74860464>
+
+        Reviewed by Eric Carlson.
+
+        AudioWorkletGlobalScope::registerProcessor() checks if 'name' is in m_processorConstructorMap
+        then does some checks that potentially run JS and thus call registerProcessor() again (potentially
+        with the same name). To address this, we now check the map again after potentially running the
+        JS code.
+
+        * Modules/webaudio/AudioWorkletGlobalScope.cpp:
+        (WebCore::AudioWorkletGlobalScope::registerProcessor):
+
 2021-03-01  Martin Robinson  <[email protected]>
 
         Scroll snapping doesn't kick in when dragging scrollbars

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp (273691 => 273692)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2021-03-01 22:02:30 UTC (rev 273691)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2021-03-01 22:29:17 UTC (rev 273692)
@@ -82,13 +82,13 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (!jsConstructor->isConstructor(vm))
-        return Exception { TypeError, "Class definitition passed to registerProcessor() is not a constructor"_s };
+        return Exception { TypeError, "Class definition passed to registerProcessor() is not a constructor"_s };
 
     auto prototype = jsConstructor->getPrototype(vm, globalObject);
     RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
 
     if (!prototype.isObject())
-        return Exception { TypeError, "Class definitition passed to registerProcessor() has invalid prototype"_s };
+        return Exception { TypeError, "Class definition passed to registerProcessor() has invalid prototype"_s };
 
     auto parameterDescriptorsValue = jsConstructor->get(globalObject, JSC::Identifier::fromString(vm, "parameterDescriptors"));
     RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
@@ -110,8 +110,12 @@
         }
     }
 
-    m_processorConstructorMap.add(name, WTFMove(processorContructor));
+    auto addResult = m_processorConstructorMap.add(name, WTFMove(processorContructor));
 
+    // We've already checked at the beginning of this function but then we ran some JS so we need to check again.
+    if (!addResult.isNewEntry)
+        return Exception { NotSupportedError, "A processor was already registered with this name"_s };
+
     thread().messagingProxy().postTaskToAudioWorklet([name = name.isolatedCopy(), parameterDescriptors = crossThreadCopy(parameterDescriptors)](AudioWorklet& worklet) mutable {
         ASSERT(isMainThread());
         if (auto* audioContext = worklet.audioContext())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to