Changeset 242807 in webkit


Ignore:
Timestamp:
Mar 12, 2019 11:51:13 AM (5 years ago)
Author:
pvollan@apple.com
Message:

[iOS] Block access to backboardd service
https://bugs.webkit.org/show_bug.cgi?id=195484

Reviewed by Brent Fulgham.

This patch is addressing blocking the backboardd service "com.apple.backboard.hid.services". Getting the
backlight level in the WebContent process will initiate a connection with this service. To be able to
block the service, the backlight level is queried in the UI process and sent to the WebContent process
when the WebContent process is started, and when the backlight level is changed. On the WebContent side,
the method getting the backlight level is swizzled to return the value sent from the UI process.

  • Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::displayBrightness):
(WebKit::WebProcessPool::backlightLevelDidChangeCallback):
(WebKit::WebProcessPool::registerNotificationObservers):
(WebKit::WebProcessPool::unregisterNotificationObservers):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::initializeNewWebProcess):

  • UIProcess/WebProcessPool.h:
  • WebProcess/WebProcess.h:
  • WebProcess/WebProcess.messages.in:
  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::currentBacklightLevel):
(WebKit::WebProcess::backlightLevelDidChange):

Location:
trunk/Source/WebKit
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r242806 r242807  
     12019-03-12  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Block access to backboardd service
     4        https://bugs.webkit.org/show_bug.cgi?id=195484
     5
     6        Reviewed by Brent Fulgham.
     7
     8        This patch is addressing blocking the backboardd service "com.apple.backboard.hid.services". Getting the
     9        backlight level in the WebContent process will initiate a connection with this service. To be able to
     10        block the service, the backlight level is queried in the UI process and sent to the WebContent process
     11        when the WebContent process is started, and when the backlight level is changed. On the WebContent side,
     12        the method getting the backlight level is swizzled to return the value sent from the UI process.
     13
     14        * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
     15        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     16        (WebKit::WebProcessPool::displayBrightness):
     17        (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
     18        (WebKit::WebProcessPool::registerNotificationObservers):
     19        (WebKit::WebProcessPool::unregisterNotificationObservers):
     20        * UIProcess/WebProcessPool.cpp:
     21        (WebKit::WebProcessPool::initializeNewWebProcess):
     22        * UIProcess/WebProcessPool.h:
     23        * WebProcess/WebProcess.h:
     24        * WebProcess/WebProcess.messages.in:
     25        * WebProcess/cocoa/WebProcessCocoa.mm:
     26        (WebKit::currentBacklightLevel):
     27        (WebKit::WebProcess::backlightLevelDidChange):
     28
    1292019-03-12  Tim Horton  <timothy_horton@apple.com>
    230
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r242775 r242807  
    11251125#endif
    11261126
     1127@interface UIDevice ()
     1128@property (nonatomic, setter=_setBacklightLevel:) float _backlightLevel;
     1129@end
     1130
    11271131static inline bool currentUserInterfaceIdiomIsPad()
    11281132{
     
    11881192UIEdgeInsets UIEdgeInsetsAdd(UIEdgeInsets lhs, UIEdgeInsets rhs, UIRectEdge);
    11891193
     1194extern NSString *const UIBacklightLevelChangedNotification;
     1195
    11901196WTF_EXTERN_C_END
  • trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb

    r242803 r242807  
    450450    (global-name "com.apple.coremedia.decompressionsession")
    451451    (global-name "com.apple.coremedia.videoqueue"))
     452
     453;; FIXME: remove the send-signal when this rule is no longer generating crashes.
     454(deny mach-lookup (with send-signal SIGKILL)
     455    (global-name "com.apple.backboard.hid.services"))
    452456
    453457;; These services have been identified as unused during living-on.
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r242775 r242807  
    7878#endif
    7979
     80#if PLATFORM(IOS)
     81SOFT_LINK_PRIVATE_FRAMEWORK(BackBoardServices)
     82SOFT_LINK(BackBoardServices, BKSDisplayBrightnessGetCurrent, float, (), ());
     83#endif
     84
    8085namespace WebKit {
    8186using namespace WebCore;
     
    382387}
    383388
     389#if PLATFORM(IOS)
     390float WebProcessPool::displayBrightness()
     391{
     392    return BKSDisplayBrightnessGetCurrent();
     393}
     394   
     395void WebProcessPool::backlightLevelDidChangeCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
     396{
     397    WebProcessPool* pool = reinterpret_cast<WebProcessPool*>(observer);
     398    pool->sendToAllProcesses(Messages::WebProcess::BacklightLevelDidChange(BKSDisplayBrightnessGetCurrent()));
     399}
     400#endif
     401
    384402void WebProcessPool::registerNotificationObservers()
    385403{
     
    428446        setApplicationIsActive(false);
    429447    }];
    430 
     448#elif PLATFORM(IOS)
     449    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, backlightLevelDidChangeCallback, static_cast<CFStringRef>(UIBacklightLevelChangedNotification), nullptr, CFNotificationSuspensionBehaviorCoalesce);
    431450#endif // !PLATFORM(IOS_FAMILY)
    432451}
     
    435454{
    436455#if !PLATFORM(IOS_FAMILY)
    437     [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];   
     456    [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
    438457    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
    439458    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
     
    446465    [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
    447466    [[NSNotificationCenter defaultCenter] removeObserver:m_deactivationObserver.get()];
     467#elif PLATFORM(IOS)
     468    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, static_cast<CFStringRef>(UIBacklightLevelChangedNotification) , nullptr);
    448469#endif // !PLATFORM(IOS_FAMILY)
    449470}
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r242775 r242807  
    998998    }
    999999
     1000#if PLATFORM(IOS)
     1001    process.send(Messages::WebProcess::BacklightLevelDidChange(displayBrightness()), 0);
     1002#endif
     1003
    10001004#if ENABLE(REMOTE_INSPECTOR)
    10011005    // Initialize remote inspector connection now that we have a sub-process that is hosting one of our web views.
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r242775 r242807  
    573573    void updateMaxSuspendedPageCount();
    574574
     575#if PLATFORM(IOS)
     576    static float displayBrightness();
     577    static void backlightLevelDidChangeCallback(CFNotificationCenterRef, void *observer, CFStringRef name, const void *, CFDictionaryRef userInfo);   
     578#endif
     579
    575580    Ref<API::ProcessPoolConfiguration> m_configuration;
    576581
  • trunk/Source/WebKit/WebProcess/WebProcess.h

    r242775 r242807  
    247247#endif
    248248
     249#if PLATFORM(IOS)
     250    float backlightLevel() const { return m_backlightLevel; }
     251#endif
     252
    249253#if PLATFORM(COCOA)
    250254    void setMediaMIMETypes(const Vector<String>);
     
    410414#endif
    411415
     416#if PLATFORM(IOS)
     417    void backlightLevelDidChange(float backlightLevel);
     418#endif
     419
    412420#if ENABLE(VIDEO)
    413421    void suspendAllMediaBuffering();
     
    507515    HashMap<String, RefPtr<SandboxExtension>> m_mediaCaptureSandboxExtensions;
    508516#endif
     517
     518#if PLATFORM(IOS)
     519    float m_backlightLevel { 0 };
     520#endif
    509521};
    510522
  • trunk/Source/WebKit/WebProcess/WebProcess.messages.in

    r242775 r242807  
    135135#endif
    136136
     137#if PLATFORM(IOS)
     138    BacklightLevelDidChange(float backlightLevel)
     139#endif
     140
    137141    IsJITEnabled() -> (bool enabled) Async
    138142
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r242775 r242807  
    7575#import <wtf/cocoa/NSURLExtras.h>
    7676
     77#if PLATFORM(IOS)
     78#import "UIKitSPI.h"
     79#endif
     80
    7781#if PLATFORM(IOS_FAMILY)
    7882#import "WKAccessibilityWebPageObjectIOS.h"
     
    699703#endif
    700704
     705#if PLATFORM(IOS)
     706static float currentBacklightLevel()
     707{
     708    return WebProcess::singleton().backlightLevel();
     709}
     710
     711void WebProcess::backlightLevelDidChange(float backlightLevel)
     712{
     713    m_backlightLevel = backlightLevel;
     714
     715    static std::once_flag onceFlag;
     716    std::call_once(
     717        onceFlag,
     718        [] {
     719            Method methodToPatch = class_getInstanceMethod([UIDevice class], @selector(_backlightLevel));
     720            method_setImplementation(methodToPatch, reinterpret_cast<IMP>(currentBacklightLevel));
     721        });
     722}
     723#endif
     724
    701725void WebProcess::setMediaMIMETypes(const Vector<String> types)
    702726{
Note: See TracChangeset for help on using the changeset viewer.