Changeset 249700 in webkit
- Timestamp:
- Sep 9, 2019, 8:20:08 PM (7 years ago)
- Location:
- branches/safari-608-branch/Source/WebKit
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/AuxiliaryProcessProxy.cpp (modified) (2 diffs)
-
UIProcess/WebPageProxy.cpp (modified) (5 diffs)
-
WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608-branch/Source/WebKit/ChangeLog
r249699 r249700 1 2019-09-09 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r249649. rdar://problem/55198071 4 5 [macOS] Pid is sometimes invalid when creating sandbox extensions by pid. 6 https://bugs.webkit.org/show_bug.cgi?id=201543 7 <rdar://problem/54733465> 8 9 Reviewed by Brent Fulgham. 10 11 There is a race condition when starting a load of a local file, where the WebContent process has not finished 12 launching yet, and its pid is not available. When we try to create a sandbox extension by using the pid of the 13 WebContent process, it is not available in the cases where the WebContent process has just launched and has not 14 finished launching yet. This patch creates a new dummy Web page message, 'LoadRequestWaitingForPID', which will 15 be sent instead of a normal 'LoadRequest' message, and only when the WebContent process has not finished 16 launching. When the WebContent process has finished launching, and we are about to actually send the pending 17 messages, we can detect that a 'LoadRequestWaitingForPID' has been appended for sending, and replace it with a 18 normal 'LoadReqest' message where we have created the sandbox extension issue with a valid pid. The message 19 'LoadRequestWaitingForPID' is never intended to reach the WebContent process, it is just there to replace with 20 a normal 'LoadRequest' message with a new sandbox extension. In the implementation of the message handler on 21 the WebContent process side, we assert that the method is never called. This patch makes sure the ordering of 22 the Web page messages are the same, even when we modify the message. 23 24 * UIProcess/AuxiliaryProcessProxy.cpp: 25 (WebKit::AuxiliaryProcessProxy::didFinishLaunching): 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle): 28 (WebKit::WebPageProxy::loadRequestWithNavigationShared): 29 (WebKit::WebPageProxy::loadFile): 30 * WebProcess/WebPage/WebPage.cpp: 31 (WebKit::WebPage::fileLoadRequest): 32 * WebProcess/WebPage/WebPage.h: 33 * WebProcess/WebPage/WebPage.messages.in: 34 35 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249649 268f45cc-cd09-0410-ab3c-d52691b4dbfc 36 37 2019-09-09 Per Arne Vollan <pvollan@apple.com> 38 39 [macOS] Pid is sometimes invalid when creating sandbox extensions by pid. 40 https://bugs.webkit.org/show_bug.cgi?id=201543 41 <rdar://problem/54733465> 42 43 Reviewed by Brent Fulgham. 44 45 There is a race condition when starting a load of a local file, where the WebContent process has not finished 46 launching yet, and its pid is not available. When we try to create a sandbox extension by using the pid of the 47 WebContent process, it is not available in the cases where the WebContent process has just launched and has not 48 finished launching yet. This patch creates a new dummy Web page message, 'LoadRequestWaitingForPID', which will 49 be sent instead of a normal 'LoadRequest' message, and only when the WebContent process has not finished 50 launching. When the WebContent process has finished launching, and we are about to actually send the pending 51 messages, we can detect that a 'LoadRequestWaitingForPID' has been appended for sending, and replace it with a 52 normal 'LoadReqest' message where we have created the sandbox extension issue with a valid pid. The message 53 'LoadRequestWaitingForPID' is never intended to reach the WebContent process, it is just there to replace with 54 a normal 'LoadRequest' message with a new sandbox extension. In the implementation of the message handler on 55 the WebContent process side, we assert that the method is never called. This patch makes sure the ordering of 56 the Web page messages are the same, even when we modify the message. 57 58 * UIProcess/AuxiliaryProcessProxy.cpp: 59 (WebKit::AuxiliaryProcessProxy::didFinishLaunching): 60 * UIProcess/WebPageProxy.cpp: 61 (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle): 62 (WebKit::WebPageProxy::loadRequestWithNavigationShared): 63 (WebKit::WebPageProxy::loadFile): 64 * WebProcess/WebPage/WebPage.cpp: 65 (WebKit::WebPage::fileLoadRequest): 66 * WebProcess/WebPage/WebPage.h: 67 * WebProcess/WebPage/WebPage.messages.in: 68 1 69 2019-09-09 Kocsen Chung <kocsen_chung@apple.com> 2 70 -
branches/safari-608-branch/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
r242303 r249700 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 } -
branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.cpp
r249691 r249700 1056 1056 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1057 1057 if (SandboxExtension::createHandleForReadByPid(resourceDirectoryURL.fileSystemPath(), process.processIdentifier(), sandboxExtensionHandle)) { 1058 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL);1058 process.assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1059 1059 return; 1060 1060 } 1061 #e ndif1061 #else 1062 1062 if (SandboxExtension::createHandle(resourceDirectoryURL.fileSystemPath(), SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) { 1063 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL);1063 process.assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1064 1064 return; 1065 1065 } 1066 #endif 1066 1067 } 1067 1068 … … 1077 1078 return; 1078 1079 } 1079 #e ndif1080 #else 1080 1081 if (SandboxExtension::createHandle("/", SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) { 1081 1082 willAcquireUniversalFileReadSandboxExtension(process); 1082 1083 return; 1083 1084 } 1085 #endif 1084 1086 1085 1087 #if PLATFORM(COCOA) … … 1091 1093 auto baseURL = URL(URL(), url.baseAsString()); 1092 1094 auto basePath = baseURL.fileSystemPath(); 1093 if (!basePath.isNull() && SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) 1094 m_process->assumeReadAccessToBaseURL(*this, baseURL); 1095 if (basePath.isNull()) 1096 return; 1097 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1098 if (SandboxExtension::createHandleForReadByPid(basePath, process.processIdentifier(), sandboxExtensionHandle)) 1099 process.assumeReadAccessToBaseURL(*this, baseURL); 1100 #else 1101 if (SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) 1102 process.assumeReadAccessToBaseURL(*this, baseURL); 1103 #endif 1095 1104 } 1096 1105 … … 1150 1159 addPlatformLoadParameters(loadParameters); 1151 1160 1161 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1162 if (processIdentifier() || !url.isLocalFile()) 1163 process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID); 1164 else { 1165 String sandboxExtensionPath; 1166 if (!m_pageLoadState.resourceDirectoryURL().isEmpty()) { 1167 sandboxExtensionPath = m_pageLoadState.resourceDirectoryURL().fileSystemPath(); 1168 process->assumeReadAccessToBaseURL(*this, m_pageLoadState.resourceDirectoryURL()); 1169 } else { 1170 sandboxExtensionPath = "/"; 1171 willAcquireUniversalFileReadSandboxExtension(process); 1172 } 1173 process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, sandboxExtensionPath), m_pageID); 1174 } 1175 #else 1152 1176 process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID); 1177 #endif 1153 1178 process->responsivenessTimer().start(); 1154 1179 } … … 1197 1222 loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get()); 1198 1223 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1199 if (!SandboxExtension::createHandleForReadByPid(resourceDirectoryPath, processIdentifier(), loadParameters.sandboxExtensionHandle))1200 #e ndif1224 SandboxExtension::createHandleForReadByPid(resourceDirectoryPath, processIdentifier(), loadParameters.sandboxExtensionHandle); 1225 #else 1201 1226 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::Type::ReadOnly, loadParameters.sandboxExtensionHandle); 1227 #endif 1202 1228 addPlatformLoadParameters(loadParameters); 1203 1229 1204 1230 m_process->assumeReadAccessToBaseURL(*this, resourceDirectoryURL); 1231 #if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID) 1232 if (processIdentifier()) 1233 m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID); 1234 else 1235 m_process->send(Messages::WebPage::LoadRequestWaitingForPID(loadParameters, resourceDirectoryPath), m_pageID); 1236 #else 1205 1237 m_process->send(Messages::WebPage::LoadRequest(loadParameters), m_pageID); 1238 #endif 1206 1239 m_process->responsivenessTimer().start(); 1207 1240 -
branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r249012 r249700 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 { -
branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.h
r249012 r249700 1310 1310 void platformDidReceiveLoadParameters(const LoadParameters&); 1311 1311 void loadRequest(LoadParameters&&); 1312 void loadRequestWaitingForPID(LoadParameters&&, const String&); 1312 1313 void loadData(LoadParameters&&); 1313 1314 void loadAlternateHTML(LoadParameters&&); -
branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r247982 r249700 166 166 LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, uint64_t 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.