Changeset 250799 in webkit


Ignore:
Timestamp:
Oct 7, 2019 3:14:41 PM (5 years ago)
Author:
pvollan@apple.com
Message:

[macOS] Layering violation in AuxiliaryProcessProxy::didFinishLaunching
https://bugs.webkit.org/show_bug.cgi?id=201617

Reviewed by Brent Fulgham.

The commit <https://trac.webkit.org/changeset/249649> introduced a layering violation in AuxiliaryProcessProxy::didFinishLaunching
where we inspect the pending message queue looking for a local file load message which needs the PID to create a sandbox extension
for the WebContent process. The layering violation can be fixed by creating a virtual method in AuxiliaryProcessProxy and override
the method in the WebProcessProxy to do the work needed to replace the message with a load request message containing a sandbox
extension created using the PID of the WebContent process. No new tests have been created, since this is covered by existing tests.

  • UIProcess/AuxiliaryProcessProxy.cpp:

(WebKit::AuxiliaryProcessProxy::didFinishLaunching):

  • UIProcess/AuxiliaryProcessProxy.h:

(WebKit::AuxiliaryProcessProxy::shouldSendPendingMessage):

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::shouldSendPendingMessage):

  • UIProcess/WebProcessProxy.h:
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250780 r250799  
     12019-10-07  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [macOS] Layering violation in AuxiliaryProcessProxy::didFinishLaunching
     4        https://bugs.webkit.org/show_bug.cgi?id=201617
     5
     6        Reviewed by Brent Fulgham.
     7
     8        The commit <https://trac.webkit.org/changeset/249649> introduced a layering violation in AuxiliaryProcessProxy::didFinishLaunching
     9        where we inspect the pending message queue looking for a local file load message which needs the PID to create a sandbox extension
     10        for the WebContent process. The layering violation can be fixed by creating a virtual method in AuxiliaryProcessProxy and override
     11        the method in the WebProcessProxy to do the work needed to replace the message with a load request message containing a sandbox
     12        extension created using the PID of the WebContent process. No new tests have been created, since this is covered by existing tests.
     13
     14        * UIProcess/AuxiliaryProcessProxy.cpp:
     15        (WebKit::AuxiliaryProcessProxy::didFinishLaunching):
     16        * UIProcess/AuxiliaryProcessProxy.h:
     17        (WebKit::AuxiliaryProcessProxy::shouldSendPendingMessage):
     18        * UIProcess/WebProcessProxy.cpp:
     19        (WebKit::WebProcessProxy::shouldSendPendingMessage):
     20        * UIProcess/WebProcessProxy.h:
     21
    1222019-10-07  Dean Jackson  <dino@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp

    r250329 r250799  
    2828
    2929#include "AuxiliaryProcessMessages.h"
    30 #include "LoadParameters.h"
    3130#include "Logging.h"
    32 #include "WebPageMessages.h"
    3331#include "WebPageProxy.h"
    3432#include "WebProcessProxy.h"
     
    212210
    213211    for (auto&& pendingMessage : std::exchange(m_pendingMessages, { })) {
     212        if (!shouldSendPendingMessage(pendingMessage))
     213            continue;
    214214        auto encoder = WTFMove(pendingMessage.encoder);
    215215        auto sendOptions = pendingMessage.sendOptions;
    216 #if HAVE(SANDBOX_ISSUE_MACH_EXTENSION_TO_PROCESS_BY_PID)
    217         if (encoder->messageName() == "LoadRequestWaitingForPID") {
    218             auto buffer = encoder->buffer();
    219             auto bufferSize = encoder->bufferSize();
    220             std::unique_ptr<IPC::Decoder> decoder = makeUnique<IPC::Decoder>(buffer, bufferSize, nullptr, Vector<IPC::Attachment> { });
    221             LoadParameters loadParameters;
    222             URL resourceDirectoryURL;
    223             WebPageProxyIdentifier pageID;
    224             if (decoder->decode(loadParameters) && decoder->decode(resourceDirectoryURL) && decoder->decode(pageID)) {
    225                 if (auto* page = WebProcessProxy::webPage(pageID)) {
    226                     page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), loadParameters.request.url(), resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
    227                     send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID());
    228                 }
    229             } else
    230                 ASSERT_NOT_REACHED();
    231             continue;
    232         }
    233 #endif
    234216        if (pendingMessage.asyncReplyInfo)
    235217            IPC::addAsyncReplyHandler(*connection(), pendingMessage.asyncReplyInfo->second, WTFMove(pendingMessage.asyncReplyInfo->first));
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h

    r250329 r250799  
    123123    virtual void platformGetLaunchOptions(ProcessLauncher::LaunchOptions&) { };
    124124
    125 private:
    126     virtual void connectionWillOpen(IPC::Connection&);
    127     virtual void processWillShutDown(IPC::Connection&) = 0;
    128 
    129125    struct PendingMessage {
    130126        std::unique_ptr<IPC::Encoder> encoder;
     
    132128        Optional<std::pair<CompletionHandler<void(IPC::Decoder*)>, uint64_t>> asyncReplyInfo;
    133129    };
    134    
     130
     131    virtual bool shouldSendPendingMessage(const PendingMessage&) { return true; }
     132
     133private:
     134    virtual void connectionWillOpen(IPC::Connection&);
     135    virtual void processWillShutDown(IPC::Connection&) = 0;
     136
    135137    Vector<PendingMessage> m_pendingMessages;
    136138    RefPtr<ProcessLauncher> m_processLauncher;
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r250084 r250799  
    3232#include "DataReference.h"
    3333#include "DownloadProxyMap.h"
     34#include "LoadParameters.h"
    3435#include "Logging.h"
    3536#include "PluginInfoStore.h"
     
    4445#include "WebNotificationManagerProxy.h"
    4546#include "WebPageGroup.h"
     47#include "WebPageMessages.h"
    4648#include "WebPageProxy.h"
    4749#include "WebPasteboardProxy.h"
     
    303305#endif
    304306
     307bool WebProcessProxy::shouldSendPendingMessage(const PendingMessage& message)
     308{
     309#if HAVE(SANDBOX_ISSUE_MACH_EXTENSION_TO_PROCESS_BY_PID)
     310    if (message.encoder->messageName() == "LoadRequestWaitingForPID") {
     311        auto buffer = message.encoder->buffer();
     312        auto bufferSize = message.encoder->bufferSize();
     313        std::unique_ptr<IPC::Decoder> decoder = makeUnique<IPC::Decoder>(buffer, bufferSize, nullptr, Vector<IPC::Attachment> { });
     314        LoadParameters loadParameters;
     315        URL resourceDirectoryURL;
     316        WebPageProxyIdentifier pageID;
     317        if (decoder->decode(loadParameters) && decoder->decode(resourceDirectoryURL) && decoder->decode(pageID)) {
     318            if (auto* page = WebProcessProxy::webPage(pageID)) {
     319                page->maybeInitializeSandboxExtensionHandle(static_cast<WebProcessProxy&>(*this), loadParameters.request.url(), resourceDirectoryURL, loadParameters.sandboxExtensionHandle);
     320                send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID());
     321            }
     322        } else
     323            ASSERT_NOT_REACHED();
     324        return false;
     325    }
     326#endif
     327    return true;
     328}
     329
    305330void WebProcessProxy::connectionWillOpen(IPC::Connection& connection)
    306331{
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r250428 r250799  
    330330    void connectionWillOpen(IPC::Connection&) override;
    331331    void processWillShutDown(IPC::Connection&) override;
    332 
     332    bool shouldSendPendingMessage(const PendingMessage&) final;
     333   
    333334    // ProcessLauncher::Client
    334335    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
Note: See TracChangeset for help on using the changeset viewer.