- Revision
- 183811
- Author
- [email protected]
- Date
- 2015-05-05 09:27:39 -0700 (Tue, 05 May 2015)
Log Message
Crashes in SandboxExtension::consumePermanently when uploading
https://bugs.webkit.org/show_bug.cgi?id=144611
rdar://problem/10156710
Reviewed by Darin Adler.
This only fixes the crashes, uploading still won't work.
Added null checks and some logging that may help us get to the root cause eventually.
* Shared/SandboxExtension.h:
(WebKit::SandboxExtension::createHandle):
(WebKit::SandboxExtension::createHandleForReadWriteDirectory):
* Shared/mac/SandboxExtensionMac.mm:
(WebKit::SandboxExtension::createHandle):
(WebKit::SandboxExtension::createHandleForReadWriteDirectory):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didChooseFilesForOpenPanel):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::extendSandboxForFileFromOpenPanel):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (183810 => 183811)
--- trunk/Source/WebKit2/ChangeLog 2015-05-05 16:22:23 UTC (rev 183810)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-05 16:27:39 UTC (rev 183811)
@@ -1,3 +1,25 @@
+2015-05-05 Alexey Proskuryakov <[email protected]>
+
+ Crashes in SandboxExtension::consumePermanently when uploading
+ https://bugs.webkit.org/show_bug.cgi?id=144611
+ rdar://problem/10156710
+
+ Reviewed by Darin Adler.
+
+ This only fixes the crashes, uploading still won't work.
+ Added null checks and some logging that may help us get to the root cause eventually.
+
+ * Shared/SandboxExtension.h:
+ (WebKit::SandboxExtension::createHandle):
+ (WebKit::SandboxExtension::createHandleForReadWriteDirectory):
+ * Shared/mac/SandboxExtensionMac.mm:
+ (WebKit::SandboxExtension::createHandle):
+ (WebKit::SandboxExtension::createHandleForReadWriteDirectory):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::extendSandboxForFileFromOpenPanel):
+
2015-05-05 Csaba Osztrogonác <[email protected]>
Remove TextureMapperImageBuffer
Modified: trunk/Source/WebKit2/Shared/SandboxExtension.h (183810 => 183811)
--- trunk/Source/WebKit2/Shared/SandboxExtension.h 2015-05-05 16:22:23 UTC (rev 183810)
+++ trunk/Source/WebKit2/Shared/SandboxExtension.h 2015-05-05 16:27:39 UTC (rev 183811)
@@ -90,8 +90,8 @@
};
static PassRefPtr<SandboxExtension> create(const Handle&);
- static void createHandle(const String& path, Type type, Handle&);
- static void createHandleForReadWriteDirectory(const String& path, Handle&); // Will attempt to create the directory.
+ static bool createHandle(const String& path, Type type, Handle&);
+ static bool createHandleForReadWriteDirectory(const String& path, Handle&); // Will attempt to create the directory.
static String createHandleForTemporaryFile(const String& prefix, Type type, Handle&);
~SandboxExtension();
@@ -124,8 +124,8 @@
inline void SandboxExtension::HandleArray::encode(IPC::ArgumentEncoder&) const { }
inline bool SandboxExtension::HandleArray::decode(IPC::ArgumentDecoder&, HandleArray&) { return true; }
inline PassRefPtr<SandboxExtension> SandboxExtension::create(const Handle&) { return 0; }
-inline void SandboxExtension::createHandle(const String&, Type, Handle&) { }
-inline void SandboxExtension::createHandleForReadWriteDirectory(const String&, Handle&) { }
+inline bool SandboxExtension::createHandle(const String&, Type, Handle&) { return true; }
+inline bool SandboxExtension::createHandleForReadWriteDirectory(const String&, Handle&) { return true; }
inline String SandboxExtension::createHandleForTemporaryFile(const String& /*prefix*/, Type, Handle&) {return String();}
inline SandboxExtension::~SandboxExtension() { }
inline bool SandboxExtension::revoke() { return true; }
Modified: trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm (183810 => 183811)
--- trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2015-05-05 16:22:23 UTC (rev 183810)
+++ trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2015-05-05 16:27:39 UTC (rev 183811)
@@ -212,28 +212,31 @@
return String::fromUTF8(resolveSymlinksInPath(path.utf8()));
}
-void SandboxExtension::createHandle(const String& path, Type type, Handle& handle)
+bool SandboxExtension::createHandle(const String& path, Type type, Handle& handle)
{
ASSERT(!handle.m_sandboxExtension);
// FIXME: Do we need both resolveSymlinksInPath() and -stringByStandardizingPath?
CString standardizedPath = resolveSymlinksInPath(fileSystemRepresentation([(NSString *)path stringByStandardizingPath]));
handle.m_sandboxExtension = WKSandboxExtensionCreate(standardizedPath.data(), wkSandboxExtensionType(type));
- if (!handle.m_sandboxExtension)
+ if (!handle.m_sandboxExtension) {
LOG_ERROR("Could not create a sandbox extension for '%s'", path.utf8().data());
+ return false;
+ }
+ return true;
}
-void SandboxExtension::createHandleForReadWriteDirectory(const String& path, SandboxExtension::Handle& handle)
+bool SandboxExtension::createHandleForReadWriteDirectory(const String& path, SandboxExtension::Handle& handle)
{
NSError *error = nil;
NSString *nsPath = path;
if (![[NSFileManager defaultManager] createDirectoryAtPath:nsPath withIntermediateDirectories:YES attributes:nil error:&error]) {
NSLog(@"could not create \"%@\", error %@", nsPath, error);
- return;
+ return false;
}
- SandboxExtension::createHandle(path, SandboxExtension::ReadWrite, handle);
+ return SandboxExtension::createHandle(path, SandboxExtension::ReadWrite, handle);
}
String SandboxExtension::createHandleForTemporaryFile(const String& prefix, Type type, Handle& handle)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (183810 => 183811)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-05-05 16:22:23 UTC (rev 183810)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-05-05 16:27:39 UTC (rev 183811)
@@ -4230,7 +4230,13 @@
// is gated on a way of passing SandboxExtension::Handles in a Vector.
for (size_t i = 0; i < fileURLs.size(); ++i) {
SandboxExtension::Handle sandboxExtensionHandle;
- SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
+ bool createdExtension = SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
+ if (!createdExtension) {
+ // This can legitimately fail if a directory containing the file is deleted after the file was chosen.
+ // We also have reports of cases where this likely fails for some unknown reason, <rdar://problem/10156710>.
+ WTFLogAlways("WebPageProxy::didChooseFilesForOpenPanel: could not create a sandbox extension for '%s'\n", fileURLs[i].utf8().data());
+ continue;
+ }
m_process->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (183810 => 183811)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-05-05 16:22:23 UTC (rev 183810)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-05-05 16:27:39 UTC (rev 183811)
@@ -3293,7 +3293,11 @@
#if ENABLE(SANDBOX_EXTENSIONS)
void WebPage::extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle& handle)
{
- SandboxExtension::create(handle)->consumePermanently();
+ bool result = SandboxExtension::consumePermanently(handle);
+ if (!result) {
+ // We have reports of cases where this fails for some unknown reason, <rdar://problem/10156710>.
+ WTFLogAlways("WebPage::extendSandboxForFileFromOpenPanel(): Could not consume a sandbox extension");
+ }
}
#endif