Deprecate all BIO_meth_get_*() functions

Their use by applications is inherently unsafe.
Fixes #26047

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/26056)
This commit is contained in:
Tomas Mraz 2024-11-25 16:06:47 +01:00
parent a64d26ac02
commit 0bba821881
6 changed files with 118 additions and 53 deletions

View File

@ -30,6 +30,12 @@ OpenSSL 3.5
### Changes between 3.4 and 3.5 [xx XXX xxxx]
* All the BIO_meth_get_*() functions allowing reuse of the internal OpenSSL
BIO method implementations were deprecated. The reuse is unsafe due to
dependency on the code of the internal methods not changing.
*Tomáš Mráz*
* Support DEFAULT keyword and '-' prefix in SSL_CTX_set1_groups_list().
SSL_CTX_set1_groups_list() now supports the DEFAULT keyword which sets the
available groups to the default selection. The '-' prefix allows the calling

View File

@ -55,6 +55,7 @@ void BIO_meth_free(BIO_METHOD *biom)
}
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int)
{
return biom->bwrite_old;
@ -65,6 +66,7 @@ int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_
{
return biom->bwrite;
}
#endif
/* Conversion for old style bwrite to new style */
int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written)
@ -102,6 +104,7 @@ int BIO_meth_set_write_ex(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int)
{
return biom->bread_old;
@ -111,6 +114,7 @@ int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size
{
return biom->bread;
}
#endif
/* Conversion for old style bread to new style */
int bread_conv(BIO *bio, char *data, size_t datal, size_t *readbytes)
@ -148,10 +152,12 @@ int BIO_meth_set_read_ex(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *)
{
return biom->bputs;
}
#endif
int BIO_meth_set_puts(BIO_METHOD *biom,
int (*bputs) (BIO *, const char *))
@ -160,10 +166,12 @@ int BIO_meth_set_puts(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int)
{
return biom->bgets;
}
#endif
int BIO_meth_set_gets(BIO_METHOD *biom,
int (*bgets) (BIO *, char *, int))
@ -172,10 +180,12 @@ int BIO_meth_set_gets(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *)
{
return biom->ctrl;
}
#endif
int BIO_meth_set_ctrl(BIO_METHOD *biom,
long (*ctrl) (BIO *, int, long, void *))
@ -184,10 +194,12 @@ int BIO_meth_set_ctrl(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_create(const BIO_METHOD *biom)) (BIO *)
{
return biom->create;
}
#endif
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
{
@ -195,10 +207,12 @@ int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *)
{
return biom->destroy;
}
#endif
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
{
@ -206,10 +220,12 @@ int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom)) (BIO *, int, BIO_info_cb *)
{
return biom->callback_ctrl;
}
#endif
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
long (*callback_ctrl) (BIO *, int,
@ -226,9 +242,11 @@ int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *) {
return biom->bsendmmsg;
}
#endif
int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
int (*brecvmmsg) (BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *))
@ -237,6 +255,8 @@ int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
return 1;
}
#ifndef OPENSSL_NO_DEPRECATED_3_5
int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *) {
return biom->brecvmmsg;
}
#endif

View File

