Title: [260215] trunk/Source/WebKit
Revision
260215
Author
[email protected]
Date
2020-04-16 13:02:43 -0700 (Thu, 16 Apr 2020)

Log Message

REGRESSION(r260081) Broke iOS PLT due to InjectedBundle initialization (edit)
https://bugs.webkit.org/show_bug.cgi?id=210582
<rdar://problem/61838584>

Reviewed by Darin Adler.

The changes in r260081 began enforcing NSSecureCoding best practices, triggering
a bug in InjectedBundleMac.mm, which is used by iOS as well.

This patch does the following:

1. Delays parameter decoding until we use the appropriate InjectedBundle mechanism
   for expressing the valid classes to use in the Unarchiver.
2. Removes a temporary workaround needed to get PLT running on iOS again.

This patch also moves the check of the CFBundleGetFunctionPointerForName slightly earlier
so we can use a single function pointer check, and only invoke the parameter decoding
if we are using the C API.

If not, we delay parameter decoding until we have constructed the WKWebProcessPlugIn
object so we can consume it's 'additionalClassesForParameterCoder' before calling
its initialization method.

* WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
(WebKit::InjectedBundle::decodeBundleParameters): Remove temporary workaround
needed to get PLT working again. Instead of using a debug assert, return as
a decoding failure if the resulting object is not an NSDictionary.
(WebKit::InjectedBundle::initialize): Delay decoding the bundle parameters on
iOS until the Plugin's additionalClassesForParameterCoder method can be called.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260214 => 260215)


--- trunk/Source/WebKit/ChangeLog	2020-04-16 19:48:02 UTC (rev 260214)
+++ trunk/Source/WebKit/ChangeLog	2020-04-16 20:02:43 UTC (rev 260215)
@@ -1,3 +1,35 @@
+2020-04-16  Brent Fulgham  <[email protected]>
+
+        REGRESSION(r260081) Broke iOS PLT due to InjectedBundle initialization (edit)
+        https://bugs.webkit.org/show_bug.cgi?id=210582
+        <rdar://problem/61838584>
+
+        Reviewed by Darin Adler.
+
+        The changes in r260081 began enforcing NSSecureCoding best practices, triggering
+        a bug in InjectedBundleMac.mm, which is used by iOS as well.
+
+        This patch does the following:
+
+        1. Delays parameter decoding until we use the appropriate InjectedBundle mechanism
+           for expressing the valid classes to use in the Unarchiver.
+        2. Removes a temporary workaround needed to get PLT running on iOS again.
+
+        This patch also moves the check of the CFBundleGetFunctionPointerForName slightly earlier
+        so we can use a single function pointer check, and only invoke the parameter decoding
+        if we are using the C API.
+        
+        If not, we delay parameter decoding until we have constructed the WKWebProcessPlugIn
+        object so we can consume it's 'additionalClassesForParameterCoder' before calling
+        its initialization method.
+
+        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
+        (WebKit::InjectedBundle::decodeBundleParameters): Remove temporary workaround
+        needed to get PLT working again. Instead of using a debug assert, return as
+        a decoding failure if the resulting object is not an NSDictionary.
+        (WebKit::InjectedBundle::initialize): Delay decoding the bundle parameters on
+        iOS until the Plugin's additionalClassesForParameterCoder method can be called.
+
 2020-04-16  Daniel Bates  <[email protected]>
 
         [iOS] Add a way to focus a text input and place a caret

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm (260214 => 260215)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2020-04-16 19:48:02 UTC (rev 260214)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2020-04-16 20:02:43 UTC (rev 260215)
@@ -101,15 +101,13 @@
 
     NSDictionary *dictionary = nil;
     @try {
-#if PLATFORM(IOS_FAMILY)
-        dictionary = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"parameters"];
-        ASSERT([dictionary isKindOfClass:[NSDictionary class]]);
-#else
         dictionary = [unarchiver.get() decodeObjectOfClasses:classesForCoder() forKey:@"parameters"];
-#endif
-        ASSERT([dictionary isKindOfClass:[NSDictionary class]]);
+        if (![dictionary isKindOfClass:[NSDictionary class]]) {
+            WTFLogAlways("InjectedBundle::decodeBundleParameters failed - Resulting object was not an NSDictionary.\n");
+            return false;
+        }
     } @catch (NSException *exception) {
-        LOG_ERROR("Failed to decode bundle parameters: %@." , exception);
+        LOG_ERROR("InjectedBundle::decodeBundleParameters failed to decode bundle parameters: %@." , exception);
         return false;
     }
     
@@ -168,6 +166,9 @@
         }
     }
 
+    if (!initializeFunction)
+        initializeFunction = bitwise_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName([m_platformBundle _cfBundle], CFSTR("WKBundleInitialize")));
+
     if (!additionalClassesForParameterCoderFunction)
         additionalClassesForParameterCoderFunction = bitwise_cast<WKBundleAdditionalClassesForParameterCoderFunctionPtr>(CFBundleGetFunctionPointerForName([m_platformBundle _cfBundle], CFSTR("WKBundleAdditionalClassesForParameterCoder")));
 
@@ -175,19 +176,16 @@
     if (additionalClassesForParameterCoderFunction)
         additionalClassesForParameterCoderFunction(toAPI(this), toAPI(initializationUserData));
 
-    decodeBundleParameters(parameters.bundleParameterData.get());
-    
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     // Swizzle [NSEvent modiferFlags], since it always returns 0 when the WindowServer is blocked.
     Method method = class_getClassMethod([NSEvent class], @selector(modifierFlags));
     method_setImplementation(method, reinterpret_cast<IMP>(currentModifierFlags));
 #endif
-    
-    if (!initializeFunction)
-        initializeFunction = bitwise_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName([m_platformBundle _cfBundle], CFSTR("WKBundleInitialize")));
 
     // First check to see if the bundle has a WKBundleInitialize function.
     if (initializeFunction) {
+        if (!decodeBundleParameters(parameters.bundleParameterData.get()))
+            return false;
         initializeFunction(toAPI(this), toAPI(initializationUserData));
         return true;
     }
@@ -213,11 +211,12 @@
     WKWebProcessPlugInController* plugInController = WebKit::wrapper(*this);
     [plugInController _setPrincipalClassInstance:instance];
 
-    if ([instance respondsToSelector:@selector(additionalClassesForParameterCoder)]) {
+    if ([instance respondsToSelector:@selector(additionalClassesForParameterCoder)])
         [plugInController extendClassesForParameterCoder:[instance additionalClassesForParameterCoder]];
-        decodeBundleParameters(parameters.bundleParameterData.get());
-    }
 
+    if (!decodeBundleParameters(parameters.bundleParameterData.get()))
+        return false;
+
     if ([instance respondsToSelector:@selector(webProcessPlugIn:initializeWithObject:)]) {
         RetainPtr<id> objCInitializationUserData;
         if (initializationUserData && initializationUserData->type() == API::Object::Type::ObjCObjectGraph)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to