Changeset 263570 in webkit


Ignore:
Timestamp:
Jun 26, 2020 10:37:25 AM (4 years ago)
Author:
Chris Dumez
Message:

[iOS] Network process is crashing when launching TJMaxx app due to invalid NetworkProcess::DestroySession IPC message
https://bugs.webkit.org/show_bug.cgi?id=213625
<rdar://problem/64737890>

Reviewed by Alex Christensen.

The app is calling [WKWebsiteDataStore init] despite the method being marked as unavailable in
WKWebsiteDataStore.h. As a result, they end up with a WKWebsiteDataStore object whose internal
_websiteDataStore is bad because its constructor was never called. When [WKWebsiteDataStore dealloc]
gets called later own, it calls the ~WebsiteDataStore() destructor for _websiteDataStore but its
m_sessionID is 0 because we never called the constructor. This causes us to send a
NetworkProcess::DestroySession IPC with a sessionID that is 0, which is not valid so the
NetworkProcess crashes.

To address the issue, we now provide an implementation of [WKWebsiteDataStore init] which raises an
exception, behind a linked-on-after check. To keep the app working, [WKWebsiteDataStore init] returns
a new ephemeral data store until rebuilt with the new SDK.

  • UIProcess/API/Cocoa/WKWebsiteDataStore.h:

Mark "new" as unavailable, otherwise [WKWebsiteDataStore new] builds.

  • UIProcess/API/Cocoa/WKWebsiteDataStore.mm:

(-[WKWebsiteDataStore init]):
Raise an exception with latest SDK, a new ephemeral data store otherwise.

  • UIProcess/Cocoa/VersionChecks.h:

Add linked-on-after check.

  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::~WebsiteDataStore):
Add a release assertion to make sure that m_sessionID is always valid when the destructor is called.

Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r263568 r263570  
     12020-06-26  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Network process is crashing when launching TJMaxx app due to invalid NetworkProcess::DestroySession IPC message
     4        https://bugs.webkit.org/show_bug.cgi?id=213625
     5        <rdar://problem/64737890>
     6
     7        Reviewed by Alex Christensen.
     8
     9        The app is calling [WKWebsiteDataStore init] despite the method being marked as unavailable in
     10        WKWebsiteDataStore.h. As a result, they end up with a WKWebsiteDataStore object whose internal
     11        _websiteDataStore is bad because its constructor was never called. When [WKWebsiteDataStore dealloc]
     12        gets called later own, it calls the ~WebsiteDataStore() destructor for _websiteDataStore but its
     13        m_sessionID is 0 because we never called the constructor. This causes us to send a
     14        NetworkProcess::DestroySession IPC with a sessionID that is 0, which is not valid so the
     15        NetworkProcess crashes.
     16
     17        To address the issue, we now provide an implementation of [WKWebsiteDataStore init] which raises an
     18        exception, behind a linked-on-after check. To keep the app working, [WKWebsiteDataStore init] returns
     19        a new ephemeral data store until rebuilt with the new SDK.
     20
     21        * UIProcess/API/Cocoa/WKWebsiteDataStore.h:
     22        Mark "new" as unavailable, otherwise [WKWebsiteDataStore new] builds.
     23
     24        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
     25        (-[WKWebsiteDataStore init]):
     26        Raise an exception with latest SDK, a new ephemeral data store otherwise.
     27
     28        * UIProcess/Cocoa/VersionChecks.h:
     29        Add linked-on-after check.
     30
     31        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     32        (WebKit::WebsiteDataStore::~WebsiteDataStore):
     33        Add a release assertion to make sure that m_sessionID is always valid when the destructor is called.
     34
    1352020-06-26  Stephan Szabo  <stephan.szabo@sony.com>
    236
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h

    r263547 r263570  
    4848+ (WKWebsiteDataStore *)nonPersistentDataStore;
    4949
     50- (instancetype)new NS_UNAVAILABLE;
    5051- (instancetype)init NS_UNAVAILABLE;
    5152
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm

    r263547 r263570  
    3131#import "CompletionHandlerCallChecker.h"
    3232#import "ShouldGrandfatherStatistics.h"
     33#import "VersionChecks.h"
    3334#import "WKHTTPCookieStoreInternal.h"
    3435#import "WKNSArray.h"
     
    116117}
    117118
     119- (instancetype)init
     120{
     121    if (WebKit::linkedOnOrAfter(WebKit::SDKVersion::FirstWithWKWebsiteDataStoreInitReturningNil))
     122        [NSException raise:NSGenericException format:@"Calling [WKWebsiteDataStore init] is not supported."];
     123   
     124    if (!(self = [super init]))
     125        return nil;
     126
     127    RELEASE_LOG_ERROR(Storage, "Application is calling [WKWebsiteDataStore init], which is not supported");
     128    API::Object::constructInWrapper<WebKit::WebsiteDataStore>(self, WebKit::WebsiteDataStoreConfiguration::create(WebKit::IsPersistent::No), PAL::SessionID::generateEphemeralSessionID());
     129
     130    return self;
     131}
     132
    118133- (void)dealloc
    119134{
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r263547 r263570  
    9595    FirstThatSendsNativeMouseEvents = DYLD_IOS_VERSION_13_4,
    9696    FirstWithInitializeWebKit2MainThreadAssertion = DYLD_IOS_VERSION_14_0,
     97    FirstWithWKWebsiteDataStoreInitReturningNil = DYLD_IOS_VERSION_14_0,
    9798#elif PLATFORM(MAC)
    9899    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     
    108109    FirstWithSessionCleanupByDefault = DYLD_MACOS_VERSION_FIRST_WITH_SESSION_CLEANUP_BY_DEFAULT,
    109110    FirstWithInitializeWebKit2MainThreadAssertion = DYLD_MACOSX_VERSION_10_16,
     111    FirstWithWKWebsiteDataStoreInitReturningNil = DYLD_MACOSX_VERSION_10_16,
    110112#endif
    111113};
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r263568 r263570  
    125125{
    126126    ASSERT(RunLoop::isMain());
     127    RELEASE_ASSERT(m_sessionID.isValid());
    127128
    128129    platformDestroy();
Note: See TracChangeset for help on using the changeset viewer.