Changeset 249649 in webkit
- Timestamp:
- Sep 9, 2019 10:44:33 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r249647 r249649 1 2019-09-09 Per Arne Vollan <pvollan@apple.com> 2 3 [macOS] Pid is sometimes invalid when creating sandbox extensions by pid. 4 https://bugs.webkit.org/show_bug.cgi?id=201543 5 <rdar://problem/54733465> 6 7 Reviewed by Brent Fulgham. 8 9 There is a race condition when starting a load of a local file, where the WebContent process has not finished 10 launching yet, and its pid is not available. When we try to create a sandbox extension by using the pid of the 11 WebContent process, it is not available in the cases where the WebContent process has just launched and has not 12 finished launching yet. This patch creates a new dummy Web page message, 'LoadRequestWaitingForPID', which will 13 be sent instead of a normal 'LoadRequest' message, and only when the WebContent process has not finished 14 launching. When the WebContent process has finished launching, and we are about to actually send the pending 15 messages, we can detect that a 'LoadRequestWaitingForPID' has been appended for sending, and replace it with a 16 normal 'LoadReqest' message where we have created the sandbox extension issue with a valid pid. The message 17 'LoadRequestWaitingForPID' is never intended to reach the WebContent process, it is just there to replace with 18 a normal 'LoadRequest' message with a new sandbox extension. In the implementation of the message handler on 19 the WebContent process side, we assert that the method is never called. This patch makes sure the ordering of 20 the Web page messages are the same, even when we modify the message. 21 22 * UIProcess/AuxiliaryProcessProxy.cpp: 23 (WebKit::AuxiliaryProcessProxy::didFinishLaunching): 24 * UIProcess/WebPageProxy.cpp: 25 (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle): 26 (WebKit::WebPageProxy::loadRequestWithNavigationShared): 27 (WebKit::WebPageProxy::loadFile): 28 * WebProcess/WebPage/WebPage.cpp: 29 (WebKit::WebPage::fileLoadRequest): 30 * WebProcess/WebPage/WebPage.h: 31 * WebProcess/WebPage/WebPage.messages.in: 32 1 33 2019-09-09 Youenn Fablet <youenn@apple.com> 2 34 -
trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
r247828 r249649 28 28 29 29 #include "AuxiliaryProcessMessages.h" 30 #include "LoadParameters.h" 31 #include "WebPageMessages.h" 30 32 #include <wtf/RunLoop.h> 31 33 … … 176 178 std::unique_ptr<IPC::Encoder> message = WTFMove(m_pendingMessages[i].first); 177 179 OptionSet<IPC::SendOption> sendOptions = m_pendingMessages[i].second; 180 #if HAVE(SANDBOX_ISSUE_MACH_EXTENSION_TO_PROCESS_BY_PID) 181 if (message->messageName() == "LoadRequestWaitingForPID") { 182 auto buffer = message->buffer(); 183 auto bufferSize = message->bufferSize(); 184 std::unique_ptr<IPC::Decoder> decoder = makeUnique<IPC::Decoder>(buffer, bufferSize, nullptr, Vector<IPC::Attachment> { }); 185 LoadParameters loadParameters; 186 String sandboxExtensionPath; 187 if (decoder->decode(loadParameters) && decoder->decode(sandboxExtensionPath)) { 188 SandboxExtension::createHandleForReadByPid(sandboxExtensionPath, processIdentifier(), loadParameters.sandboxExtensionHandle); 189 send(Messages::WebPage::LoadRequest(loadParameters), decoder->destinationID()); 190 continue; 191 } 192 } 193 #endif 178 194 m_connection->sendMessage(WTFMove(message), sendOptions); 179 195 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r249501 r249649 1072 1072 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1073 1073 if (SandboxExtension::createHandleForReadByPid(resourceDirectoryURL.fileSystemPath(), process.processIdentifier(), sandboxExtensionHandle)) { 1074 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL);1074 process.assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1075 1075 return; 1076 1076 } 1077 #e ndif1077 #else 1078 1078 if (SandboxExtension::createHandle(resourceDirectoryURL.fileSystemPath(), SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) { 1079 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL);1079 process.assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1080 1080 return; 1081 1081 } 1082 #endif 1082 1083 } 1083 1084 … … 1093 1094 return; 1094 1095 } 1095 #e ndif1096 #else 1096 1097 if (SandboxExtension::createHandle("/", SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) { 1097 1098 willAcquireUniversalFileReadSandboxExtension(process); 1098 1099 return; 1099 1100 } 1101 #endif 1100 1102 1101 1103 #if PLATFORM(COCOA) … … 1107 1109 auto baseURL = URL(URL(), url.baseAsString()); 1108 1110 auto basePath = baseURL.fileSystemPath(); 1109 if (!basePath.isNull() && SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) 1110 m_process->assumeReadAccessToBaseURL(*this, baseURL); 1111 if (basePath.isNull()) 1112 return; 1113 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1114 if (SandboxExtension::createHandleForReadByPid(basePath, process.processIdentifier(), sandboxExtensionHandle)) 1115 process.assumeReadAccessToBaseURL(*this, baseURL); 1116 #else 1117 if (SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) 1118 process.assumeReadAccessToBaseURL(*this, baseURL); 1119 #endif 1111 1120 } 1112 1121 … … 1166 1175 addPlatformLoadParameters(loadParameters); 1167 1176 1177 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1178 if (processIdentifier() || !url.isLocalFile()) 1179 process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID); 1180 else { 1181 String sandboxExtensionPath; 1182 if (!m_pageLoadState.resourceDirectoryURL().isEmpty()) { 1183 sandboxExtensionPath = m_pageLoadState.resourceDirectoryURL().fileSystemPath(); 1184 process->assumeReadAccessToBaseURL(*this, m_pageLoadState.resourceDirectoryURL()); 1185 } else { 1186 sandboxExtensionPath = "/"; 1187 willAcquireUniversalFileReadSandboxExtension(process); 1188 } 1189 process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, sandboxExtensionPath), webPageID); 1190 } 1191 #else 1168 1192 process->send(Messages::WebPage::LoadRequest(loadParameters), webPageID); 1193 #endif 1169 1194 process->responsivenessTimer().start(); 1170 1195 } … … 1213 1238 loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get()); 1214 1239 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1215 if (!SandboxExtension::createHandleForReadByPid(resourceDirectoryPath, processIdentifier(), loadParameters.sandboxExtensionHandle))1216 #e ndif1240 SandboxExtension::createHandleForReadByPid(resourceDirectoryPath, processIdentifier(), loadParameters.sandboxExtensionHandle); 1241 #else 1217 1242 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::Type::ReadOnly, loadParameters.sandboxExtensionHandle); 1243 #endif 1218 1244 addPlatformLoadParameters(loadParameters); 1219 1245 1220 1246 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1247 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1248 if (processIdentifier()) 1249 m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_webPageID); 1250 else 1251 m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryPath), m_webPageID); 1252 #else 1221 1253 m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_webPageID); 1254 #endif 1222 1255 m_process->responsivenessTimer().start(); 1223 1256 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r249501 r249649 1554 1554 } 1555 1555 1556 // LoadRequestWaitingForPID should never be sent to the WebProcess. It must always be converted to a LoadRequest message. 1557 NO_RETURN void WebPage::loadRequestWaitingForPID(LoadParameters&&, const String&) 1558 { 1559 RELEASE_ASSERT_NOT_REACHED(); 1560 } 1561 1556 1562 void WebPage::loadDataImpl(uint64_t navigationID, bool shouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& websitePolicies, Ref<SharedBuffer>&& sharedBuffer, const String& MIMEType, const String& encodingName, const URL& baseURL, const URL& unreachableURL, const UserData& userData, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy) 1557 1563 { -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r249435 r249649 1318 1318 void platformDidReceiveLoadParameters(const LoadParameters&); 1319 1319 void loadRequest(LoadParameters&&); 1320 void loadRequestWaitingForPID(LoadParameters&&, const String&); 1320 1321 void loadData(LoadParameters&&); 1321 1322 void loadAlternateHTML(LoadParameters&&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r249093 r249649 166 166 LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, WebCore::FrameIdentifier frameID) 167 167 LoadRequest(struct WebKit::LoadParameters loadParameters) 168 LoadRequestWaitingForPID(struct WebKit::LoadParameters loadParameters, String sandboxExtensionPath) 168 169 LoadData(struct WebKit::LoadParameters loadParameters) 169 170 LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)
Note: See TracChangeset
for help on using the changeset viewer.