<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169457] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169457">169457</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2014-05-29 11:24:43 -0700 (Thu, 29 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac] Always use plug-in sandbox with sandboxed clients
https://bugs.webkit.org/show_bug.cgi?id=133358
<rdar://problem/15637695>
Reviewed by Anders Carlsson.
* PluginProcess/mac/PluginProcessMac.mm: (WebKit::PluginProcess::initializeSandbox):
Refuse to start if parent process is sandboxed, and plug-in process is not going to be.
None of this should run in normal case, because there are also checks on UI process side.
* Shared/Plugins/PluginModuleInfo.h:
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::NetscapePluginModule::getPluginInfo):
Added a member to PluginModuleInfo, telling whether the plug-in has a sandbox profile.
* Shared/Plugins/Netscape/mac/PluginInformationMac.mm:
(WebKit::getPlatformPluginModuleInformation): Use the new PluginModuleInfo member,
we no longer need to check the file system here.
* WebKit2.xcodeproj/project.pbxproj:
* Shared/mac/SandboxUtilities.h: Added.
* Shared/mac/SandboxUtilities.cpp: Added. (WebKit::processIsSandboxed):
This code is simple, but include magic is not. Moved it to a separate file to
avoid repeating.
* UIProcess/API/C/mac/WKContextPrivateMac.mm: Removed an unused include.
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::shouldUsePlugin): Don't use unsandboxed plug-ins in
sandboxed applications.
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::platformGetLaunchOptions): Don't ever pass disable-sandbox
from sandboxed processes.
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
Use the new shared code in SandboxUtilities.h.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessmacPluginProcessMacmm">trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsNetscapemacNetscapePluginModuleMacmm">trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsNetscapemacPluginInformationMacmm">trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsPluginModuleInfoh">trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICmacWKContextPrivateMacmm">trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPluginsmacPluginInfoStoreMacmm">trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPluginsmacPluginProcessProxyMacmm">trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2SharedmacSandboxUtilitiescpp">trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedmacSandboxUtilitiesh">trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2014-05-29 Alexey Proskuryakov <ap@apple.com>
+
+ [Mac] Always use plug-in sandbox with sandboxed clients
+ https://bugs.webkit.org/show_bug.cgi?id=133358
+ <rdar://problem/15637695>
+
+ Reviewed by Anders Carlsson.
+
+ * PluginProcess/mac/PluginProcessMac.mm: (WebKit::PluginProcess::initializeSandbox):
+ Refuse to start if parent process is sandboxed, and plug-in process is not going to be.
+ None of this should run in normal case, because there are also checks on UI process side.
+
+ * Shared/Plugins/PluginModuleInfo.h:
+ * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+ (WebKit::NetscapePluginModule::getPluginInfo):
+ Added a member to PluginModuleInfo, telling whether the plug-in has a sandbox profile.
+
+ * Shared/Plugins/Netscape/mac/PluginInformationMac.mm:
+ (WebKit::getPlatformPluginModuleInformation): Use the new PluginModuleInfo member,
+ we no longer need to check the file system here.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ * Shared/mac/SandboxUtilities.h: Added.
+ * Shared/mac/SandboxUtilities.cpp: Added. (WebKit::processIsSandboxed):
+ This code is simple, but include magic is not. Moved it to a separate file to
+ avoid repeating.
+
+ * UIProcess/API/C/mac/WKContextPrivateMac.mm: Removed an unused include.
+
+ * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
+ (WebKit::PluginInfoStore::shouldUsePlugin): Don't use unsandboxed plug-ins in
+ sandboxed applications.
+
+ * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+ (WebKit::PluginProcessProxy::platformGetLaunchOptions): Don't ever pass disable-sandbox
+ from sandboxed processes.
+
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+ (WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
+ Use the new shared code in SandboxUtilities.h.
+
</ins><span class="cx"> 2014-05-29 Timothy Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Crash loading skydrive.com (assertion under RemoteLayerTreeDisplayRefreshMonitor)
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessmacPluginProcessMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import "PluginProcessShim.h"
</span><span class="cx"> #import "PluginSandboxProfile.h"
</span><span class="cx"> #import "SandboxInitializationParameters.h"
</span><ins>+#import "SandboxUtilities.h"
</ins><span class="cx"> #import <CoreAudio/AudioHardware.h>
</span><span class="cx"> #import <WebCore/LocalizedStrings.h>
</span><span class="cx"> #import <WebKitSystemInterface.h>
</span><span class="lines">@@ -456,12 +457,32 @@
</span><span class="cx">
</span><span class="cx"> void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
</span><span class="cx"> {
</span><del>- if (parameters.extraInitializationData.get("disable-sandbox") == "1")
</del><ins>+ // PluginProcess may already be sandboxed if its parent process was sandboxed, and launched a child process instead of an XPC service.
+ // This is generally not expected, however we currently always spawn a child process to create a MIME type preferences file.
+ if (processIsSandboxed(getpid())) {
+ RELEASE_ASSERT(!parameters.connectionIdentifier.xpcConnection);
+ RELEASE_ASSERT(processIsSandboxed(getppid()));
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx">
</span><ins>+ bool parentIsSandboxed = parameters.connectionIdentifier.xpcConnection && processIsSandboxed(xpc_connection_get_pid(parameters.connectionIdentifier.xpcConnection.get()));
+
+ if (parameters.extraInitializationData.get("disable-sandbox") == "1") {
+ if (parentIsSandboxed) {
+ WTFLogAlways("Sandboxed processes may not disable plug-in sandbox, terminating %s.", parameters.clientIdentifier.utf8().data());
+ exit(EX_OSERR);
+ }
+ return;
+ }
+
</ins><span class="cx"> String sandboxProfile = pluginSandboxProfile(m_pluginBundleIdentifier);
</span><del>- if (sandboxProfile.isEmpty())
</del><ins>+ if (sandboxProfile.isEmpty()) {
+ if (parentIsSandboxed) {
+ WTFLogAlways("Sandboxed processes may only use sandboxed plug-ins, terminating %s.", parameters.clientIdentifier.utf8().data());
+ exit(EX_OSERR);
+ }
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> sandboxParameters.setSandboxProfile(sandboxProfile);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx">
</span><span class="cx"> #import "config.h"
</span><span class="cx">
</span><ins>+#import "SandboxUtilities.h"
</ins><span class="cx"> #import "XPCServiceEntryPoint.h"
</span><span class="cx">
</span><span class="cx"> #if __has_include(<xpc/private.h>)
</span><span class="lines">@@ -34,16 +35,6 @@
</span><span class="cx"> extern "C" mach_port_t xpc_dictionary_copy_mach_send(xpc_object_t, const char*);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if __has_include(<sandbox/private.h>)
-#import <sandbox/private.h>
-#else
-enum sandbox_filter_type {
- SANDBOX_FILTER_NONE,
-};
-extern "C"
-int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
-#endif
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> XPCServiceInitializerDelegate::~XPCServiceInitializerDelegate()
</span><span class="lines">@@ -104,9 +95,7 @@
</span><span class="cx">
</span><span class="cx"> bool XPCServiceInitializerDelegate::isClientSandboxed()
</span><span class="cx"> {
</span><del>- pid_t clientPID = xpc_connection_get_pid(m_connection.get());
-
- return sandbox_check(clientPID, nullptr, SANDBOX_FILTER_NONE);
</del><ins>+ return processIsSandboxed(xpc_connection_get_pid(m_connection.get()));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsNetscapemacNetscapePluginModuleMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx">
</span><span class="cx"> #import "PluginProcessProxy.h"
</span><ins>+#import "PluginSandboxProfile.h"
</ins><span class="cx"> #import <WebCore/WebCoreNSStringExtras.h>
</span><span class="cx"> #import <wtf/HashSet.h>
</span><span class="cx"> #import <wtf/MainThread.h>
</span><span class="lines">@@ -386,7 +387,9 @@
</span><span class="cx"> if (!getPluginInfoFromPropertyLists(bundle.get(), plugin) &&
</span><span class="cx"> !getPluginInfoFromCarbonResources(bundle.get(), plugin))
</span><span class="cx"> return false;
</span><del>-
</del><ins>+
+ plugin.hasSandboxProfile = pluginHasSandboxProfile(plugin.bundleIdentifier);
+
</ins><span class="cx"> RetainPtr<CFStringRef> filename = adoptCF(CFURLCopyLastPathComponent(bundleURL.get()));
</span><span class="cx"> plugin.info.file = filename.get();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsNetscapemacPluginInformationMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #import "APINumber.h"
</span><span class="cx"> #import "APIString.h"
</span><span class="cx"> #import "PluginModuleInfo.h"
</span><del>-#import "PluginSandboxProfile.h"
</del><span class="cx"> #import "StringUtilities.h"
</span><span class="cx"> #import <WebKitSystemInterface.h>
</span><span class="cx">
</span><span class="lines">@@ -43,7 +42,7 @@
</span><span class="cx"> map.set(pluginInformationBundleVersionKey(), API::String::create(plugin.versionString));
</span><span class="cx"> map.set(pluginInformationBundleShortVersionKey(), API::String::create(plugin.shortVersionString));
</span><span class="cx"> map.set(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey(), API::Boolean::create(WKIsPluginUpdateAvailable(nsStringFromWebCoreString(plugin.bundleIdentifier))));
</span><del>- map.set(pluginInformationHasSandboxProfileKey(), API::Boolean::create(pluginHasSandboxProfile(plugin.bundleIdentifier)));
</del><ins>+ map.set(pluginInformationHasSandboxProfileKey(), API::Boolean::create(plugin.hasSandboxProfile));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsPluginModuleInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> String versionString;
</span><span class="cx"> String shortVersionString;
</span><span class="cx"> String preferencePanePath;
</span><ins>+ bool hasSandboxProfile;
</ins><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx"> bool requiresGtk2;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacSandboxUtilitiescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp (0 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp         (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SandboxUtilities.h"
+
+#if __has_include(<sandbox/private.h>)
+#import <sandbox/private.h>
+#else
+enum sandbox_filter_type {
+ SANDBOX_FILTER_NONE,
+};
+extern "C"
+int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
+#endif
+
+namespace WebKit {
+
+bool processIsSandboxed(pid_t pid)
+{
+ return sandbox_check(pid, nullptr, SANDBOX_FILTER_NONE);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedmacSandboxUtilitiesh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h (0 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h         (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SandboxUtilities_h
+#define SandboxUtilities_h
+
+#include <sys/types.h>
+
+namespace WebKit {
+
+bool processIsSandboxed(pid_t);
+
+}
+
+#endif // SandboxUtilities_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICmacWKContextPrivateMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #import "ImmutableDictionary.h"
</span><span class="cx"> #import "PluginInfoStore.h"
</span><span class="cx"> #import "PluginInformation.h"
</span><del>-#import "PluginSandboxProfile.h"
</del><span class="cx"> #import "StringUtilities.h"
</span><span class="cx"> #import "WKAPICast.h"
</span><span class="cx"> #import "WKPluginInformation.h"
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPluginsmacPluginInfoStoreMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -28,11 +28,14 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC) && ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx">
</span><ins>+#import "Logging.h"
</ins><span class="cx"> #import "NetscapePluginModule.h"
</span><ins>+#import "SandboxUtilities.h"
</ins><span class="cx"> #import "WebKitSystemInterface.h"
</span><span class="cx"> #import <WebCore/WebCoreNSStringExtras.h>
</span><span class="cx"> #import <wtf/HashSet.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><ins>+#import <wtf/text/CString.h>
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -91,9 +94,16 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (plugin.bundleIdentifier == "com.apple.java.JavaAppletPlugin")
</del><ins>+ if (plugin.bundleIdentifier == "com.apple.java.JavaAppletPlugin") {
+ LOG(Plugins, "Ignoring com.apple.java.JavaAppletPlugin");
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><ins>+ if (processIsSandboxed(getpid()) && !plugin.hasSandboxProfile) {
+ LOG(Plugins, "Ignoring unsandboxed plug-in %s", plugin.bundleIdentifier.utf8().data());
+ return false;
+ }
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPluginsmacPluginProcessProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import "EnvironmentVariables.h"
</span><span class="cx"> #import "PluginProcessCreationParameters.h"
</span><span class="cx"> #import "PluginProcessMessages.h"
</span><ins>+#import "SandboxUtilities.h"
</ins><span class="cx"> #import "WebKitSystemInterface.h"
</span><span class="cx"> #import <QuartzCore/CARemoteLayerServer.h>
</span><span class="cx"> #import <WebCore/FileSystem.h>
</span><span class="lines">@@ -151,9 +152,12 @@
</span><span class="cx"> launchOptions.executableHeap = PluginProcessProxy::pluginNeedsExecutableHeap(pluginProcessAttributes.moduleInfo);
</span><span class="cx"> launchOptions.extraInitializationData.add("plugin-path", pluginProcessAttributes.moduleInfo.path);
</span><span class="cx">
</span><del>- // FIXME: Don't allow this if the UI process is sandboxed.
- if (pluginProcessAttributes.sandboxPolicy == PluginProcessSandboxPolicyUnsandboxed)
- launchOptions.extraInitializationData.add("disable-sandbox", "1");
</del><ins>+ if (pluginProcessAttributes.sandboxPolicy == PluginProcessSandboxPolicyUnsandboxed) {
+ if (!processIsSandboxed(getpid()))
+ launchOptions.extraInitializationData.add("disable-sandbox", "1");
+ else
+ WTFLogAlways("Main process is sandboxed, ignoring plug-in sandbox policy");
+ }
</ins><span class="cx">
</span><span class="cx"> launchOptions.useXPC = shouldUseXPC(launchOptions, pluginProcessAttributes);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -1583,6 +1583,8 @@
</span><span class="cx">                 E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */; };
</span><span class="cx">                 E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */ = {isa = PBXBuildFile; fileRef = E19582D2153CBFD700B60875 /* PDFKitImports.h */; };
</span><span class="cx">                 E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19582D4153CC05300B60875 /* PDFKitImports.mm */; };
</span><ins>+                E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E19BDA88193686A400B97F57 /* SandboxUtilities.h */; };
+                E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */; };
</ins><span class="cx">                 E19BDA86193665E300B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */; };
</span><span class="cx">                 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };
</span><span class="cx">                 E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A31734134CEA80007C9A4F /* AttributedString.mm */; };
</span><span class="lines">@@ -3634,6 +3636,8 @@
</span><span class="cx">                 E19582D2153CBFD700B60875 /* PDFKitImports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFKitImports.h; sourceTree = "<group>"; };
</span><span class="cx">                 E19582D4153CC05300B60875 /* PDFKitImports.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFKitImports.mm; sourceTree = "<group>"; };
</span><span class="cx">                 E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebProcess.sb; sourceTree = "<group>"; };
</span><ins>+                E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SandboxUtilities.cpp; sourceTree = "<group>"; };
+                E19BDA88193686A400B97F57 /* SandboxUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxUtilities.h; sourceTree = "<group>"; };
</ins><span class="cx">                 E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = "<group>"; };
</span><span class="cx">                 E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
</span><span class="cx">                 E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -5997,6 +6001,8 @@
</span><span class="cx">                                 1AAB4AA91296F1540023952F /* SandboxExtensionMac.mm */,
</span><span class="cx">                                 E1E552C216AE065E004ED653 /* SandboxInitialiationParametersMac.mm */,
</span><span class="cx">                                 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */,
</span><ins>+                                E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */,
+                                E19BDA88193686A400B97F57 /* SandboxUtilities.h */,
</ins><span class="cx">                                 51D130501382EAC000351EDD /* SecItemRequestData.h */,
</span><span class="cx">                                 51D130511382EAC000351EDD /* SecItemResponseData.cpp */,
</span><span class="cx">                                 51D130521382EAC000351EDD /* SecItemResponseData.h */,
</span><span class="lines">@@ -6882,6 +6888,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 1ADAE12E1919A5B400F48E21 /* WKPreferences.h in Headers */,
</span><ins>+                                E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -8698,6 +8705,7 @@
</span><span class="cx">                                 2DA944951884E3B500ED86DB /* WKViewIOS.mm in Sources */,
</span><span class="cx">                                 BC14DF78120B5B7900826C0C /* InjectedBundleScriptWorld.cpp in Sources */,
</span><span class="cx">                                 1AE49A4A11FFA8CE0048B464 /* JSNPMethod.cpp in Sources */,
</span><ins>+                                E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */,
</ins><span class="cx">                                 2D6AB542192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.mm in Sources */,
</span><span class="cx">                                 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */,
</span><span class="cx">                                 BCE0937714FB128C001138D9 /* LayerHostingContext.mm in Sources */,
</span></span></pre>
</div>
</div>
</body>
</html>