Skip to content

Add generic EVP method fetcher#8341

Closed
levitte wants to merge 8 commits intoopenssl:masterfrom
levitte:300-evpfetch
Closed

Add generic EVP method fetcher#8341
levitte wants to merge 8 commits intoopenssl:masterfrom
levitte:300-evpfetch

Conversation

@levitte
Copy link
Member

@levitte levitte commented Feb 26, 2019

This is an interface between Core dispatch table fetching and
EVP_{method}_fetch(). All that's needed from the diverse method
fetchers are the functions to create a method structure from a
dispatch table, a function that ups the method reference counter and a
function to free the method (in case of failure).

This routine is internal to the EVP API andis therefore only made
accessible within crypto/evp, by including evp_locl.h

Checklist
  • documentation is added or updated
  • tests are added or updated

@levitte levitte added the branch: master Applies to master branch label Feb 26, 2019
@levitte
Copy link
Member Author

levitte commented Feb 26, 2019

To build, this needs #8286, #8287 and #8340. It's here to show how internal API specific methods can get created from provider dispatch tables through the core fetcher from #8340.

@levitte levitte force-pushed the 300-evpfetch branch 3 times, most recently from 00d3174 to ae3784f Compare February 27, 2019 21:33
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to include this from evp_locl.h if it is needed there?

@paulidale
Copy link
Contributor

CI errors are relevant.

@levitte
Copy link
Member Author

levitte commented Mar 4, 2019

@paulidale, in #8341 (comment), I mention that this needs #8286, #8287 and #8340. Only #8286 has yet made it into master.

@paulidale
Copy link
Contributor

Okay, I'll look at them too.

@levitte levitte force-pushed the 300-evpfetch branch 2 times, most recently from 2996ee6 to 35774f1 Compare March 11, 2019 19:46
@levitte
Copy link
Member Author

levitte commented Mar 11, 2019

I've rebased this on top of a fresh master. I'll go through any remaining comments tomorrow

Copy link
Member

Choose a reason for hiding this comment

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

Do we need some locking here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, not here. Locking for this should be part of the object database code, possibly through a function that anyone can call.

That should be done in a separate PR, and locking calls should be added in all places where things are added to the object database if necessary, not just here.

Copy link
Member Author

Choose a reason for hiding this comment

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

(and for anyone listening, PR welcome!)

Copy link
Member

Choose a reason for hiding this comment

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

We should raise an issue for this

@levitte
Copy link
Member Author

levitte commented Mar 12, 2019

Please note, btw, that this won't work without #8340...

@levitte
Copy link
Member Author

levitte commented Mar 12, 2019

#8340 is now merged, and this has been rebased on top.

@mattcaswell
Copy link
Member

Travis errors look relevant:

crypto/evp/evp_fetch.c: In function 'evp_generic_fetch':
crypto/evp/evp_fetch.c:168:9: error: initializer element is not computable at load time [-Werror]
         };
         ^
cc1: all warnings being treated as errors
make[1]: *** [crypto/evp/libcrypto-shlib-evp_fetch.o] Error 1
make[1]: Leaving directory `/home/travis/build/openssl/openssl'
make: *** [build_programs] Error 2

@levitte
Copy link
Member Author

levitte commented Mar 13, 2019

Saw it, and discovered a small thing missing in #8340. Corrected with 837f046

@levitte
Copy link
Member Author

levitte commented Mar 13, 2019

CIs are happy now

Copy link
Member

Choose a reason for hiding this comment

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

We should raise an issue for this

@levitte
Copy link
Member Author

levitte commented Mar 14, 2019

The work done today was to correct some refcounting that wasn't quite right.

All relevant OSSL_METHOD_CONSTRUCT_METHOD callbacks got the callback
data passed to them, except 'destruct'.  There's no reason why it
shouldn't get that pointer passed, so we make a small adjustment.
levitte added 7 commits March 17, 2019 19:49
Fully assume that the method constructors use reference counting.
Otherwise, we may leak memory, or loose track and do a double free.
This is an interface between Core dispatch table fetching and
EVP_{method}_fetch().  All that's needed from the diverse method
fetchers are the functions to create a method structure from a
dispatch table, a function that ups the method reference counter and a
function to free the method (in case of failure).

This routine is internal to the EVP API andis therefore only made
accessible within crypto/evp, by including evp_locl.h
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 assuming the minor typo is fixed. I also think an issue should be raised for the OBJ locking stuff before it gets forgotten about.

* Note regarding putting the method in stores:
*
* we don't need to care if it actually got in or not here.
* If it didn't get it, it will simply not be available when
Copy link
Member

Choose a reason for hiding this comment

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

s/get it/get in/

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

@mattcaswell mattcaswell added the approval: done This pull request has the required number of approvals label Mar 18, 2019
@levitte
Copy link
Member Author

levitte commented Mar 18, 2019

Merged.

Thanks for the reviews!

c13d2ab Add generic EVP method fetcher
a383083 Replumbing: better reference counter control in ossl_method_construct()
7bb19a0 Replumbing: pass callback data to the algo destructor too

@levitte levitte closed this Mar 18, 2019
levitte added a commit that referenced this pull request Mar 18, 2019
All relevant OSSL_METHOD_CONSTRUCT_METHOD callbacks got the callback
data passed to them, except 'destruct'.  There's no reason why it
shouldn't get that pointer passed, so we make a small adjustment.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #8341)
levitte added a commit that referenced this pull request Mar 18, 2019
Fully assume that the method constructors use reference counting.
Otherwise, we may leak memory, or loose track and do a double free.

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #8341)
levitte added a commit that referenced this pull request Mar 18, 2019
This is an interface between Core dispatch table fetching and
EVP_{method}_fetch().  All that's needed from the diverse method
fetchers are the functions to create a method structure from a
dispatch table, a function that ups the method reference counter and a
function to free the method (in case of failure).

This routine is internal to the EVP API andis therefore only made
accessible within crypto/evp, by including evp_locl.h

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #8341)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants