-
-
Notifications
You must be signed in to change notification settings - Fork 11k
[URGENT] Fix sanitizer build #13661
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
[URGENT] Fix sanitizer build #13661
Conversation
|
I'm getting issues with the tests on my laptop, like this: This makes me think of the recent issues with seed stuff, but I thought @paulidale had fixed it and the fix was merged. I have no idead what's going on... |
I got a better idea now, and it has nothing to do with the seed stuff. Our decoders must adjust the library context of the created keys to match what would come out of the KEYMGMT if it was generated. |
|
Sanitizers still not happy... that looks like a leak elsewhere, though. |
|
This is becoming a generic fixup PR... I'll change title and description accordingly |
But the leak or at least its appearance seems to be triggered by this PR. |
Yeah, something's up, I agree. |
|
Found 1 leak, I hope that's it. |
|
I did a sanitizer run on my laptop, using the exact same setup (apart from I'd be grateful if anyone could take a look at that last bit and help me figure it out UPDATE: Maybe it's a |
I can periodically reproduce it with OPENSSL_TEST_RAND_ORDER=0 |
|
With this patch I can reliably reproduce this failure even in a build without sanitizers: It looks to me like an instance of #12157 |
|
Thanks for the hint, now I can go in and see what can be done about it. |
|
There is no need for trial and error over the test order randomisation. When running with I've created #13672 to make the randomisation failure text more obvious and to document how to use the env variable. |
ec054ce to
bfbe5bf
Compare
|
A new commit was added, which fixes #12157, and hopefully make the sanitizers happy. ("It works on my laptop!" -- famous last words) |
|
This is urgent, so it would be nice to get a review soon. |
|
It seems the old failures in the sanitizer are now fixed. There is a new one - leak in the provided test. However this is not a regression caused by this PR as the new failure is there on master already. I did not yet find out which merged PR caused it. |
I found that one and added a commit that I hope fixes the issue. |
|
Now it works on my laptop. |
|
Yay, sanitizer CI passes 😄 |
|
Working on review but it will take me some time as the changes are quite non-trivial. |
I'd recommend reading them one commit at a time, that will at least make each change more concise. Oh, and thank you! |
With that in mind, should I perform a squash? |
Yes, please. |
OSSL_DECODER_CTX_new_by_EVP_PKEY() would keep copies of all the EVP_KEYMGMTs it finds. This turns out to be fragile in certain circumstances, so we switch to fetch the appropriate EVP_KEYMGMT when it's time to construct an EVP_PKEY from the decoded data instead. This has the added benefit that we now actually use the property query string that was given by the caller for these fetches. Fixes openssl#13503
…nal key So far, the MSBLOB and PVK writers could only handle EVP_PKEYs with legacy internal keys. Specially to be able to compile the loader_attic engine, we use the C macro OPENSSL_NO_PROVIDER_CODE to avoid building the provider specific things when we don't need them. The alternative is to suck half of crypto/evp/ into loader_attic, and that's just not feasible. Fixes openssl#13503
Because decoders are coupled with keymgmts from the same provider, ours need to produce provider side keys the same way. Since our keymgmts create key data with the provider library context, so must our decoders. We solve with functions to adjust the library context of decoded keys, and use them.
This introduces a separate activation counter, and the function ossl_provider_deactivate() for provider deactivation. Something to be noted is that if the reference count goes down to zero, we don't care if the activation count is non-zero (i.e. someone forgot to call ossl_provider_deactivate()). Since there are no more references to the provider, it doesn't matter. The important thing is that deactivation doesn't remove the provider as long as there are references to it, for example because there are live methods associated with that provider, but still makes the provider unavailable to create new methods from. Fixes openssl#13503 Fixes openssl#12157
In most error cases, EVP_PKEY_CTX_dup() would only free the EVP_PKEY_CTX without freeing the duplicated contents. Fixes openssl#13503
Done |
t8m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some doc nits, otherwise LGTM.
|
Approved. Setting ready-to-merge as this is urgent. |
Thanks. Will merge now |
OSSL_DECODER_CTX_new_by_EVP_PKEY() would keep copies of all the EVP_KEYMGMTs it finds. This turns out to be fragile in certain circumstances, so we switch to fetch the appropriate EVP_KEYMGMT when it's time to construct an EVP_PKEY from the decoded data instead. This has the added benefit that we now actually use the property query string that was given by the caller for these fetches. Fixes #13503 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from #13661)
…nal key So far, the MSBLOB and PVK writers could only handle EVP_PKEYs with legacy internal keys. Specially to be able to compile the loader_attic engine, we use the C macro OPENSSL_NO_PROVIDER_CODE to avoid building the provider specific things when we don't need them. The alternative is to suck half of crypto/evp/ into loader_attic, and that's just not feasible. Fixes #13503 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from #13661)
Because decoders are coupled with keymgmts from the same provider, ours need to produce provider side keys the same way. Since our keymgmts create key data with the provider library context, so must our decoders. We solve with functions to adjust the library context of decoded keys, and use them. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from #13661)
This introduces a separate activation counter, and the function ossl_provider_deactivate() for provider deactivation. Something to be noted is that if the reference count goes down to zero, we don't care if the activation count is non-zero (i.e. someone forgot to call ossl_provider_deactivate()). Since there are no more references to the provider, it doesn't matter. The important thing is that deactivation doesn't remove the provider as long as there are references to it, for example because there are live methods associated with that provider, but still makes the provider unavailable to create new methods from. Fixes #13503 Fixes #12157 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from #13661)
|
Merged 054cde1 DECODER EVP_PKEY: Don't store all the EVP_KEYMGMTs |
|
Thank you, @t8m! |
DECODER EVP_PKEY: Don't store all the EVP_KEYMGMTs
OSSL_DECODER_CTX_new_by_EVP_PKEY() would keep copies of all the
EVP_KEYMGMTs it finds.
This turns out to be fragile in certain circumstances, so we switch to
fetch the appropriate EVP_KEYMGMT when it's time to construct an
EVP_PKEY from the decoded data instead. This has the added benefit
that we now actually use the property query string that was given by
the caller for these fetches.
Fixes #13503
MSBLOB & PVK: Make it possible to write EVP_PKEYs with provided internal key
So far, the MSBLOB and PVK writers could only handle EVP_PKEYs with
legacy internal keys.
Specially to be able to compile the loader_attic engine, we use the C
macro OPENSSL_NO_PROVIDER_CODE to avoid building the provider specific
things when we don't need them. The alternative is to suck half of
crypto/evp/ into loader_attic, and that's just not feasible.
Fixes #13503
DECODER: Adjust the library context of keys in our decoders
Because decoders are coupled with keymgmts from the same provider,
ours need to produce provider side keys the same way. Since our
keymgmts create key data with the provider library context, so must
our decoders.
We solve with functions to adjust the library context of decoded keys,
and use them.
CORE: Separate OSSL_PROVIDER activation from OSSL_PROVIDER reference
This introduces a separate activation counter, and the function
ossl_provider_deactivate() for provider deactivation.
Something to be noted is that if the reference count goes down to
zero, we don't care if the activation count is non-zero (i.e. someone
forgot to call ossl_provider_deactivate()). Since there are no more
references to the provider, it doesn't matter.
The important thing is that deactivation doesn't remove the provider
as long as there are references to it, for example because there are
live methods associated with that provider, but still makes the
provider unavailable to create new methods from.
Fixes #13503
Fixes #12157
EVP: Fix memory leak in EVP_PKEY_CTX_dup()
In most error cases, EVP_PKEY_CTX_dup() would only free the EVP_PKEY_CTX
without freeing the duplicated contents.
Fixes #13503