Diff
Modified: trunk/Source/WebKit/ChangeLog (242806 => 242807)
--- trunk/Source/WebKit/ChangeLog 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/ChangeLog 2019-03-12 18:51:13 UTC (rev 242807)
@@ -1,3 +1,31 @@
+2019-03-12 Per Arne Vollan <[email protected]>
+
+ [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):
+
2019-03-12 Tim Horton <[email protected]>
Fix the build after 242801
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (242806 => 242807)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-03-12 18:51:13 UTC (rev 242807)
@@ -1124,6 +1124,10 @@
@end
#endif
+@interface UIDevice ()
+@property (nonatomic, setter=_setBacklightLevel:) float _backlightLevel;
+@end
+
static inline bool currentUserInterfaceIdiomIsPad()
{
// This inline function exists to thwart unreachable code
@@ -1187,4 +1191,6 @@
UIEdgeInsets UIEdgeInsetsAdd(UIEdgeInsets lhs, UIEdgeInsets rhs, UIRectEdge);
+extern NSString *const UIBacklightLevelChangedNotification;
+
WTF_EXTERN_C_END
Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb (242806 => 242807)
--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-03-12 18:51:13 UTC (rev 242807)
@@ -450,6 +450,10 @@
(global-name "com.apple.coremedia.decompressionsession")
(global-name "com.apple.coremedia.videoqueue"))
+;; FIXME: remove the send-signal when this rule is no longer generating crashes.
+(deny mach-lookup (with send-signal SIGKILL)
+ (global-name "com.apple.backboard.hid.services"))
+
;; These services have been identified as unused during living-on.
;; This list overrides some definitions above and in common.sb.
;; FIXME: remove overridden rules once the final list has been
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (242806 => 242807)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2019-03-12 18:51:13 UTC (rev 242807)
@@ -77,6 +77,11 @@
static NSString * const WebKitLogCookieInformationDefaultsKey = @"WebKitLogCookieInformation";
#endif
+#if PLATFORM(IOS)
+SOFT_LINK_PRIVATE_FRAMEWORK(BackBoardServices)
+SOFT_LINK(BackBoardServices, BKSDisplayBrightnessGetCurrent, float, (), ());
+#endif
+
namespace WebKit {
using namespace WebCore;
@@ -381,6 +386,19 @@
return WTF::hasEntitlement(ensureNetworkProcess().connection()->xpcConnection(), entitlement.utf8().data());
}
+#if PLATFORM(IOS)
+float WebProcessPool::displayBrightness()
+{
+ return BKSDisplayBrightnessGetCurrent();
+}
+
+void WebProcessPool::backlightLevelDidChangeCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
+{
+ WebProcessPool* pool = reinterpret_cast<WebProcessPool*>(observer);
+ pool->sendToAllProcesses(Messages::WebProcess::BacklightLevelDidChange(BKSDisplayBrightnessGetCurrent()));
+}
+#endif
+
void WebProcessPool::registerNotificationObservers()
{
#if !PLATFORM(IOS_FAMILY)
@@ -427,7 +445,8 @@
m_deactivationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationDidResignActiveNotification object:NSApp queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
setApplicationIsActive(false);
}];
-
+#elif PLATFORM(IOS)
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, backlightLevelDidChangeCallback, static_cast<CFStringRef>(UIBacklightLevelChangedNotification), nullptr, CFNotificationSuspensionBehaviorCoalesce);
#endif // !PLATFORM(IOS_FAMILY)
}
@@ -434,7 +453,7 @@
void WebProcessPool::unregisterNotificationObservers()
{
#if !PLATFORM(IOS_FAMILY)
- [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
+ [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_automaticQuoteSubstitutionNotificationObserver.get()];
@@ -445,6 +464,8 @@
#endif
[[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_deactivationObserver.get()];
+#elif PLATFORM(IOS)
+ CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, static_cast<CFStringRef>(UIBacklightLevelChangedNotification) , nullptr);
#endif // !PLATFORM(IOS_FAMILY)
}
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (242806 => 242807)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-12 18:51:13 UTC (rev 242807)
@@ -997,6 +997,10 @@
process.send(Messages::WebProcess::PrewarmGlobally(), 0);
}
+#if PLATFORM(IOS)
+ process.send(Messages::WebProcess::BacklightLevelDidChange(displayBrightness()), 0);
+#endif
+
#if ENABLE(REMOTE_INSPECTOR)
// Initialize remote inspector connection now that we have a sub-process that is hosting one of our web views.
Inspector::RemoteInspector::singleton();
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (242806 => 242807)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-03-12 18:51:13 UTC (rev 242807)
@@ -572,6 +572,11 @@
void updateMaxSuspendedPageCount();
+#if PLATFORM(IOS)
+ static float displayBrightness();
+ static void backlightLevelDidChangeCallback(CFNotificationCenterRef, void *observer, CFStringRef name, const void *, CFDictionaryRef userInfo);
+#endif
+
Ref<API::ProcessPoolConfiguration> m_configuration;
IPC::MessageReceiverMap m_messageReceiverMap;
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (242806 => 242807)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2019-03-12 18:51:13 UTC (rev 242807)
@@ -246,6 +246,10 @@
void accessibilityProcessSuspendedNotification(bool);
#endif
+#if PLATFORM(IOS)
+ float backlightLevel() const { return m_backlightLevel; }
+#endif
+
#if PLATFORM(COCOA)
void setMediaMIMETypes(const Vector<String>);
#endif
@@ -409,6 +413,10 @@
#endif
#endif
+#if PLATFORM(IOS)
+ void backlightLevelDidChange(float backlightLevel);
+#endif
+
#if ENABLE(VIDEO)
void suspendAllMediaBuffering();
void resumeAllMediaBuffering();
@@ -506,6 +514,10 @@
#if ENABLE(MEDIA_STREAM) && ENABLE(SANDBOX_EXTENSIONS)
HashMap<String, RefPtr<SandboxExtension>> m_mediaCaptureSandboxExtensions;
#endif
+
+#if PLATFORM(IOS)
+ float m_backlightLevel { 0 };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (242806 => 242807)
--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-03-12 18:51:13 UTC (rev 242807)
@@ -134,6 +134,10 @@
#endif
#endif
+#if PLATFORM(IOS)
+ BacklightLevelDidChange(float backlightLevel)
+#endif
+
IsJITEnabled() -> (bool enabled) Async
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (242806 => 242807)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-03-12 18:25:34 UTC (rev 242806)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-03-12 18:51:13 UTC (rev 242807)
@@ -74,6 +74,10 @@
#import <wtf/FileSystem.h>
#import <wtf/cocoa/NSURLExtras.h>
+#if PLATFORM(IOS)
+#import "UIKitSPI.h"
+#endif
+
#if PLATFORM(IOS_FAMILY)
#import "WKAccessibilityWebPageObjectIOS.h"
#import <UIKit/UIAccessibility.h>
@@ -698,6 +702,26 @@
}
#endif
+#if PLATFORM(IOS)
+static float currentBacklightLevel()
+{
+ return WebProcess::singleton().backlightLevel();
+}
+
+void WebProcess::backlightLevelDidChange(float backlightLevel)
+{
+ m_backlightLevel = backlightLevel;
+
+ static std::once_flag onceFlag;
+ std::call_once(
+ onceFlag,
+ [] {
+ Method methodToPatch = class_getInstanceMethod([UIDevice class], @selector(_backlightLevel));
+ method_setImplementation(methodToPatch, reinterpret_cast<IMP>(currentBacklightLevel));
+ });
+}
+#endif
+
void WebProcess::setMediaMIMETypes(const Vector<String> types)
{
AVFoundationMIMETypeCache::singleton().setSupportedTypes(types);