@ -22,59 +22,64 @@ BIO_meth_set_recvmmsg, BIO_meth_get_recvmmsg - Routines to build up BIO methods
void BIO_meth_free(BIO_METHOD *biom);
int (*BIO_meth_get_write_ex(const BIO_METHOD *biom))(BIO *, const char *, size_t,
size_t *);
int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int);
int BIO_meth_set_write_ex(BIO_METHOD *biom,
int (*bwrite)(BIO *, const char *, size_t, size_t *));
int BIO_meth_set_write(BIO_METHOD *biom,
int (*write)(BIO *, const char *, int));
int (*BIO_meth_get_read_ex(const BIO_METHOD *biom))(BIO *, char *, size_t, size_t *);
int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int);
int BIO_meth_set_read_ex(BIO_METHOD *biom,
int (*bread)(BIO *, char *, size_t, size_t *));
int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int));
int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *);
int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *));
int (*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int);
int BIO_meth_set_gets(BIO_METHOD *biom,
int (*gets)(BIO *, char *, int));
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *);
int BIO_meth_set_ctrl(BIO_METHOD *biom,
long (*ctrl)(BIO *, int, long, void *));
int (*BIO_meth_get_create(const BIO_METHOD *bion))(BIO *);
int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *));
int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *);
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *));
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *);
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
long (*callback_ctrl)(BIO *, int, BIO_info_cb *));
int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
size_t, uint64_t));
int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
size_t, uint64_t));
The following functions have been deprecated since OpenSSL 3.5:
int (*BIO_meth_get_write_ex(const BIO_METHOD *biom))(BIO *, const char *, size_t,
size_t *);
int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int);
int (*BIO_meth_get_read_ex(const BIO_METHOD *biom))(BIO *, char *, size_t, size_t *);
int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int);
int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *);
int (*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int);
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *);
int (*BIO_meth_get_create(const BIO_METHOD *bion))(BIO *);
int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *);
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *);
ossl_ssize_t (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *,
BIO_MSG *,
size_t,
size_t,
uint64_t);
int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
size_t, uint64_t));
ossl_ssize_t (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *,
BIO_MSG *,
size_t,
size_t,
uint64_t);
int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
ossl_ssize_t (*f) (BIO *, BIO_MSG *, size_t,
size_t, uint64_t));
=head1 DESCRIPTION
@ -176,13 +181,32 @@ The B<BIO_meth_set> functions return 1 on success or 0 on error.
The B<BIO_meth_get> functions return the corresponding function pointers.
=head1 BUGS
It is not safe to use C<BIO_meth_get_> functions to reuse the B<BIO>
implementation of B<BIO>s implemented by OpenSSL itself with
application-implemented B<BIO>s. Instead either the applications ought to
implement these functions themselves or they should implement a filter BIO.
For more details please see L<https://github.com/openssl/openssl/issues/26047>.
=head1 SEE ALSO
L<bio(7)>, L<BIO_find_type(3)>, L<BIO_ctrl(3)>, L<BIO_read_ex(3)>, L<BIO_new(3)>
=head1 HISTORY
The functions described here were added in OpenSSL 1.1.0.
The functions BIO_meth_get_sendmmsg(), BIO_meth_set_sendmmsg(),
BIO_meth_get_recvmmsg() and BIO_meth_set_recvmmsg() were added in OpenSSL 3.2.
All the other functions described here were added in OpenSSL 1.1.0.
The functions BIO_meth_get_read_ex(), BIO_meth_get_write_ex(),
BIO_meth_get_write(), BIO_meth_get_read(), BIO_meth_get_puts(),
BIO_meth_get_gets(), BIO_meth_get_ctrl(), BIO_meth_get_create(),
BIO_meth_get_destroy(), BIO_meth_get_callback_ctrl(),
BIO_meth_get_sendmmsg() and BIO_meth_get_recvmmsg() are deprecated since
OpenSSL 3.5.
=head1 COPYRIGHT

View File

@ -942,9 +942,6 @@ ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
BIO_METHOD *BIO_meth_new(int type, const char *name);
void BIO_meth_free(BIO_METHOD *biom);
int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
size_t *);
int BIO_meth_set_write(BIO_METHOD *biom,
int (*write) (BIO *, const char *, int));
int BIO_meth_set_write_ex(BIO_METHOD *biom,
@ -952,11 +949,6 @@ int BIO_meth_set_write_ex(BIO_METHOD *biom,
int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
int (*f) (BIO *, BIO_MSG *, size_t, size_t,
uint64_t, size_t *));
int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
size_t, size_t,
uint64_t, size_t *);
int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);
int BIO_meth_set_read(BIO_METHOD *biom,
int (*read) (BIO *, char *, int));
int BIO_meth_set_read_ex(BIO_METHOD *biom,
@ -964,28 +956,40 @@ int BIO_meth_set_read_ex(BIO_METHOD *biom,
int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
int (*f) (BIO *, BIO_MSG *, size_t, size_t,
uint64_t, size_t *));
int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
size_t, size_t,
uint64_t, size_t *);
int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
int BIO_meth_set_puts(BIO_METHOD *biom,
int (*puts) (BIO *, const char *));
int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
int BIO_meth_set_gets(BIO_METHOD *biom,
int (*ossl_gets) (BIO *, char *, int));
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
int BIO_meth_set_ctrl(BIO_METHOD *biom,
long (*ctrl) (BIO *, int, long, void *));
int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
(BIO *, int, BIO_info_cb *);
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
long (*callback_ctrl) (BIO *, int,
BIO_info_cb *));
# ifndef OPENSSL_NO_DEPRECATED_3_5
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *,
int);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *,
size_t, size_t *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
size_t, size_t,
uint64_t, size_t *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *,
size_t, size_t *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
size_t, size_t,
uint64_t, size_t *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
OSSL_DEPRECATEDIN_3_5 long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int,
long, void *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
OSSL_DEPRECATEDIN_3_5 int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
OSSL_DEPRECATEDIN_3_5 long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom)) (BIO *, int,
BIO_info_cb *);
# endif
# ifdef __cplusplus
}
# endif

View File

@ -179,6 +179,17 @@
# undef OPENSSL_NO_DEPRECATED_1_0_0
# undef OPENSSL_NO_DEPRECATED_0_9_8
# if OPENSSL_API_LEVEL >= 30500
# ifndef OPENSSL_NO_DEPRECATED
# define OSSL_DEPRECATEDIN_3_5 OSSL_DEPRECATED(3.5)
# define OSSL_DEPRECATEDIN_3_5_FOR(msg) OSSL_DEPRECATED_FOR(3.5, msg)
# else
# define OPENSSL_NO_DEPRECATED_3_5
# endif
# else
# define OSSL_DEPRECATEDIN_3_5
# define OSSL_DEPRECATEDIN_3_5_FOR(msg)
# endif
# if OPENSSL_API_LEVEL >= 30400
# ifndef OPENSSL_NO_DEPRECATED
# define OSSL_DEPRECATEDIN_3_4 OSSL_DEPRECATED(3.4)

