Bug 187110

Summary: Add nullptr check for xpc_connection_t in AuthenticationManager::initializeConnection
Product: WebKit Reporter: Jiewen Tan <jiewen_tan>
Component: WebKit Misc.Assignee: Jiewen Tan <jiewen_tan>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, bfulgham, commit-queue, ews-watchlist, jiewen_tan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews206 for win-future
none
Patch
none
Patch none

Description Jiewen Tan 2018-06-27 12:20:28 PDT
Add null check for xpc_connection_t in AuthenticationManager::initializeConnection and AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc.
Comment 1 Radar WebKit Bug Importer 2018-06-27 12:22:51 PDT
<rdar://problem/41536815>
Comment 2 Jiewen Tan 2018-06-27 12:36:20 PDT
Created attachment 343738 [details]
Patch
Comment 3 EWS Watchlist 2018-06-27 17:14:37 PDT Comment hidden (obsolete)
Comment 4 EWS Watchlist 2018-06-27 17:14:49 PDT Comment hidden (obsolete)
Comment 5 Jiewen Tan 2018-06-27 17:46:05 PDT
The tree of win EWS bot is red.
Comment 6 Anders Carlsson 2018-06-28 08:26:49 PDT
The ChangeLog doesn't explain why this change is necessary.
Comment 7 Brent Fulgham 2018-06-28 09:39:09 PDT
Comment on attachment 343738 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=343738&action=review

> Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:43
> +    if (!connection || !connection->xpcConnection()) {

I don't understand this change. It seems like you should add your nullptr check, but KEEP the XPC_TYPE_CONNECTION check. Why are you removing the XPC type check?

> Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:56
> +    if (!m_connection->xpcConnection()) {

Is the issue that sometimes we go to relay client certificate data to the network process, but the network process has been terminated?
Comment 8 Jiewen Tan 2018-06-28 11:34:31 PDT
Comment on attachment 343738 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=343738&action=review

I will add a description as well.

>> Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:43
>> +    if (!connection || !connection->xpcConnection()) {
> 
> I don't understand this change. It seems like you should add your nullptr check, but KEEP the XPC_TYPE_CONNECTION check. Why are you removing the XPC type check?

I actually make a mistake last time when I added this check. What I was trying to do is to do the nullptr check. Then I discovered xpc_get_type(). Therefore I used it to do a more general check. However, xpc_get_type() doesn't do the nullptr check for its parameters... Therefore, we now crash here. Since nullptr check is what I actually need, I don't have to check the type of the object.

>> Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:56
>> +    if (!m_connection->xpcConnection()) {
> 
> Is the issue that sometimes we go to relay client certificate data to the network process, but the network process has been terminated?

I haven't observed any issues here. I added this just in case there are some future issues. I can remove this check here.
Comment 9 Jiewen Tan 2018-06-28 11:49:56 PDT
Created attachment 343825 [details]
Patch
Comment 10 Jiewen Tan 2018-06-28 11:51:45 PDT
Created attachment 343826 [details]
Patch
Comment 11 Brent Fulgham 2018-06-28 16:29:11 PDT
Comment on attachment 343826 [details]
Patch

r=me
Comment 12 Jiewen Tan 2018-06-28 16:30:37 PDT
Comment on attachment 343826 [details]
Patch

Thanks Brent for r+ this patch.
Comment 13 WebKit Commit Bot 2018-06-28 16:57:07 PDT
Comment on attachment 343826 [details]
Patch

Clearing flags on attachment: 343826

Committed r233340: <https://trac.webkit.org/changeset/233340>
Comment 14 WebKit Commit Bot 2018-06-28 16:57:09 PDT
All reviewed patches have been landed.  Closing bug.