Changeset 230468 in webkit


Ignore:
Timestamp:
Apr 9, 2018 8:50:17 PM (6 years ago)
Author:
Brent Fulgham
Message:

Add ProcessPrivilege assertions to places that access NSApp
https://bugs.webkit.org/show_bug.cgi?id=184322
<rdar://problem/39194560>

Reviewed by Per Arne Vollan.

Add ProcessPrivilege assertions to places where we interact with NSApp so
that we can prevent accidentally using them in the WebContent process.

Source/WebCore:

  • page/mac/EventHandlerMac.mm:

(WebCore::lastEventIsMouseUp):
(WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):

  • platform/mac/EventLoopMac.mm:

(WebCore::EventLoop::cycle):

  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::setDragImage):

Source/WebKit:

  • Shared/mac/ChildProcessMac.mm:

(WebKit::ChildProcess::stopNSAppRunLoop):

  • Shared/mac/HangDetectionDisablerMac.mm:

(WebKit::setClientsMayIgnoreEvents):

  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess):

  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::becomeFirstResponder):
(WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
(WebKit::WebViewImpl::validateUserInterfaceItem):
(WebKit::WebViewImpl::startSpeaking):
(WebKit::WebViewImpl::stopSpeaking):
(WebKit::applicationFlagsForDrag):
(WebKit::WebViewImpl::doneWithKeyEvent):

  • UIProcess/Gamepad/mac/UIGamepadProviderMac.mm:

(WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):

  • UIProcess/Plugins/mac/PluginProcessProxyMac.mm:

(WebKit::PluginProcessProxy::enterFullscreen):
(WebKit::PluginProcessProxy::beginModal):
(WebKit::PluginProcessProxy::endModal):

  • UIProcess/mac/DisplayLink.cpp:

(WebKit::DisplayLink::DisplayLink):
(WebKit::DisplayLink::~DisplayLink):

  • UIProcess/mac/PageClientImplMac.mm:

(WebKit::PageClientImpl::isViewWindowActive):
(WebKit::PageClientImpl::setCursor):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::getIsSpeaking):
(WebKit::WebPageProxy::speak):
(WebKit::WebPageProxy::stopSpeaking):
(WebKit::WebPageProxy::startDisplayLink):

  • UIProcess/mac/WebPopupMenuProxyMac.mm:

