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

crypto/provider_core.c: correct definition of lock #8477

Closed
wants to merge 3 commits into from

Conversation

levitte
Copy link
Member

@levitte levitte commented Mar 14, 2019

Fixes #8476

paulidale
paulidale previously approved these changes Mar 14, 2019
@@ -208,7 +208,7 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
int ref = 0;

#ifndef HAVE_ATOMICS
CRYPTO_DOWN_REF(&prov->refcnt, &ref, provider_lock);
CRYPTO_DOWN_REF(&prov->refcnt, &ref, prov->refcnt_lock);
Copy link
Member

Choose a reason for hiding this comment

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

refcnt_lock appears to be NULL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh...

The refcount header doesn't make it easy to build without atomics 😕
That needs to change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

I do wonder why we're using HAVE_ATOMICS here at all. We could just create the lock unconditionally. If HAVE_ATOMICS is defined then it won't be used by the CRYPTO_DOWN_REF implementation...but so what?

Copy link
Member Author

Choose a reason for hiding this comment

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

'til some code sanitizer notices and starts complaining about it

Copy link
Member

Choose a reason for hiding this comment

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

It's what we do everywhere else. This is the only file in the whole repo that actually uses the HAVE_ATOMICS define.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okie. I've now ripped out most of those ifdefs. I will refuse to remove those around CRYPTO_THREAD_lock_new and CRYPTO_THREAD_lock_free, though. That would be stoopid waste of resources (and if we are wasteful elsewhere, I think guards should be added)

@levitte levitte dismissed paulidale’s stale review March 14, 2019 08:49

@slontis' concern needs fixing

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

Approved whether or not you make the suggested change

@@ -231,6 +224,9 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
if (ref == 0) {
DSO_free(prov->module);
OPENSSL_free(prov->name);
#ifndef HAVE_ATOMICS
CRYPTO_THREAD_lock_free(prov->refcnt_lock);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

You could also make this unconditional

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll have a closer look at the HAVE_ATOMICS stuff. We could do it better

Copy link
Contributor

Choose a reason for hiding this comment

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

I planned on producing a macro or two that do the necessary conditioning for us.
It shouldn't be hard to make this a lot easier.

@levitte
Copy link
Member Author

levitte commented Mar 14, 2019

Merged.

085bef9 crypto/provider_core.c: correct definition and use of lock

@levitte levitte closed this Mar 14, 2019
levitte added a commit that referenced this pull request Mar 14, 2019
Fixes #8476

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #8477)
@richsalz
Copy link
Contributor

Should CRYPTO_LOCK be used in the same in all API's no matter what ifdef's are used? Isn't that the point of the abstraction?

@levitte
Copy link
Member Author

levitte commented Mar 14, 2019

Should CRYPTO_LOCK be used in the same in all API's no matter what ifdef's are used? Isn't that the point of the abstraction?

We ended up doing that here as well. The only thing I still guard is the creation of the lock. There's no point creating it if it won't be used...

@richsalz
Copy link
Contributor

Oops, I misread the diff. Yes, you're completely right and I wasted time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants