Skip to content

Conversation

@wintersteiger
Copy link

No description provided.

@wintersteiger wintersteiger requested a review from a team as a code owner February 18, 2021 17:30
EVP_PKEY_encrypt(ctx, output.data(), &olen, input, input_size));

output.resize(olen);
EVP_PKEY_CTX_free(ctx);
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm missing something, OPENSSL_CHECK1() can throw, so we're still leaking in all error cases. Can we wrap the ctx into a unique_ptr with a custom deleter instead?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, can do. Failures of OPENSSL_CHECK1 are pretty much fatal, so I didn't spend too much effort on cleanup, but I'll have another look around.

Copy link
Member

Choose a reason for hiding this comment

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

We have a big catch around transaction logic though, in case anything gets thrown by user code. So these will get caught there, they won’t cause an abort. I’m happy for that to go in a follow up PR, but I would prefer if it was fixed.

ctx, output.data(), &olen, input.data(), input.size()));

output.resize(olen);
EVP_PKEY_CTX_free(ctx);
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@ghost
Copy link

ghost commented Feb 18, 2021

cwinter_rsa_mem_leak@19184 aka 20210219.8 vs main ewma over 20 builds from 18786 to 19177
images

@achamayou
Copy link
Member

There is still a leak in the ca_cert test it seems:

57: =================================================================
57: ==5024==ERROR: LeakSanitizer: detected memory leaks
57:
57: Direct leak of 120 byte(s) in 1 object(s) allocated from:
57: #0 0x4ced43 in __interceptor_malloc (/mnt/build/1/s/build/cchost.virtual+0x4ced43)
57: #1 0x7f3831660e58 in CRYPTO_zalloc (/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1+0x17ae58)
57:
57: Indirect leak of 136 byte(s) in 4 object(s) allocated from:
57: #0 0x4ced43 in __interceptor_malloc (/mnt/build/1/s/build/cchost.virtual+0x4ced43)
57: #1 0x7f3831660e58 in CRYPTO_zalloc (/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1+0x17ae58)
57:
57: SUMMARY: AddressSanitizer: 256 byte(s) leaked in 5 allocation(s).
57:

Copy link
Member

@achamayou achamayou left a comment

Choose a reason for hiding this comment

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

There's still a leak in the ca_certs_test it seems.

@wintersteiger
Copy link
Author

Yeah, that one's giving me headaches. I fixed a number of them yesterday, but I can't reproduce the ca_certs_test failure on my machine and the stack traces are useless. I'll dig deeper shortly.

@wintersteiger wintersteiger merged commit e8b70fc into microsoft:main Feb 19, 2021
@wintersteiger wintersteiger deleted the cwinter_rsa_mem_leak branch February 19, 2021 11:49
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.

3 participants