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

Remove invalid assert in EvpPKeyDuplicate #86503

Merged
merged 1 commit into from
May 19, 2023
Merged

Conversation

vcsjones
Copy link
Member

EvpPKeyDuplicate has an invalid assert in it where it asserts that the handle it was passed is not IsInvalid. This may not be true in a multi-threaded scenario where an object is disposed by one thread while another thread is trying to use the resource.

Since we are marshaling the handle as a SafeHandle, just let it do the right thing of throwing an ObjectDisposedException when the marshaller attempts to add a reference to the handle.

Fixes #85073

@ghost
Copy link

ghost commented May 19, 2023

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

EvpPKeyDuplicate has an invalid assert in it where it asserts that the handle it was passed is not IsInvalid. This may not be true in a multi-threaded scenario where an object is disposed by one thread while another thread is trying to use the resource.

Since we are marshaling the handle as a SafeHandle, just let it do the right thing of throwing an ObjectDisposedException when the marshaller attempts to add a reference to the handle.

Fixes #85073

Author: vcsjones
Assignees: -
Labels:

area-System.Security

Milestone: -

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@vcsjones thank you for providing both the fix and the explanation!

@vcsjones
Copy link
Member Author

iOS failure is #82637, and changes don't impact iOS or tvOS platforms. Merging.

@vcsjones vcsjones merged commit 3924920 into dotnet:main May 19, 2023
@vcsjones vcsjones deleted the fix-85073 branch May 19, 2023 17:25
@vcsjones vcsjones added this to the 8.0.0 milestone May 19, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 18, 2023
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.

System.Security.Cryptography.Tests CertTests.RaceDisposeAndKeyAccess failing
2 participants