(WebKit::WebPopupMenuProxyMac::showPopupMenu):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230467 r230468  
     12018-04-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Add ProcessPrivilege assertions to places that access NSApp
     4        https://bugs.webkit.org/show_bug.cgi?id=184322
     5        <rdar://problem/39194560>
     6
     7        Reviewed by Per Arne Vollan.
     8
     9        Add ProcessPrivilege assertions to places where we interact with NSApp so
     10        that we can prevent accidentally using them in the WebContent process.
     11
     12        * page/mac/EventHandlerMac.mm:
     13        (WebCore::lastEventIsMouseUp):
     14        (WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):
     15        * platform/mac/EventLoopMac.mm:
     16        (WebCore::EventLoop::cycle):
     17        * platform/mac/PasteboardMac.mm:
     18        (WebCore::Pasteboard::setDragImage):
     19
    1202018-04-09  John Wilander  <wilander@apple.com>
    221
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r230454 r230468  
    7070#include <wtf/NeverDestroyed.h>
    7171#include <wtf/ObjcRuntimeExtras.h>
     72#include <wtf/ProcessPrivilege.h>
    7273
    7374#if ENABLE(MAC_GESTURE_EVENTS)
     
    201202
    202203    ASSERT([NSApp isRunning]);
     204    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    203205
    204206    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    570572    if (!view)
    571573        return;
     574
     575    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    572576
    573577    BEGIN_BLOCK_OBJC_EXCEPTIONS;
  • trunk/Source/WebCore/platform/mac/EventLoopMac.mm

    r228531 r230468  
    11/*
    2  * Copyright (C) 2008, 2017 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#include "EventLoop.h"
    2828
     29#include <wtf/ProcessPrivilege.h>
     30
    2931#if PLATFORM(MAC)
    3032
     
    3840        return;
    3941    }
     42    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    4043#endif
    4144    [NSApp setWindowsNeedUpdate:YES];
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r230221 r230468  
    4343#import <pal/spi/cg/CoreGraphicsSPI.h>
    4444#import <pal/spi/mac/HIServicesSPI.h>
     45#import <wtf/ProcessPrivilege.h>
    4546#import <wtf/RetainPtr.h>
    4647#import <wtf/StdLibExtras.h>
     
    676677    // NSRunLoop, and not the NSApplication run loop.
    677678    if ([NSApp isRunning]) {
     679        RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    678680        NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSZeroPoint
    679681            modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
  • trunk/Source/WebKit/ChangeLog

    r230467 r230468  
     12018-04-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Add ProcessPrivilege assertions to places that access NSApp
     4        https://bugs.webkit.org/show_bug.cgi?id=184322
     5        <rdar://problem/39194560>
     6
     7        Reviewed by Per Arne Vollan.
     8
     9        Add ProcessPrivilege assertions to places where we interact with NSApp so
     10        that we can prevent accidentally using them in the WebContent process.
     11
     12        * Shared/mac/ChildProcessMac.mm:
     13        (WebKit::ChildProcess::stopNSAppRunLoop):
     14        * Shared/mac/HangDetectionDisablerMac.mm:
     15        (WebKit::setClientsMayIgnoreEvents):
     16        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     17        (WebKit::WebProcessPool::platformInitializeWebProcess):
     18        * UIProcess/Cocoa/WebViewImpl.mm:
     19        (WebKit::WebViewImpl::WebViewImpl):
     20        (WebKit::WebViewImpl::becomeFirstResponder):
     21        (WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
     22        (WebKit::WebViewImpl::validateUserInterfaceItem):
     23        (WebKit::WebViewImpl::startSpeaking):
     24        (WebKit::WebViewImpl::stopSpeaking):
     25        (WebKit::applicationFlagsForDrag):
     26        (WebKit::WebViewImpl::doneWithKeyEvent):
     27        * UIProcess/Gamepad/mac/UIGamepadProviderMac.mm:
     28        (WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
     29        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
     30        (WebKit::PluginProcessProxy::enterFullscreen):
     31        (WebKit::PluginProcessProxy::beginModal):
     32        (WebKit::PluginProcessProxy::endModal):
     33        * UIProcess/mac/DisplayLink.cpp:
     34        (WebKit::DisplayLink::DisplayLink):
     35        (WebKit::DisplayLink::~DisplayLink):
     36        * UIProcess/mac/PageClientImplMac.mm:
     37        (WebKit::PageClientImpl::isViewWindowActive):
     38        (WebKit::PageClientImpl::setCursor):
     39        * UIProcess/mac/WebPageProxyMac.mm:
     40        (WebKit::WebPageProxy::getIsSpeaking):
     41        (WebKit::WebPageProxy::speak):
     42        (WebKit::WebPageProxy::stopSpeaking):
     43        (WebKit::WebPageProxy::startDisplayLink):
     44        * UIProcess/mac/WebPopupMenuProxyMac.mm:
     45        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
     46
    1472018-04-09  John Wilander  <wilander@apple.com>
    248
  • trunk/Source/WebKit/Shared/mac/ChildProcessMac.mm

    r229480 r230468  
    3939#import <stdlib.h>
    4040#import <sysexits.h>
     41#import <wtf/ProcessPrivilege.h>
    4142#import <wtf/Scope.h>
    4243#import <wtf/spi/darwin/SandboxSPI.h>
     
    206207{
    207208    ASSERT([NSApp isRunning]);
     209    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    208210    [NSApp stop:nil];
    209211
  • trunk/Source/WebKit/Shared/mac/HangDetectionDisablerMac.mm

    r229484 r230468  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131#include <pal/spi/cg/CoreGraphicsSPI.h>
     32#include <wtf/ProcessPrivilege.h>
    3233#include <wtf/RetainPtr.h>
    3334
     
    5354    if (!cgsId)
    5455        return;
     56    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    5557#endif
    5658    if (CGSSetConnectionProperty(cgsId, cgsId, clientsMayIgnoreEventsKey, clientsMayIgnoreEvents ? kCFBooleanTrue : kCFBooleanFalse) != kCGErrorSuccess)
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r229978 r230468  
    183183#pragma clang diagnostic push
    184184#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     185    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    185186    parameters.accessibilityEnhancedUserInterfaceEnabled = [[NSApp accessibilityAttributeValue:@"AXEnhancedUserInterface"] boolValue];
    186187#pragma clang diagnostic pop
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r230462 r230468  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    103103#import <sys/stat.h>
    104104#import <wtf/NeverDestroyed.h>
     105#import <wtf/ProcessPrivilege.h>
    105106#import <wtf/SetForScope.h>
    106107#import <wtf/SoftLinking.h>
     
    12881289    static_cast<PageClientImpl&>(*m_pageClient).setImpl(*this);
    12891290
     1291    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    12901292    [NSApp registerServicesMenuSendTypes:PasteboardTypes::forSelection() returnTypes:PasteboardTypes::forEditing()];
    12911293
     
    14211423bool WebViewImpl::becomeFirstResponder()
    14221424{
     1425    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    14231426    // If we just became first responder again, there is no need to do anything,
    14241427    // since resignFirstResponder has correctly detected this situation.
     
    23772380void WebViewImpl::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus, uint64_t pluginComplexTextInputIdentifier)
    23782381{
     2382    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    23792383    BOOL inputSourceChanged = m_pluginComplexTextInputIdentifier;
    23802384
     
    26862690bool WebViewImpl::validateUserInterfaceItem(id <NSValidatedUserInterfaceItem> item)
    26872691{
     2692    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    26882693    SEL action = [item action];
    26892694
     
    28072812void WebViewImpl::startSpeaking()
    28082813{
     2814    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    28092815    m_page->getSelectionOrContentsAsString([](const String& string, WebKit::CallbackBase::Error error) {
    28102816        if (error != WebKit::CallbackBase::Error::None)
     
    28192825void WebViewImpl::stopSpeaking(id sender)
    28202826{
     2827    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    28212828    [NSApp stopSpeaking:sender];
    28222829}
     
    36313638static WebCore::DragApplicationFlags applicationFlagsForDrag(NSView *view, id <NSDraggingInfo> draggingInfo)
    36323639{
     3640    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    36333641    uint32_t flags = 0;
    36343642    if ([NSApp modalWindow])
     
    42434251void WebViewImpl::doneWithKeyEvent(NSEvent *event, bool eventWasHandled)
    42444252{
     4253    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    42454254    if ([event type] != NSEventTypeKeyDown)
    42464255        return;
  • trunk/Source/WebKit/UIProcess/Gamepad/mac/UIGamepadProviderMac.mm

    r205247 r230468  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#import "WKViewInternal.h"
    3434#import "WKWebViewInternal.h"
     35#import <wtf/ProcessPrivilege.h>
    3536
    3637namespace WebKit {
     
    3839WebPageProxy* UIGamepadProvider::platformWebPageProxyForGamepadInput()
    3940{
     41    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    4042    auto responder = [[NSApp keyWindow] firstResponder];
    4143
  • trunk/Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm

    r222896 r230468  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939#import <pal/spi/cf/CFNetworkSPI.h>
    4040#import <spawn.h>
     41#import <wtf/ProcessPrivilege.h>
    4142#import <wtf/text/CString.h>
    4243
     
    132133void PluginProcessProxy::enterFullscreen()
    133134{
     135    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    134136    // Get the current presentation options.
    135137    m_preFullscreenAppPresentationOptions = [NSApp presentationOptions];
     
    192194    ASSERT(!m_placeholderWindow);
    193195    ASSERT(!m_activationObserver);
    194    
     196    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     197
    195198    m_placeholderWindow = adoptNS([[WKPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]);
    196199    [m_placeholderWindow setReleasedWhenClosed:NO];
     
    213216    ASSERT(m_placeholderWindow);
    214217    ASSERT(m_activationObserver);
    215    
     218    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     219
    216220    [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
    217221    m_activationObserver = nullptr;
  • trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp

    r229707 r230468  
    3232#include "WebPageProxy.h"
    3333#include "WebProcessProxy.h"
     34#include <wtf/ProcessPrivilege.h>
    3435
    3536namespace WebKit {
     
    3839    : m_webPageProxy(webPageProxy)
    3940{
     41    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    4042    CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &m_displayLink);
    4143    if (error) {
     
    5759DisplayLink::~DisplayLink()
    5860{
     61    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    5962    ASSERT(m_displayLink);
    6063    if (!m_displayLink)
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r228857 r230468  
    11/*
    2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7373#import <WebCore/ValidationBubble.h>
    7474#import <WebCore/WebCoreCALayerExtras.h>
     75#import <wtf/ProcessPrivilege.h>
    7576#import <wtf/text/CString.h>
    7677#import <wtf/text/WTFString.h>
     
    161162bool PageClientImpl::isViewWindowActive()
    162163{
     164    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    163165    NSWindow *activeViewWindow = activeWindow();
    164166    return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;
     
    291293void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
    292294{
     295    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    293296    // FIXME: Would be nice to share this code with WebKit1's WebChromeClient.
    294297
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r229707 r230468  
    11/*
    2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5959#import <mach-o/dyld.h>
    6060#import <pal/spi/mac/NSApplicationSPI.h>
     61#import <wtf/ProcessPrivilege.h>
    6162#import <wtf/text/StringConcatenate.h>
    6263
     
    100101void WebPageProxy::getIsSpeaking(bool& isSpeaking)
    101102{
     103    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    102104    isSpeaking = [NSApp isSpeaking];
    103105}
     
    105107void WebPageProxy::speak(const String& string)
    106108{
     109    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    107110    [NSApp speakString:nsStringFromWebCoreString(string)];
    108111}
     
    110113void WebPageProxy::stopSpeaking()
    111114{
     115    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    112116    [NSApp stopSpeaking:nil];
    113117}
     
    609613void WebPageProxy::startDisplayLink(unsigned observerID)
    610614{
     615    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    611616    if (!m_displayLink) {
    612617        uint32_t displayID = [[[[platformWindow() screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
  • trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm

    r227550 r230468  
    11/*
    2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535#import "WebPopupItem.h"
    3636#import <pal/system/mac/PopupMenu.h>
     37#import <wtf/ProcessPrivilege.h>
    3738
    3839using namespace WebCore;
     
    99100void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
    100101{
     102    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    101103    NSFont *font;
    102104    if (data.fontInfo.fontAttributeDictionary) {
Note: See TracChangeset for help on using the changeset viewer.