Changeset 275486 in webkit
- Timestamp:
- Apr 5, 2021 9:02:40 PM (3 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r275485 r275486 1 2021-04-05 Alex Christensen <achristensen@webkit.org> 2 3 Reduce crash inside getAuditToken 4 https://bugs.webkit.org/show_bug.cgi?id=224196 5 <rdar://74536285> 6 7 Reviewed by David Kilzer. 8 9 Something is crashing inside the call to getAuditToken, and I believe it is happening during teardown of the network process. 10 After many days of head scratching and many previous attempts at fixing this problem, it persists. 11 Since direct strategies at fixing this problem have failed, I now try something different. 12 Instead of calling getAuditToken at the beginning of every resource load to ask if the parent process has an entitlement, 13 I now call it only once per process. That should make things faster and less crashy. Otherwise no change in behavior. 14 15 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 16 (WebKit::activateSessionCleanup): 17 (WebKit::NetworkSessionCocoa::sessionWrapperForTask): 18 * Shared/Cocoa/DefaultWebBrowserChecks.h: 19 * Shared/Cocoa/DefaultWebBrowserChecks.mm: 20 (WebKit::doesParentProcessHaveITPEnabled): 21 (WebKit::isParentProcessAFullWebBrowser): 22 * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: 23 (WebKit::WebCore::isWebBrowser): 24 * WebProcess/WebPage/WebPage.cpp: 25 (WebKit::WebPage::isParentProcessAWebBrowser const): 26 1 27 2021-04-05 Chris Dumez <cdumez@apple.com> 2 28 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r275415 r275486 1146 1146 1147 1147 #if !PLATFORM(IOS_FAMILY_SIMULATOR) 1148 auto parentAuditToken = session.networkProcess().parentProcessConnection()->getAuditToken(); 1149 RELEASE_ASSERT(parentAuditToken); // This should be impossible. 1150 1151 bool itpEnabled = doesParentProcessHaveITPEnabled(parentAuditToken, parameters.appHasRequestedCrossWebsiteTrackingPermission); 1148 bool itpEnabled = doesParentProcessHaveITPEnabled(session.networkProcess(), parameters.appHasRequestedCrossWebsiteTrackingPermission); 1152 1149 bool passedEnabledState = session.isResourceLoadStatisticsEnabled(); 1153 1150 … … 1351 1348 { 1352 1349 auto shouldBeConsideredAppBound = isNavigatingToAppBoundDomain ? *isNavigatingToAppBoundDomain : NavigatingToAppBoundDomain::Yes; 1353 if (RefPtr<IPC::Connection> connection = networkProcess().parentProcessConnection()) { 1354 if (isParentProcessAFullWebBrowser(connection->getAuditToken())) 1355 shouldBeConsideredAppBound = NavigatingToAppBoundDomain::No; 1356 } 1350 if (isParentProcessAFullWebBrowser(networkProcess())) 1351 shouldBeConsideredAppBound = NavigatingToAppBoundDomain::No; 1357 1352 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1358 1353 if (auto* storageSession = networkStorageSession()) { -
trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.h
r271283 r275486 35 35 namespace WebKit { 36 36 37 class AuxiliaryProcess; 38 37 39 bool hasRequestedCrossWebsiteTrackingPermission(); 38 40 bool hasProhibitedUsageStrings(); … … 41 43 void determineITPState(); 42 44 bool doesAppHaveITPEnabled(); 43 bool doesParentProcessHaveITPEnabled( Optional<audit_token_t>, bool);45 bool doesParentProcessHaveITPEnabled(AuxiliaryProcess&, bool hasRequestedCrossWebsiteTrackingPermission); 44 46 bool isFullWebBrowser(); 45 bool isParentProcessAFullWebBrowser(Optional<audit_token_t>); 47 bool isParentProcessAFullWebBrowser(AuxiliaryProcess&); 48 49 #define WEBKIT_PARENT_PROCESS_FULL_WEB_BROWSER_PARAMETER_AUXILIARY_PROCESS 1 46 50 47 51 } // namespace WebKit -
trunk/Source/WebKit/Shared/Cocoa/DefaultWebBrowserChecks.mm
r275410 r275486 27 27 #import "DefaultWebBrowserChecks.h" 28 28 29 #import "AuxiliaryProcess.h" 30 #import "Connection.h" 31 #import "Logging.h" 29 32 #import "TCCSPI.h" 30 33 #import <WebCore/RegistrableDomain.h> … … 156 159 } 157 160 158 bool doesParentProcessHaveITPEnabled( Optional<audit_token_t> auditToken, bool hasRequestedCrossWebsiteTrackingPermissionValue)161 bool doesParentProcessHaveITPEnabled(AuxiliaryProcess& auxiliaryProcess, bool hasRequestedCrossWebsiteTrackingPermission) 159 162 { 160 163 ASSERT(isInWebKitChildProcess()); 161 164 ASSERT(RunLoop::isMain()); 162 165 163 if (!isParentProcessAFullWebBrowser(auditToken) && !hasRequestedCrossWebsiteTrackingPermissionValue) 164 return true; 165 166 TCCAccessPreflightResult result = kTCCAccessPreflightDenied; 166 static bool itpEnabled { true }; 167 static dispatch_once_t once; 168 dispatch_once(&once, ^{ 169 if (!isParentProcessAFullWebBrowser(auxiliaryProcess) && !hasRequestedCrossWebsiteTrackingPermission) 170 return; 171 172 TCCAccessPreflightResult result = kTCCAccessPreflightDenied; 167 173 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000) 168 if (auditToken) 174 RefPtr<IPC::Connection> connection = auxiliaryProcess.parentProcessConnection(); 175 if (!connection) { 176 ASSERT_NOT_REACHED(); 177 RELEASE_LOG_ERROR(IPC, "Unable to get parent process connection"); 178 return; 179 } 180 181 auto auditToken = connection->getAuditToken(); 182 if (!auditToken) { 183 ASSERT_NOT_REACHED(); 184 RELEASE_LOG_ERROR(IPC, "Unable to get parent process audit token"); 185 return; 186 } 169 187 result = TCCAccessPreflightWithAuditToken(getkTCCServiceWebKitIntelligentTrackingPrevention(), auditToken.value(), nullptr); 170 188 #endif 171 return result != kTCCAccessPreflightDenied; 189 itpEnabled = result != kTCCAccessPreflightDenied; 190 }); 191 return itpEnabled; 172 192 } 173 193 … … 208 228 } 209 229 210 bool isParentProcessAFullWebBrowser( Optional<audit_token_t> auditToken)230 bool isParentProcessAFullWebBrowser(AuxiliaryProcess& auxiliaryProcess) 211 231 { 212 232 ASSERT(isInWebKitChildProcess()); 213 if (!auditToken) 214 return false; 215 216 static bool fullWebBrowser; 217 233 234 static bool fullWebBrowser { false }; 218 235 static dispatch_once_t once; 219 236 dispatch_once(&once, ^{ 220 fullWebBrowser = WTF::hasEntitlement(auditToken.value(), "com.apple.developer.web-browser"); 221 }); 222 223 return fullWebBrowser || isRunningTest(WebCore::applicationBundleIdentifier()); 237 if (isRunningTest(WebCore::applicationBundleIdentifier())) { 238 fullWebBrowser = true; 239 return; 240 } 241 242 RefPtr<IPC::Connection> connection = auxiliaryProcess.parentProcessConnection(); 243 if (!connection) { 244 ASSERT_NOT_REACHED(); 245 RELEASE_LOG_ERROR(IPC, "Unable to get parent process connection"); 246 return; 247 } 248 249 auto auditToken = connection->getAuditToken(); 250 if (!auditToken) { 251 ASSERT_NOT_REACHED(); 252 RELEASE_LOG_ERROR(IPC, "Unable to get parent process audit token"); 253 return; 254 } 255 256 fullWebBrowser = WTF::hasEntitlement(*auditToken, "com.apple.developer.web-browser"); 257 }); 258 259 return fullWebBrowser; 224 260 } 225 261 -
trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
r272345 r275486 51 51 52 52 namespace { 53 staticbool isWebBrowser()53 inline bool isWebBrowser() 54 54 { 55 if (auto* connection = WebProcess::singleton().parentProcessConnection()) 56 return isParentProcessAFullWebBrowser(connection->getAuditToken()); 57 return false; 55 return isParentProcessAFullWebBrowser(WebProcess::singleton()); 58 56 } 59 57 } -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r275485 r275486 3827 3827 { 3828 3828 #if HAVE(AUDIT_TOKEN) 3829 if (auto* connection = WebProcess::singleton().parentProcessConnection()) 3830 return isParentProcessAFullWebBrowser(connection->getAuditToken()); 3829 return isParentProcessAFullWebBrowser(WebProcess::singleton()); 3831 3830 #endif 3832 3831 return false;
Note: See TracChangeset
for help on using the changeset viewer.