⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242745 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 3:15:51 PM (7 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

    r242738 r242745  
     12019-03-11  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-11  Brent Fulgham  <bfulgham@apple.com>
    230
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r241971 r242745  
    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

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

    r242406 r242745  
    7878#endif
    7979
     80#if PLATFORM(IOS_FAMILY)
     81SOFT_LINK_PRIVATE_FRAMEWORK(BackBoardServices)
     82SOFT_LINK(BackBoardServices, BKSDisplayBrightnessGetCurrent, float, (), ());
     83#endif
     84
    8085namespace WebKit {
    8186using namespace WebCore;
     
    382387}
    383388
     389#if PLATFORM(IOS_FAMILY)
     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{
    386 #if !PLATFORM(IOS_FAMILY)
     404#if PLATFORM(IOS_FAMILY)
     405    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, backlightLevelDidChangeCallback, (CFStringRef)UIBacklightLevelChangedNotification, nullptr, CFNotificationSuspensionBehaviorCoalesce);
     406#else
    387407    // Listen for enhanced accessibility changes and propagate them to the WebProcess.
    388408    m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
     
    434454void WebProcessPool::unregisterNotificationObservers()
    435455{
    436 #if !PLATFORM(IOS_FAMILY)
     456#if PLATFORM(IOS_FAMILY)
     457    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, (CFStringRef)UIBacklightLevelChangedNotification, nullptr);
     458#else
    437459    [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];   
    438460    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r242726 r242745  
    984984    }
    985985
     986#if PLATFORM(IOS_FAMILY)
     987    process.send(Messages::WebProcess::BacklightLevelDidChange(displayBrightness()), 0);
     988#endif
     989
    986990#if ENABLE(REMOTE_INSPECTOR)
    987991    // 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

    r242603 r242745  
    573573    void updateMaxSuspendedPageCount();
    574574
     575#if PLATFORM(IOS_FAMILY)
     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

    r242230 r242745  
    245245#if PLATFORM(IOS_FAMILY)
    246246    void accessibilityProcessSuspendedNotification(bool);
     247    float backlightLevel() const { return m_backlightLevel; }
    247248#endif
    248249
     
    410411#endif
    411412
     413#if PLATFORM(IOS_FAMILY)
     414    void backlightLevelDidChange(float backlightLevel);
     415#endif
     416
    412417#if ENABLE(VIDEO)
    413418    void suspendAllMediaBuffering();
     
    507512    HashMap<String, RefPtr<SandboxExtension>> m_mediaCaptureSandboxExtensions;
    508513#endif
     514
     515#if PLATFORM(IOS_FAMILY)
     516    float m_backlightLevel { 0 };
     517#endif
    509518};
    510519
  • trunk/Source/WebKit/WebProcess/WebProcess.messages.in

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

    r242339 r242745  
    7676
    7777#if PLATFORM(IOS_FAMILY)
     78#import "UIKitSPI.h"
    7879#import "WKAccessibilityWebPageObjectIOS.h"
    7980#import <UIKit/UIAccessibility.h>
     
    699700#endif
    700701
     702#if PLATFORM(IOS_FAMILY)
     703static float currentBacklightLevel()
     704{
     705    return WebProcess::singleton().backlightLevel();
     706}
     707
     708void WebProcess::backlightLevelDidChange(float backlightLevel)
     709{
     710    m_backlightLevel = backlightLevel;
     711
     712    // Swizzle -[UIDevice _backlightLevel]
     713    // FIXME: remove the swizzling and related code once <rdar://problem/47603552> is fixed.
     714    static std::once_flag onceFlag;
     715    std::call_once(
     716        onceFlag,
     717        [] {
     718            Method methodToPatch = class_getInstanceMethod([UIDevice class], @selector(_backlightLevel));
     719            method_setImplementation(methodToPatch, reinterpret_cast<IMP>(currentBacklightLevel));
     720        });
     721}
     722#endif
     723
    701724void WebProcess::setMediaMIMETypes(const Vector<String> types)
    702725{
Note: See TracChangeset for help on using the changeset viewer.