BIO_new_from_core_bio: Fix heap-use-after-free after attach
authorPetr Gotthard <petr.gotthard@centrum.cz>
Wed, 5 May 2021 16:32:55 +0000 (18:32 +0200)
committerPauli <pauli@openssl.org>
Fri, 25 Jun 2021 00:11:29 +0000 (10:11 +1000)
commit11efa7d45ba08fe4d8a11332680b1021934733cf
treea590634d6e56fa3511da4bca4e89e3dd07004f3d
parent454d69271cf65edb1f6d0ca2a06f9b755f6cb937
BIO_new_from_core_bio: Fix heap-use-after-free after attach

The providers have to call up_ref to keep the cbio pointer, just like
the internal bio_prov.c does.

OSSL_STORE_attach passes a cbio pointer to the provider and then calls
ossl_core_bio_free(cbio). If up_ref is not called, the cbio gets
freed way too early.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15163)
crypto/bio/bss_core.c
test/bio_core_test.c