For child libctx / provider, don't count self-references in parent
authorRichard Levitte <levitte@openssl.org>
Fri, 29 Apr 2022 06:08:06 +0000 (08:08 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 5 May 2022 13:06:11 +0000 (15:06 +0200)
commit4da7663b02bf05542830e85db6f74cf90daf1f49
tree4f9cff33c44c8e57caefbd23c66a78649a001788
parent03454ba2a234197c961920f1bac37cc9f4cf3f54
For child libctx / provider, don't count self-references in parent

In child library contexts, which contain child "clones" of the
providers the application has in store, one of these children will
always be the provider that creates the child library context; let's
call them self-refering child providers.

For these self-refering child providers, we don't increment the parent
provider reference count, nor do we free the parent provider, as those
become self defeating and hinder the teardown and unloading process
when the application cleans up.

For non self-refering child providers, we must retain this propagation
of reference count to the parent, so that aren't torn down too early,
i.e. when there's still a "foreign" reference (fetched algorithm).

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18151)
crypto/provider_child.c