Changeset 150537 in webkit


Ignore:
Timestamp:
May 22, 2013 1:50:44 PM (11 years ago)
Author:
ap@apple.com
Message:

Crashes in NetworkProcess due to incorrect private browsing session tracking
https://bugs.webkit.org/show_bug.cgi?id=116628

Reviewed by Brady Eidson.

The current API for private browsing makes it extremely difficult to track sessions.
Private browsing is enabled via WKPreferences, but the session is shared, so it
has to be maintained while there is any chance that any page group anywhere still
needs it.

This patch fixes some of the issues, but ultimately, I think that we'll just need
to deprecate and replace the API.

  • NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::storageSession): There are valid scenarios where privateBrowsingEnabled is true, but there is no private browsing session. Handle that without crashing, although this unfortunately means that it will be harder to spot logic errors when using a wrong session. (WebKit::NetworkConnectionToWebProcess::registerBlobURL): Removed an obsolete FIXME.
  • NetworkProcess/mac/RemoteNetworkingContext.h: Changed privateBrowsingSession() to return a pointer, as no caller could know when it was safe to call it.
  • NetworkProcess/mac/RemoteNetworkingContext.mm: (WebKit::RemoteNetworkingContext::storageSession): Handle the case where private browsing session is unexpectedly missing without crashing. (WebKit::RemoteNetworkingContext::privateBrowsingSession): Changed to return a pointer.
  • UIProcess/WebContext.cpp: (WebKit::WebContext::ensureNetworkProcess): Actually initialize privateBrowsingEnabled creation parameter. It would be very difficult to figure out 100% reliably whether NetworkProcess needs a private browsing session with the current API, but for existing clients, looking at m_privateBrowsingEnterCount is good enough. Certainly better than not initializing.
  • WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::setPrivateBrowsingEnabled): Added a FIXME.
Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r150532 r150537  
     12013-05-22  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Crashes in NetworkProcess due to incorrect private browsing session tracking
     4        https://bugs.webkit.org/show_bug.cgi?id=116628
     5
     6        Reviewed by Brady Eidson.
     7
     8        The current API for private browsing makes it extremely difficult to track sessions.
     9        Private browsing is enabled via WKPreferences, but the session is shared, so it
     10        has to be maintained while there is any chance that any page group anywhere still
     11        needs it.
     12
     13        This patch fixes some of the issues, but ultimately, I think that we'll just need
     14        to deprecate and replace the API.
     15
     16        * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::storageSession):
     17        There are valid scenarios where privateBrowsingEnabled is true, but there is no
     18        private browsing session. Handle that without crashing, although this unfortunately
     19        means that it will be harder to spot logic errors when using a wrong session.
     20        (WebKit::NetworkConnectionToWebProcess::registerBlobURL): Removed an obsolete FIXME.
     21
     22        * NetworkProcess/mac/RemoteNetworkingContext.h: Changed privateBrowsingSession()
     23        to return a pointer, as no caller could know when it was safe to call it.
     24
     25        * NetworkProcess/mac/RemoteNetworkingContext.mm:
     26        (WebKit::RemoteNetworkingContext::storageSession): Handle the case where private
     27        browsing session is unexpectedly missing without crashing.
     28        (WebKit::RemoteNetworkingContext::privateBrowsingSession): Changed to return a pointer.
     29
     30        * UIProcess/WebContext.cpp: (WebKit::WebContext::ensureNetworkProcess):
     31        Actually initialize privateBrowsingEnabled creation parameter. It would be very
     32        difficult to figure out 100% reliably whether NetworkProcess needs a private browsing
     33        session with the current API, but for existing clients, looking at
     34        m_privateBrowsingEnterCount is good enough. Certainly better than not initializing.
     35
     36        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     37        (WebKit::InjectedBundle::setPrivateBrowsingEnabled): Added a FIXME.
     38
    1392013-05-22  Tim Horton  <timothy_horton@apple.com>
    240
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r149848 r150537  
    157157static NetworkStorageSession& storageSession(bool privateBrowsingEnabled)
    158158{
    159     return privateBrowsingEnabled ? RemoteNetworkingContext::privateBrowsingSession() : NetworkStorageSession::defaultStorageSession();
     159    if (privateBrowsingEnabled) {
     160        NetworkStorageSession* privateSession = RemoteNetworkingContext::privateBrowsingSession();
     161        if (privateSession)
     162            return *privateSession;
     163        // Some requests with private browsing mode requested may still be coming shortly after NetworkProcess was told to destroy its session.
     164        // FIXME: Find a way to track private browsing sessions more rigorously.
     165        LOG_ERROR("Private browsing was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
     166    }
     167    return NetworkStorageSession::defaultStorageSession();
    160168}
    161169
     
    209217void NetworkConnectionToWebProcess::registerBlobURL(const KURL& url, const BlobRegistrationData& data)
    210218{
    211     // FIXME: unregister all URLs when process connection closes.
    212 
    213219    Vector<RefPtr<SandboxExtension>> extensions;
    214220    for (size_t i = 0, count = data.sandboxExtensions().size(); i < count; ++i) {
  • trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h

    r146536 r150537  
    4343    static void destroyPrivateBrowsingSession();
    4444
    45     static WebCore::NetworkStorageSession& privateBrowsingSession(); // Can only be called when the session exists.
     45    static WebCore::NetworkStorageSession* privateBrowsingSession();
    4646
    4747    virtual bool shouldClearReferrerOnHTTPSToHTTPRedirect() const OVERRIDE;
  • trunk/Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm

    r148123 r150537  
    7979{
    8080    if (m_privateBrowsingEnabled) {
    81         ASSERT(privateBrowsingStorageSession());
    82         return *privateBrowsingStorageSession();
     81        NetworkStorageSession* privateSession = privateBrowsingStorageSession().get();
     82        if (privateSession)
     83            return *privateSession;
     84        // Some requests with private browsing mode requested may still be coming shortly after NetworkProcess was told to destroy its session.
     85        // FIXME: Find a way to track private browsing sessions more rigorously.
     86        LOG_ERROR("Private browsing was requested, but there was no session for it. Please file a bug unless you just disabled private browsing, in which case it's an expected race.");
    8387    }
    8488
     
    8690}
    8791
    88 NetworkStorageSession& RemoteNetworkingContext::privateBrowsingSession()
     92NetworkStorageSession* RemoteNetworkingContext::privateBrowsingSession()
    8993{
    90     ASSERT(privateBrowsingStorageSession());
    91     return *privateBrowsingStorageSession();
     94    return privateBrowsingStorageSession().get();
    9295}
    9396
  • trunk/Source/WebKit2/UIProcess/WebContext.cpp

    r150314 r150537  
    374374        SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle);
    375375
     376    // FIXME: We don't account for private browsing mode being enabled due to a persistent preference in any of active page groups.
     377    // This means that clients must re-enable private browsing mode through API on each launch, not relying on preferences.
     378    // If the client does not re-enable private browsing on next launch, NetworkProcess will crash.
     379    parameters.privateBrowsingEnabled = m_privateBrowsingEnterCount;
     380
    376381    parameters.cacheModel = m_cacheModel;
    377382
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r150282 r150537  
    304304void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
    305305{
     306    // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>.
    306307#if PLATFORM(MAC) || USE(CFNETWORK)
    307308    if (enabled)
Note: See TracChangeset for help on using the changeset viewer.