]> git.ipfire.org Git - thirdparty/openssl.git/commit
Prevent potential UAF in init_thread_deregister()
authorjwalch <jeremy.walch@gmail.com>
Thu, 29 Oct 2020 17:32:49 +0000 (13:32 -0400)
committerTomas Mraz <tmraz@fedoraproject.org>
Mon, 2 Nov 2020 17:03:22 +0000 (18:03 +0100)
commit3d7e7e7c48210b515ef5e05f4acf6dc58377331c
treed4c5bc6b4ac11433146086911702ece5679dec4f
parentd1ca391123864180d7d1d61c84e127ffcf2967d6
Prevent potential UAF in init_thread_deregister()

I discovered the potential for use-after-free on glob_tevent_reg &
its members in this function as a consequence of some static (de-)initialization
fiasco in C++ client code.

Long story short, an EVP_PKEY_free() was happening after
OPENSSL_cleanup(). Aside from being freed the EVP_PKEY object wasn't
actually being used after cleanup, it was basically just an
ordering issue.

Obviously the application behavior here is somewhat suspect,
but IMO is basically benign. Crashing (most typical outcome
of a UAF) doesn't seem the optimal response.

At any rate, the issue can be avoided (at least with regard to this function)
by simply updating the pointer to NULL rather than leaving it pointing
to the freed memory, as is the typical practice.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13267)
crypto/initthread.c