Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid access of Target in SafeCredentialReference #36875

Merged

Conversation

aik-jahoda
Copy link
Contributor

@aik-jahoda aik-jahoda commented May 22, 2020

The SafeCredentialReference derive from CriticalHandleMinusOneIsInvalid however it didn't owerride IsInvalid nor IsClosed and the behaviour of those method are not reflecting the real Target state.

I removed this inheritance so the problemathics methods are no longer valid and it pointed into problematic usage of SafeCredentialReference which is fixed now.

Fixes #34337

@ghost
Copy link

ghost commented May 22, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@aik-jahoda aik-jahoda requested review from wfurt and stephentoub May 22, 2020 11:55
@wfurt
Copy link
Member

wfurt commented May 22, 2020

you may need to rebase or merge from upstream @aik-jahoda

@aik-jahoda aik-jahoda force-pushed the jajahoda/SafeCredentialReferencefix branch from 9779b99 to a660da1 Compare May 26, 2020 15:36
@aik-jahoda
Copy link
Contributor Author

@wfurt, thanks for the notice. All tests are passing now.

aik-jahoda and others added 2 commits June 5, 2020 18:08
Co-authored-by: Stephen Toub <stoub@microsoft.com>
@aik-jahoda aik-jahoda requested a review from stephentoub June 9, 2020 19:55
@aik-jahoda aik-jahoda requested a review from stephentoub June 16, 2020 13:37
creds = cached.Target;
cached.Dispose();

if (creds != null && !creds.IsClosed && !creds.IsInvalid && (cached = SafeCredentialReference.CreateReference(creds)) != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would creds be null here? If there's actually a concern that cached.Target might change from non-null to null concurrently, you can move the creds = cached.Target line to above the previous if block, and then use that creds in the above if check... then it definitely won't be null here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, doesn't CreateReference already check for IsClosed and IsInvalid and return null if either is true? Why do we need to duplicate those checks here?

@stephentoub
Copy link
Member

@aik-jahoda, are you still working on this?

@aik-jahoda
Copy link
Contributor Author

@stephentoub not actively now. However this is on our test failure list and I expect it will be prioritised soon.

@aik-jahoda aik-jahoda marked this pull request as draft December 3, 2020 16:26
@aik-jahoda
Copy link
Contributor Author

I continue on this PR to resolve the handles issue.

@aik-jahoda aik-jahoda force-pushed the jajahoda/SafeCredentialReferencefix branch from 970d63f to 46631be Compare December 15, 2020 13:53
@aik-jahoda aik-jahoda marked this pull request as ready for review December 16, 2020 09:11
@aik-jahoda
Copy link
Contributor Author

I run the test in loop for several days with any failure. It is ready to merge and we will observe possible failures in our weekly CI report.

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aik-jahoda aik-jahoda merged commit a987ef6 into dotnet:master Dec 17, 2020
@aik-jahoda aik-jahoda deleted the jajahoda/SafeCredentialReferencefix branch December 17, 2020 17:13
@ghost ghost locked as resolved and limited conversation to collaborators Jan 16, 2021
@karelz karelz added this to the 6.0.0 milestone Jan 26, 2021
@ViktorHofer
Copy link
Member

@aik-jahoda is the result.txt file that was checked into this PR necessary?

@wfurt
Copy link
Member

wfurt commented Sep 10, 2021

no, it is not. we miss it in the review IMHO as GitHub would not show binary (utf-16) diff @ViktorHofer

@ViktorHofer
Copy link
Member

@aik-jahoda can you please send a PR to remove the file from main?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClientAndServer_OneOrBothUseDefaultOk failing in CI
6 participants