View File

@ -3840,9 +3840,9 @@ EVP_blake2s256 3926 3_0_0 EXIST::FUNCTION:BLAKE2
EVP_blake2b512 3927 3_0_0 EXIST::FUNCTION:BLAKE2
X509_SIG_get0 3928 3_0_0 EXIST::FUNCTION:
BIO_meth_new 3929 3_0_0 EXIST::FUNCTION:
BIO_meth_get_puts 3930 3_0_0 EXIST::FUNCTION:
BIO_meth_get_ctrl 3931 3_0_0 EXIST::FUNCTION:
BIO_meth_get_gets 3932 3_0_0 EXIST::FUNCTION:
BIO_meth_get_puts 3930 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_get_ctrl 3931 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_get_gets 3932 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_get_data 3933 3_0_0 EXIST::FUNCTION:
BIO_set_init 3934 3_0_0 EXIST::FUNCTION:
BIO_meth_set_puts 3935 3_0_0 EXIST::FUNCTION:
@ -3852,17 +3852,17 @@ BIO_meth_set_ctrl 3938 3_0_0 EXIST::FUNCTION:
BIO_meth_set_read 3939 3_0_0 EXIST::FUNCTION:
BIO_set_shutdown 3940 3_0_0 EXIST::FUNCTION:
BIO_meth_set_create 3941 3_0_0 EXIST::FUNCTION:
BIO_meth_get_write 3942 3_0_0 EXIST::FUNCTION:
BIO_meth_get_write 3942 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_set_callback_ctrl 3943 3_0_0 EXIST::FUNCTION:
BIO_meth_get_create 3944 3_0_0 EXIST::FUNCTION:
BIO_meth_get_create 3944 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_set_next 3945 3_0_0 EXIST::FUNCTION:
BIO_set_data 3946 3_0_0 EXIST::FUNCTION:
BIO_meth_set_write 3947 3_0_0 EXIST::FUNCTION:
BIO_meth_set_destroy 3948 3_0_0 EXIST::FUNCTION:
BIO_meth_set_gets 3949 3_0_0 EXIST::FUNCTION:
BIO_meth_get_callback_ctrl 3950 3_0_0 EXIST::FUNCTION:
BIO_meth_get_destroy 3951 3_0_0 EXIST::FUNCTION:
BIO_meth_get_read 3952 3_0_0 EXIST::FUNCTION:
BIO_meth_get_callback_ctrl 3950 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_get_destroy 3951 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_get_read 3952 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_set_retry_reason 3953 3_0_0 EXIST::FUNCTION:
BIO_meth_free 3954 3_0_0 EXIST::FUNCTION:
DSA_meth_set_bn_mod_exp 3955 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,DSA
@ -4071,9 +4071,9 @@ BIO_read_ex 4162 3_0_0 EXIST::FUNCTION:
BIO_set_callback_ex 4163 3_0_0 EXIST::FUNCTION:
BIO_get_callback_ex 4164 3_0_0 EXIST::FUNCTION:
BIO_meth_set_read_ex 4165 3_0_0 EXIST::FUNCTION:
BIO_meth_get_read_ex 4166 3_0_0 EXIST::FUNCTION:
BIO_meth_get_read_ex 4166 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_write_ex 4167 3_0_0 EXIST::FUNCTION:
BIO_meth_get_write_ex 4168 3_0_0 EXIST::FUNCTION:
BIO_meth_get_write_ex 4168 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_set_write_ex 4169 3_0_0 EXIST::FUNCTION:
DSO_pathbyaddr 4170 3_0_0 EXIST::FUNCTION:
DSO_dsobyaddr 4171 3_0_0 EXIST::FUNCTION:
@ -5470,9 +5470,9 @@ BIO_s_dgram_mem 5597 3_2_0 EXIST::FUNCTION:DGRAM
BIO_recvmmsg 5598 3_2_0 EXIST::FUNCTION:
BIO_sendmmsg 5599 3_2_0 EXIST::FUNCTION:
BIO_meth_set_sendmmsg 5600 3_2_0 EXIST::FUNCTION:
BIO_meth_get_sendmmsg 5601 3_2_0 EXIST::FUNCTION:
BIO_meth_get_sendmmsg 5601 3_2_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_meth_set_recvmmsg 5602 3_2_0 EXIST::FUNCTION:
BIO_meth_get_recvmmsg 5603 3_2_0 EXIST::FUNCTION:
BIO_meth_get_recvmmsg 5603 3_2_0 EXIST::FUNCTION:DEPRECATEDIN_3_5
BIO_err_is_non_fatal 5604 3_2_0 EXIST::FUNCTION:SOCK
BIO_s_dgram_pair 5605 3_2_0 EXIST::FUNCTION:DGRAM
BIO_new_bio_dgram_pair 5606 3_2_0 EXIST::FUNCTION:DGRAM