Diff
Modified: trunk/Source/WebKit/ChangeLog (242744 => 242745)
--- trunk/Source/WebKit/ChangeLog 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/ChangeLog 2019-03-11 22:15:51 UTC (rev 242745)
@@ -1,3 +1,31 @@
+2019-03-11 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-11 Brent Fulgham <[email protected]>
Remove obsolete runtime flag for StorageAccess API Prompt
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (242744 => 242745)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-03-11 22:15:51 UTC (rev 242745)
@@ -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 (242744 => 242745)
--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb 2019-03-11 22:15:51 UTC (rev 242745)
@@ -450,6 +450,11 @@
(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 (242744 => 242745)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2019-03-11 22:15:51 UTC (rev 242745)
@@ -77,6 +77,11 @@
static NSString * const WebKitLogCookieInformationDefaultsKey = @"WebKitLogCookieInformation";
#endif
+#if PLATFORM(IOS_FAMILY)
+SOFT_LINK_PRIVATE_FRAMEWORK(BackBoardServices)
+SOFT_LINK(BackBoardServices, BKSDisplayBrightnessGetCurrent, float, (), ());
+#endif
+
namespace WebKit {
using namespace WebCore;
@@ -381,9 +386,24 @@
return WTF::hasEntitlement(ensureNetworkProcess().connection()->xpcConnection(), entitlement.utf8().data());
}
+#if PLATFORM(IOS_FAMILY)
+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)
+#if PLATFORM(IOS_FAMILY)
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, backlightLevelDidChangeCallback, (CFStringRef)UIBacklightLevelChangedNotification, nullptr, CFNotificationSuspensionBehaviorCoalesce);
+#else
// Listen for enhanced accessibility changes and propagate them to the WebProcess.
m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
@@ -433,7 +453,9 @@
void WebProcessPool::unregisterNotificationObservers()
{
-#if !PLATFORM(IOS_FAMILY)
+#if PLATFORM(IOS_FAMILY)
+ CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), this, (CFStringRef)UIBacklightLevelChangedNotification, nullptr);
+#else
[[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
[[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (242744 => 242745)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-11 22:15:51 UTC (rev 242745)
@@ -983,6 +983,10 @@
process.send(Messages::WebProcess::PrewarmGlobally(), 0);
}
+#if PLATFORM(IOS_FAMILY)
+ 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 (242744 => 242745)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2019-03-11 22:15:51 UTC (rev 242745)
@@ -572,6 +572,11 @@
void updateMaxSuspendedPageCount();
+#if PLATFORM(IOS_FAMILY)
+ 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 (242744 => 242745)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2019-03-11 22:15:51 UTC (rev 242745)
@@ -244,6 +244,7 @@
#if PLATFORM(IOS_FAMILY)
void accessibilityProcessSuspendedNotification(bool);
+ float backlightLevel() const { return m_backlightLevel; }
#endif
#if PLATFORM(COCOA)
@@ -409,6 +410,10 @@
#endif
#endif
+#if PLATFORM(IOS_FAMILY)
+ void backlightLevelDidChange(float backlightLevel);
+#endif
+
#if ENABLE(VIDEO)
void suspendAllMediaBuffering();
void resumeAllMediaBuffering();
@@ -506,6 +511,10 @@
#if ENABLE(MEDIA_STREAM) && ENABLE(SANDBOX_EXTENSIONS)
HashMap<String, RefPtr<SandboxExtension>> m_mediaCaptureSandboxExtensions;
#endif
+
+#if PLATFORM(IOS_FAMILY)
+ float m_backlightLevel { 0 };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (242744 => 242745)
--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-03-11 22:15:51 UTC (rev 242745)
@@ -134,6 +134,10 @@
#endif
#endif
+#if PLATFORM(IOS_FAMILY)
+ BacklightLevelDidChange(float backlightLevel)
+#endif
+
IsJITEnabled() -> (bool enabled) Async
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (242744 => 242745)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-03-11 22:12:28 UTC (rev 242744)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2019-03-11 22:15:51 UTC (rev 242745)
@@ -75,6 +75,7 @@
#import <wtf/cocoa/NSURLExtras.h>
#if PLATFORM(IOS_FAMILY)
+#import "UIKitSPI.h"
#import "WKAccessibilityWebPageObjectIOS.h"
#import <UIKit/UIAccessibility.h>
#import <pal/spi/ios/GraphicsServicesSPI.h>
@@ -698,6 +699,28 @@
}
#endif
+#if PLATFORM(IOS_FAMILY)
+static float currentBacklightLevel()
+{
+ return WebProcess::singleton().backlightLevel();
+}
+
+void WebProcess::backlightLevelDidChange(float backlightLevel)
+{
+ m_backlightLevel = backlightLevel;
+
+ // Swizzle -[UIDevice _backlightLevel]
+ // FIXME: remove the swizzling and related code once <rdar://problem/47603552> is fixed.
+ 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);