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

Safer pointer dereferences #505

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Safer pointer dereferences #505

merged 1 commit into from
Aug 27, 2024

Conversation

justsmth
Copy link
Contributor

@justsmth justsmth commented Aug 19, 2024

Description of changes:

  • Makes acquiring a mutable or const pointer from a ManagedPointer explicit (instead of using Deref):
    • Adds a MutPointer type as an analog of ConstPointer.
    • On a mutable ManagedPointer use as_mut to obtain a MutPointer.
    • On a shared ManagedPointer use as_const to obtain a ConstPointer.
    • On a shared ManagedPointer use as_mut_unsafe to obtain a MutPointer.

Call-outs:

The uses of as_mut_unsafe are limited to calls made to the following AWS-LC functions:

  • EVP_PKEY_CTX_new
  • EVP_PKEY_up_ref
  • EVP_DigestSignInit
  • EVP_DigestVerifyInit

These function only modify EVP_PKEY ref-count while holding a global lock.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 78.63636% with 47 lines in your changes missing coverage. Please review.

Project coverage is 92.52%. Comparing base (c358484) to head (8c8e522).
Report is 78 commits behind head on main.

Files with missing lines Patch % Lines
aws-lc-rs/src/ec.rs 63.82% 0 Missing and 17 partials ⚠️
aws-lc-rs/src/agreement.rs 80.00% 0 Missing and 5 partials ⚠️
aws-lc-rs/src/rsa/key.rs 70.58% 0 Missing and 5 partials ⚠️
aws-lc-rs/src/rsa/encryption/pkcs1.rs 66.66% 0 Missing and 4 partials ⚠️
aws-lc-rs/src/kem.rs 72.72% 0 Missing and 3 partials ⚠️
aws-lc-rs/src/rsa/signature.rs 57.14% 0 Missing and 3 partials ⚠️
aws-lc-rs/src/ec/key_pair.rs 71.42% 0 Missing and 2 partials ⚠️
aws-lc-rs/src/evp_pkey.rs 90.00% 2 Missing ⚠️
aws-lc-rs/src/rsa/encoding.rs 60.00% 0 Missing and 2 partials ⚠️
aws-lc-rs/src/rsa/encryption/oaep.rs 89.47% 0 Missing and 2 partials ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #505      +/-   ##
==========================================
- Coverage   95.80%   92.52%   -3.28%     
==========================================
  Files          61       67       +6     
  Lines        8143     9277    +1134     
  Branches        0     9277    +9277     
==========================================
+ Hits         7801     8584     +783     
- Misses        342      422      +80     
- Partials        0      271     +271     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justsmth justsmth force-pushed the safer-ptr-deref branch 3 times, most recently from d527c49 to b65d16a Compare August 19, 2024 16:50
skmcgrail
skmcgrail previously approved these changes Aug 19, 2024
samuel40791765
samuel40791765 previously approved these changes Aug 27, 2024
skmcgrail
skmcgrail previously approved these changes Aug 27, 2024
samuel40791765
samuel40791765 previously approved these changes Aug 27, 2024
@justsmth justsmth merged commit 8fb6869 into aws:main Aug 27, 2024
187 of 198 checks passed
@justsmth justsmth deleted the safer-ptr-deref branch August 27, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants