From 4a6edb3688c0b5be3cd04db9f5525049dd5908fd Mon Sep 17 00:00:00 2001 From: purplerain Date: Mon, 24 Jun 2024 17:59:29 +0000 Subject: [PATCH] sync with OpenBSD -current --- distrib/notes/arm64/hardware | 6 +- include/string.h | 6 +- lib/libc/string/strmode.c | 6 +- lib/libc/sys/swapctl.2 | 6 +- lib/libcrypto/Makefile | 3 +- lib/libcrypto/asn1/asn1_err.c | 12 +- lib/libcrypto/bio/bio_err.c | 12 +- lib/libcrypto/bn/bn_err.c | 12 +- lib/libcrypto/buffer/buf_err.c | 12 +- lib/libcrypto/cms/cms_err.c | 12 +- lib/libcrypto/conf/conf_err.c | 12 +- lib/libcrypto/cpt_err.c | 12 +- lib/libcrypto/ct/ct_err.c | 12 +- lib/libcrypto/dh/dh_err.c | 14 +- lib/libcrypto/dsa/dsa_err.c | 12 +- lib/libcrypto/ec/ec_err.c | 13 +- lib/libcrypto/err/err.c | 47 ++++--- lib/libcrypto/err/err_local.h | 123 ++++++++++++++++++ lib/libcrypto/evp/evp_err.c | 12 +- lib/libcrypto/kdf/kdf_err.c | 12 +- lib/libcrypto/objects/obj_err.c | 12 +- lib/libcrypto/ocsp/ocsp_err.c | 12 +- lib/libcrypto/pem/pem_err.c | 12 +- lib/libcrypto/pkcs12/pk12err.c | 12 +- lib/libcrypto/pkcs7/pkcs7err.c | 12 +- lib/libcrypto/rand/rand_err.c | 12 +- lib/libcrypto/rsa/rsa_err.c | 12 +- lib/libcrypto/ts/ts_err.c | 12 +- lib/libcrypto/ui/ui_err.c | 12 +- lib/libcrypto/x509/x509_conf.c | 16 +-- lib/libcrypto/x509/x509_err.c | 20 +-- lib/libssl/ssl_err.c | 28 ++-- regress/lib/libssl/rust-openssl/Makefile | 4 +- .../rust-openssl/{config => config.toml} | 0 sys/arch/amd64/amd64/mem.c | 4 +- sys/arch/arm/arm/mem.c | 4 +- sys/arch/arm64/arm64/cpu.c | 4 +- sys/arch/arm64/arm64/mem.c | 4 +- sys/arch/arm64/dev/agintc.c | 14 +- sys/arch/arm64/include/armreg.h | 3 +- sys/arch/arm64/stand/efiboot/conf.c | 4 +- sys/arch/arm64/stand/efiboot/efiacpi.c | 36 ++++- sys/arch/i386/i386/mem.c | 4 +- sys/dev/acpi/acpibat.c | 8 +- sys/dev/fdt/qcscm.c | 21 ++- sys/dev/fdt/rkusbphy.c | 44 ++++++- sys/dev/pci/drm/i915/display/intel_audio.c | 34 +++-- sys/dev/pci/drm/i915/display/intel_audio.h | 1 + .../drm/i915/display/intel_display_driver.c | 2 + sys/dev/pci/drm/i915/gem/i915_gem_object.h | 4 +- sys/dev/pci/drm/i915/gt/intel_breadcrumbs.c | 15 +-- sys/netinet/ip_input.c | 60 ++++----- usr.bin/openssl/ca.c | 3 +- usr.bin/ssh/sshd_config.5 | 11 +- usr.bin/tmux/cmd-refresh-client.c | 37 +++++- usr.bin/tmux/grid.c | 4 +- usr.bin/tmux/input.c | 66 ++++++++-- usr.bin/tmux/tmux.1 | 11 +- usr.bin/tmux/tmux.h | 7 +- usr.bin/tmux/tty-keys.c | 24 ++-- usr.bin/tmux/window.c | 5 +- 61 files changed, 680 insertions(+), 286 deletions(-) create mode 100644 lib/libcrypto/err/err_local.h rename regress/lib/libssl/rust-openssl/{config => config.toml} (100%) diff --git a/distrib/notes/arm64/hardware b/distrib/notes/arm64/hardware index 03fca42d8..39daf7ad9 100644 --- a/distrib/notes/arm64/hardware +++ b/distrib/notes/arm64/hardware @@ -1,4 +1,4 @@ -dnl $OpenBSD: hardware,v 1.23 2024/04/23 10:17:20 fcambus Exp $ +dnl $OpenBSD: hardware,v 1.24 2024/06/24 05:15:29 jsg Exp $ The following machines are targeted by SecBSD/MACHINE: Allwinner A64/H5/H6 @@ -31,7 +31,7 @@ The following machines are targeted by SecBSD/MACHINE: Apple iMac (24-inch, M1, 2021) Apple MacBook Pro (14-inch, M1 Pro/Max, 2021) Apple MacBook Pro (16-inch, M1 Pro/Max, 2021) - Apple Studio (M1 Max/Ultra, 2022) + Apple Mac Studio (M1 Max/Ultra, 2022) Apple Mac mini (M2, 2023) Apple MacBook Air (13-inch, M2, 2022) Apple MacBook Pro (13-inch, M2, 2022) @@ -39,7 +39,7 @@ The following machines are targeted by SecBSD/MACHINE: Apple Mac mini (M2 Pro, 2023) Apple MacBook Pro (14-inch, M2 Pro/Max, 2023) Apple MacBook Pro (16-inch, M2 Pro/Max, 2023) - Apple Studio (M2 Max/Ultra, 2023) + Apple Mac Studio (M2 Max/Ultra, 2023) Broadcom BCM2837/BCM2711 Raspberry Pi 3 Raspberry Pi 3 Model B+ diff --git a/include/string.h b/include/string.h index e0afaf2b4..2ae8c62a2 100644 --- a/include/string.h +++ b/include/string.h @@ -1,4 +1,4 @@ -/* $OpenBSD: string.h,v 1.32 2017/09/05 03:16:13 schwarze Exp $ */ +/* $OpenBSD: string.h,v 1.33 2024/06/23 07:08:26 otto Exp $ */ /* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */ /*- @@ -37,7 +37,7 @@ #include #include -#include +#include /* * POSIX mandates that certain string functions not present in ISO C @@ -128,7 +128,7 @@ size_t strlcat(char *, const char *, size_t) __attribute__ ((__bounded__(__string__,1,3))); size_t strlcpy(char *, const char *, size_t) __attribute__ ((__bounded__(__string__,1,3))); -void strmode(int, char *); +void strmode(__mode_t, char *); char *strsep(char **, const char *); int timingsafe_bcmp(const void *, const void *, size_t); int timingsafe_memcmp(const void *, const void *, size_t); diff --git a/lib/libc/string/strmode.c b/lib/libc/string/strmode.c index 609b8931f..c57fe74b2 100644 --- a/lib/libc/string/strmode.c +++ b/lib/libc/string/strmode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strmode.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: strmode.c,v 1.9 2024/06/23 07:08:26 otto Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -32,10 +32,8 @@ #include #include -/* XXX mode should be mode_t */ - void -strmode(int mode, char *p) +strmode(mode_t mode, char *p) { /* print type */ switch (mode & S_IFMT) { diff --git a/lib/libc/sys/swapctl.2 b/lib/libc/sys/swapctl.2 index 2da86fa98..3540fd698 100644 --- a/lib/libc/sys/swapctl.2 +++ b/lib/libc/sys/swapctl.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: swapctl.2,v 1.25 2021/11/21 23:44:55 jan Exp $ +.\" $OpenBSD: swapctl.2,v 1.26 2024/06/24 14:39:28 deraadt Exp $ .\" $NetBSD: swapctl.2,v 1.10 1998/08/29 17:11:09 mrg Exp $ .\" .\" Copyright (c) 1997 Matthew R. Green @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: November 21 2021 $ +.Dd $Mdocdate: June 24 2024 $ .Dt SWAPCTL 2 .Os .Sh NAME @@ -197,7 +197,7 @@ has already been made available for swapping. .It Bq Er EINVAL The device configured by .Fa arg -has no associated size, or the +has insufficient size, or the .Fa cmd was unknown. .It Bq Er ENXIO diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 564dc0116..7b926db11 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.195 2024/05/24 19:16:53 tb Exp $ +# $OpenBSD: Makefile,v 1.196 2024/06/24 06:43:22 tb Exp $ LIB= crypto LIBREBUILD=y @@ -36,6 +36,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/dh CFLAGS+= -I${LCRYPTO_SRC}/dsa CFLAGS+= -I${LCRYPTO_SRC}/ec CFLAGS+= -I${LCRYPTO_SRC}/ecdsa +CFLAGS+= -I${LCRYPTO_SRC}/err CFLAGS+= -I${LCRYPTO_SRC}/evp CFLAGS+= -I${LCRYPTO_SRC}/hidden CFLAGS+= -I${LCRYPTO_SRC}/hmac diff --git a/lib/libcrypto/asn1/asn1_err.c b/lib/libcrypto/asn1/asn1_err.c index 28570386f..44809c76b 100644 --- a/lib/libcrypto/asn1/asn1_err.c +++ b/lib/libcrypto/asn1/asn1_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_err.c,v 1.26 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: asn1_err.c,v 1.27 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ASN1,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason) -static ERR_STRING_DATA ASN1_str_functs[] = { +static const ERR_STRING_DATA ASN1_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA ASN1_str_reasons[] = { +static const ERR_STRING_DATA ASN1_str_reasons[] = { {ERR_REASON(ASN1_R_ADDING_OBJECT) , "adding object"}, {ERR_REASON(ASN1_R_ASN1_PARSE_ERROR) , "asn1 parse error"}, {ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR) , "asn1 sig parse error"}, @@ -206,8 +208,8 @@ ERR_load_ASN1_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) { - ERR_load_strings(0, ASN1_str_functs); - ERR_load_strings(0, ASN1_str_reasons); + ERR_load_const_strings(ASN1_str_functs); + ERR_load_const_strings(ASN1_str_reasons); } #endif } diff --git a/lib/libcrypto/bio/bio_err.c b/lib/libcrypto/bio/bio_err.c index 36fabca21..4541adb24 100644 --- a/lib/libcrypto/bio/bio_err.c +++ b/lib/libcrypto/bio/bio_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_err.c,v 1.20 2023/07/05 21:23:37 beck Exp $ */ +/* $OpenBSD: bio_err.c,v 1.21 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BIO,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BIO,0,reason) -static ERR_STRING_DATA BIO_str_functs[] = { +static const ERR_STRING_DATA BIO_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA BIO_str_reasons[] = { +static const ERR_STRING_DATA BIO_str_reasons[] = { {ERR_REASON(BIO_R_ACCEPT_ERROR) , "accept error"}, {ERR_REASON(BIO_R_BAD_FOPEN_MODE) , "bad fopen mode"}, {ERR_REASON(BIO_R_BAD_HOSTNAME_LOOKUP) , "bad hostname lookup"}, @@ -112,8 +114,8 @@ ERR_load_BIO_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) { - ERR_load_strings(0, BIO_str_functs); - ERR_load_strings(0, BIO_str_reasons); + ERR_load_const_strings(BIO_str_functs); + ERR_load_const_strings(BIO_str_reasons); } #endif } diff --git a/lib/libcrypto/bn/bn_err.c b/lib/libcrypto/bn/bn_err.c index 6fd6030a0..3ee6b4311 100644 --- a/lib/libcrypto/bn/bn_err.c +++ b/lib/libcrypto/bn/bn_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_err.c,v 1.17 2023/07/08 12:21:58 beck Exp $ */ +/* $OpenBSD: bn_err.c,v 1.18 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BN,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BN,0,reason) -static ERR_STRING_DATA BN_str_functs[]= { +static const ERR_STRING_DATA BN_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA BN_str_reasons[]= { +static const ERR_STRING_DATA BN_str_reasons[] = { {ERR_REASON(BN_R_ARG2_LT_ARG3) , "arg2 lt arg3"}, {ERR_REASON(BN_R_BAD_RECIPROCAL) , "bad reciprocal"}, {ERR_REASON(BN_R_BIGNUM_TOO_LONG) , "bignum too long"}, @@ -100,8 +102,8 @@ ERR_load_BN_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BN_str_functs[0].error) == NULL) { - ERR_load_strings(0, BN_str_functs); - ERR_load_strings(0, BN_str_reasons); + ERR_load_const_strings(BN_str_functs); + ERR_load_const_strings(BN_str_reasons); } #endif } diff --git a/lib/libcrypto/buffer/buf_err.c b/lib/libcrypto/buffer/buf_err.c index 3b045cf58..8637a06a7 100644 --- a/lib/libcrypto/buffer/buf_err.c +++ b/lib/libcrypto/buffer/buf_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf_err.c,v 1.13 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: buf_err.c,v 1.14 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BUF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason) -static ERR_STRING_DATA BUF_str_functs[] = { +static const ERR_STRING_DATA BUF_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA BUF_str_reasons[] = { +static const ERR_STRING_DATA BUF_str_reasons[] = { {0, NULL} }; @@ -81,8 +83,8 @@ ERR_load_BUF_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) { - ERR_load_strings(0, BUF_str_functs); - ERR_load_strings(0, BUF_str_reasons); + ERR_load_const_strings(BUF_str_functs); + ERR_load_const_strings(BUF_str_reasons); } #endif } diff --git a/lib/libcrypto/cms/cms_err.c b/lib/libcrypto/cms/cms_err.c index 5758a26db..5431ab4bb 100644 --- a/lib/libcrypto/cms/cms_err.c +++ b/lib/libcrypto/cms/cms_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_err.c,v 1.14 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: cms_err.c,v 1.15 2024/06/24 06:43:22 tb Exp $ */ /* * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * @@ -11,17 +11,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CMS,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CMS,0,reason) -static ERR_STRING_DATA CMS_str_functs[] = { +static const ERR_STRING_DATA CMS_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA CMS_str_reasons[] = { +static const ERR_STRING_DATA CMS_str_reasons[] = { {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ADD_SIGNER_ERROR), "add signer error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_ALREADY_PRESENT), "certificate already present"}, @@ -155,8 +157,8 @@ ERR_load_CMS_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(CMS_str_functs[0].error) == NULL) { - ERR_load_strings(ERR_LIB_CMS, CMS_str_functs); - ERR_load_strings(ERR_LIB_CMS, CMS_str_reasons); + ERR_load_const_strings(CMS_str_functs); + ERR_load_const_strings(CMS_str_reasons); } #endif return 1; diff --git a/lib/libcrypto/conf/conf_err.c b/lib/libcrypto/conf/conf_err.c index 9a44f22fa..5100847d8 100644 --- a/lib/libcrypto/conf/conf_err.c +++ b/lib/libcrypto/conf/conf_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_err.c,v 1.16 2024/04/09 13:56:30 beck Exp $ */ +/* $OpenBSD: conf_err.c,v 1.17 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CONF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CONF,0,reason) -static ERR_STRING_DATA CONF_str_functs[]= { +static const ERR_STRING_DATA CONF_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA CONF_str_reasons[]= { +static const ERR_STRING_DATA CONF_str_reasons[] = { {ERR_REASON(CONF_R_ERROR_LOADING_DSO) , "error loading dso"}, {ERR_REASON(CONF_R_LIST_CANNOT_BE_NULL) , "list cannot be null"}, {ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET), "missing close square bracket"}, @@ -98,8 +100,8 @@ ERR_load_CONF_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(CONF_str_functs[0].error) == NULL) { - ERR_load_strings(0, CONF_str_functs); - ERR_load_strings(0, CONF_str_reasons); + ERR_load_const_strings(CONF_str_functs); + ERR_load_const_strings(CONF_str_reasons); } #endif } diff --git a/lib/libcrypto/cpt_err.c b/lib/libcrypto/cpt_err.c index ff4e5c4bc..459b99d43 100644 --- a/lib/libcrypto/cpt_err.c +++ b/lib/libcrypto/cpt_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpt_err.c,v 1.15 2023/07/08 08:28:23 beck Exp $ */ +/* $OpenBSD: cpt_err.c,v 1.16 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,12 +60,14 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CRYPTO,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CRYPTO,0,reason) -static ERR_STRING_DATA CRYPTO_str_functs[] = { +static const ERR_STRING_DATA CRYPTO_str_functs[] = { {ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX), "CRYPTO_get_ex_new_index"}, {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID), "CRYPTO_get_new_dynlockid"}, {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID), "CRYPTO_get_new_lockid"}, @@ -79,7 +81,7 @@ static ERR_STRING_DATA CRYPTO_str_functs[] = { {0, NULL} }; -static ERR_STRING_DATA CRYPTO_str_reasons[] = { +static const ERR_STRING_DATA CRYPTO_str_reasons[] = { {ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"}, {ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK), "no dynlock create callback"}, {0, NULL} @@ -92,8 +94,8 @@ ERR_load_CRYPTO_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) { - ERR_load_strings(0, CRYPTO_str_functs); - ERR_load_strings(0, CRYPTO_str_reasons); + ERR_load_const_strings(CRYPTO_str_functs); + ERR_load_const_strings(CRYPTO_str_reasons); } #endif } diff --git a/lib/libcrypto/ct/ct_err.c b/lib/libcrypto/ct/ct_err.c index 2597874bd..494f88b89 100644 --- a/lib/libcrypto/ct/ct_err.c +++ b/lib/libcrypto/ct/ct_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ct_err.c,v 1.7 2022/07/12 14:42:48 kn Exp $ */ +/* $OpenBSD: ct_err.c,v 1.8 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -56,9 +56,11 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR -static ERR_STRING_DATA CT_str_functs[] = { +static const ERR_STRING_DATA CT_str_functs[] = { {ERR_PACK(ERR_LIB_CT, CT_F_CTLOG_NEW, 0), "CTLOG_new"}, {ERR_PACK(ERR_LIB_CT, CT_F_CTLOG_NEW_FROM_BASE64, 0), "CTLOG_new_from_base64"}, @@ -101,7 +103,7 @@ static ERR_STRING_DATA CT_str_functs[] = { {0, NULL} }; -static ERR_STRING_DATA CT_str_reasons[] = { +static const ERR_STRING_DATA CT_str_reasons[] = { {ERR_PACK(ERR_LIB_CT, 0, CT_R_BASE64_DECODE_ERROR), "base64 decode error"}, {ERR_PACK(ERR_LIB_CT, 0, CT_R_INVALID_LOG_ID_LENGTH), @@ -140,8 +142,8 @@ int ERR_load_CT_strings(void) { if (ERR_func_error_string(CT_str_functs[0].error) == NULL) { - ERR_load_strings(0, CT_str_functs); - ERR_load_strings(0, CT_str_reasons); + ERR_load_const_strings(CT_str_functs); + ERR_load_const_strings(CT_str_reasons); } return 1; } diff --git a/lib/libcrypto/dh/dh_err.c b/lib/libcrypto/dh/dh_err.c index 52fec7848..568eff575 100644 --- a/lib/libcrypto/dh/dh_err.c +++ b/lib/libcrypto/dh/dh_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_err.c,v 1.21 2024/05/19 08:22:40 tb Exp $ */ +/* $OpenBSD: dh_err.c,v 1.22 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -57,20 +57,22 @@ #include -#include #include +#include + +#include "err_local.h" #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DH,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DH,0,reason) -static ERR_STRING_DATA DH_str_functs[] = { +static const ERR_STRING_DATA DH_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA DH_str_reasons[] = { +static const ERR_STRING_DATA DH_str_reasons[] = { {ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, {ERR_REASON(DH_R_BN_DECODE_ERROR) ,"bn decode error"}, {ERR_REASON(DH_R_BN_ERROR) ,"bn error"}, @@ -104,8 +106,8 @@ ERR_load_DH_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(DH_str_functs[0].error) == NULL) { - ERR_load_strings(0, DH_str_functs); - ERR_load_strings(0, DH_str_reasons); + ERR_load_const_strings(DH_str_functs); + ERR_load_const_strings(DH_str_reasons); } #endif } diff --git a/lib/libcrypto/dsa/dsa_err.c b/lib/libcrypto/dsa/dsa_err.c index 048fa8df4..b7670f895 100644 --- a/lib/libcrypto/dsa/dsa_err.c +++ b/lib/libcrypto/dsa/dsa_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_err.c,v 1.21 2024/05/19 08:22:40 tb Exp $ */ +/* $OpenBSD: dsa_err.c,v 1.22 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSA,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSA,0,reason) -static ERR_STRING_DATA DSA_str_functs[] = { +static const ERR_STRING_DATA DSA_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA DSA_str_reasons[] = { +static const ERR_STRING_DATA DSA_str_reasons[] = { {ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, {ERR_REASON(DSA_R_BN_DECODE_ERROR) ,"bn decode error"}, {ERR_REASON(DSA_R_BN_ERROR) ,"bn error"}, @@ -94,8 +96,8 @@ ERR_load_DSA_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(DSA_str_functs[0].error) == NULL) { - ERR_load_strings(0, DSA_str_functs); - ERR_load_strings(0, DSA_str_reasons); + ERR_load_const_strings(DSA_str_functs); + ERR_load_const_strings(DSA_str_reasons); } #endif } diff --git a/lib/libcrypto/ec/ec_err.c b/lib/libcrypto/ec/ec_err.c index 7ecbb6656..2a6c419b5 100644 --- a/lib/libcrypto/ec/ec_err.c +++ b/lib/libcrypto/ec/ec_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_err.c,v 1.19 2024/05/19 08:26:03 tb Exp $ */ +/* $OpenBSD: ec_err.c,v 1.20 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_EC,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_EC,0,reason) -static ERR_STRING_DATA EC_str_functs[] = { +static const ERR_STRING_DATA EC_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA EC_str_reasons[] = { +static const ERR_STRING_DATA EC_str_reasons[] = { {ERR_REASON(EC_R_ASN1_ERROR), "asn1 error"}, {ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD), "asn1 unknown field"}, {ERR_REASON(EC_R_BAD_SIGNATURE), "bad signature"}, @@ -140,10 +142,9 @@ void ERR_load_EC_strings(void) { #ifndef OPENSSL_NO_ERR - if (ERR_func_error_string(EC_str_functs[0].error) == NULL) { - ERR_load_strings(0, EC_str_functs); - ERR_load_strings(0, EC_str_reasons); + ERR_load_const_strings(EC_str_functs); + ERR_load_const_strings(EC_str_reasons); } #endif } diff --git a/lib/libcrypto/err/err.c b/lib/libcrypto/err/err.c index a7b13a540..583293e79 100644 --- a/lib/libcrypto/err/err.c +++ b/lib/libcrypto/err/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.60 2024/03/02 11:37:13 tb Exp $ */ +/* $OpenBSD: err.c,v 1.61 2024/06/24 06:43:22 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -244,9 +244,9 @@ struct st_ERR_FNS { /* Works on the "error_hash" string table */ LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); void (*cb_err_del)(void); - ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *); - ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *); - ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *); + const ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *); + const ERR_STRING_DATA *(*cb_err_set_item)(const ERR_STRING_DATA *); + const ERR_STRING_DATA *(*cb_err_del_item)(const ERR_STRING_DATA *); /* Works on the "thread_hash" error-state table */ LHASH_OF(ERR_STATE) *(*cb_thread_get)(int create); void (*cb_thread_release)(LHASH_OF(ERR_STATE) **hash); @@ -260,9 +260,9 @@ struct st_ERR_FNS { /* Predeclarations of the "err_defaults" functions */ static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); static void int_err_del(void); -static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *); -static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *); -static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *); +static const ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *); +static const ERR_STRING_DATA *int_err_set_item(const ERR_STRING_DATA *); +static const ERR_STRING_DATA *int_err_del_item(const ERR_STRING_DATA *); static LHASH_OF(ERR_STATE) *int_thread_get(int create); static void int_thread_release(LHASH_OF(ERR_STATE) **hash); static ERR_STATE *int_thread_get_item(const ERR_STATE *); @@ -369,7 +369,7 @@ int_err_del(void) CRYPTO_w_unlock(CRYPTO_LOCK_ERR); } -static ERR_STRING_DATA * +static const ERR_STRING_DATA * int_err_get_item(const ERR_STRING_DATA *d) { ERR_STRING_DATA *p; @@ -387,10 +387,10 @@ int_err_get_item(const ERR_STRING_DATA *d) return p; } -static ERR_STRING_DATA * -int_err_set_item(ERR_STRING_DATA *d) +static const ERR_STRING_DATA * +int_err_set_item(const ERR_STRING_DATA *d) { - ERR_STRING_DATA *p; + const ERR_STRING_DATA *p; LHASH_OF(ERR_STRING_DATA) *hash; err_fns_check(); @@ -399,14 +399,14 @@ int_err_set_item(ERR_STRING_DATA *d) return NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); - p = lh_ERR_STRING_DATA_insert(hash, d); + p = lh_ERR_STRING_DATA_insert(hash, (void *)d); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return p; } -static ERR_STRING_DATA * -int_err_del_item(ERR_STRING_DATA *d) +static const ERR_STRING_DATA * +int_err_del_item(const ERR_STRING_DATA *d) { ERR_STRING_DATA *p; LHASH_OF(ERR_STRING_DATA) *hash; @@ -692,6 +692,16 @@ ERR_load_strings(int lib, ERR_STRING_DATA *str) } LCRYPTO_ALIAS(ERR_load_strings); +void +ERR_load_const_strings(const ERR_STRING_DATA *str) +{ + ERR_load_ERR_strings(); + while (str->error) { + ERRFN(err_set_item)(str); + str++; + } +} + void ERR_unload_strings(int lib, ERR_STRING_DATA *str) { @@ -964,7 +974,8 @@ LCRYPTO_ALIAS(ERR_error_string); const char * ERR_lib_error_string(unsigned long e) { - ERR_STRING_DATA d, *p; + const ERR_STRING_DATA *p; + ERR_STRING_DATA d; unsigned long l; if (!OPENSSL_init_crypto(0, NULL)) @@ -981,7 +992,8 @@ LCRYPTO_ALIAS(ERR_lib_error_string); const char * ERR_func_error_string(unsigned long e) { - ERR_STRING_DATA d, *p; + const ERR_STRING_DATA *p; + ERR_STRING_DATA d; unsigned long l, f; err_fns_check(); @@ -996,7 +1008,8 @@ LCRYPTO_ALIAS(ERR_func_error_string); const char * ERR_reason_error_string(unsigned long e) { - ERR_STRING_DATA d, *p = NULL; + const ERR_STRING_DATA *p = NULL; + ERR_STRING_DATA d; unsigned long l, r; err_fns_check(); diff --git a/lib/libcrypto/err/err_local.h b/lib/libcrypto/err/err_local.h new file mode 100644 index 000000000..d091b979c --- /dev/null +++ b/lib/libcrypto/err/err_local.h @@ -0,0 +1,123 @@ +/* $OpenBSD: err_local.h,v 1.1 2024/06/24 06:43:22 tb Exp $ */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#ifndef HEADER_ERR_LOCAL_H +#define HEADER_ERR_LOCAL_H + +__BEGIN_HIDDEN_DECLS + +void ERR_load_const_strings(const ERR_STRING_DATA *str); + +__END_HIDDEN_DECLS + +#endif /* HEADER_ERR_LOCAL_H */ diff --git a/lib/libcrypto/evp/evp_err.c b/lib/libcrypto/evp/evp_err.c index 07515f4d9..a41339c77 100644 --- a/lib/libcrypto/evp/evp_err.c +++ b/lib/libcrypto/evp/evp_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_err.c,v 1.33 2024/04/09 13:52:41 beck Exp $ */ +/* $OpenBSD: evp_err.c,v 1.34 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_EVP,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_EVP,0,reason) -static ERR_STRING_DATA EVP_str_functs[] = { +static const ERR_STRING_DATA EVP_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA EVP_str_reasons[] = { +static const ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_AES_IV_SETUP_FAILED) , "aes iv setup failed"}, {ERR_REASON(EVP_R_AES_KEY_SETUP_FAILED) , "aes key setup failed"}, {ERR_REASON(EVP_R_ASN1_LIB) , "asn1 lib"}, @@ -159,8 +161,8 @@ ERR_load_EVP_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(EVP_str_functs[0].error) == NULL) { - ERR_load_strings(0, EVP_str_functs); - ERR_load_strings(0, EVP_str_reasons); + ERR_load_const_strings(EVP_str_functs); + ERR_load_const_strings(EVP_str_reasons); } #endif } diff --git a/lib/libcrypto/kdf/kdf_err.c b/lib/libcrypto/kdf/kdf_err.c index 4dd323701..fc38e0813 100644 --- a/lib/libcrypto/kdf/kdf_err.c +++ b/lib/libcrypto/kdf/kdf_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdf_err.c,v 1.9 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: kdf_err.c,v 1.10 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2018 The OpenSSL Project. All rights reserved. * @@ -56,16 +56,18 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR -static ERR_STRING_DATA KDF_str_functs[] = { +static const ERR_STRING_DATA KDF_str_functs[] = { {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_CTRL_STR, 0), "pkey_hkdf_ctrl_str"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_DERIVE, 0), "pkey_hkdf_derive"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_INIT, 0), "pkey_hkdf_init"}, {0, NULL}, }; -static ERR_STRING_DATA KDF_str_reasons[] = { +static const ERR_STRING_DATA KDF_str_reasons[] = { {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_KEY), "missing key"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_MESSAGE_DIGEST), "missing message digest"}, @@ -81,8 +83,8 @@ ERR_load_KDF_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(KDF_str_functs[0].error) == NULL) { - ERR_load_strings(0, KDF_str_functs); - ERR_load_strings(0, KDF_str_reasons); + ERR_load_const_strings(KDF_str_functs); + ERR_load_const_strings(KDF_str_reasons); } #endif return 1; diff --git a/lib/libcrypto/objects/obj_err.c b/lib/libcrypto/objects/obj_err.c index 04cb4218c..514fb0d4f 100644 --- a/lib/libcrypto/objects/obj_err.c +++ b/lib/libcrypto/objects/obj_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_err.c,v 1.14 2023/07/08 12:27:51 beck Exp $ */ +/* $OpenBSD: obj_err.c,v 1.15 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_OBJ,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_OBJ,0,reason) -static ERR_STRING_DATA OBJ_str_functs[] = { +static const ERR_STRING_DATA OBJ_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA OBJ_str_reasons[] = { +static const ERR_STRING_DATA OBJ_str_reasons[] = { {ERR_REASON(OBJ_R_MALLOC_FAILURE) , "malloc failure"}, {ERR_REASON(OBJ_R_UNKNOWN_NID) , "unknown nid"}, {0, NULL} @@ -83,8 +85,8 @@ ERR_load_OBJ_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(OBJ_str_functs[0].error) == NULL) { - ERR_load_strings(0, OBJ_str_functs); - ERR_load_strings(0, OBJ_str_reasons); + ERR_load_const_strings(OBJ_str_functs); + ERR_load_const_strings(OBJ_str_reasons); } #endif } diff --git a/lib/libcrypto/ocsp/ocsp_err.c b/lib/libcrypto/ocsp/ocsp_err.c index 865091f54..ca8f8f22b 100644 --- a/lib/libcrypto/ocsp/ocsp_err.c +++ b/lib/libcrypto/ocsp/ocsp_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_err.c,v 1.10 2023/07/08 10:44:00 beck Exp $ */ +/* $OpenBSD: ocsp_err.c,v 1.11 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_OCSP,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_OCSP,0,reason) -static ERR_STRING_DATA OCSP_str_functs[]= { +static const ERR_STRING_DATA OCSP_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA OCSP_str_reasons[]= { +static const ERR_STRING_DATA OCSP_str_reasons[] = { {ERR_REASON(OCSP_R_BAD_DATA) , "bad data"}, {ERR_REASON(OCSP_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(OCSP_R_DIGEST_ERR) , "digest err"}, @@ -111,8 +113,8 @@ ERR_load_OCSP_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(OCSP_str_functs[0].error) == NULL) { - ERR_load_strings(0, OCSP_str_functs); - ERR_load_strings(0, OCSP_str_reasons); + ERR_load_const_strings(OCSP_str_functs); + ERR_load_const_strings(OCSP_str_reasons); } #endif } diff --git a/lib/libcrypto/pem/pem_err.c b/lib/libcrypto/pem/pem_err.c index a94e2d5eb..05025c8ee 100644 --- a/lib/libcrypto/pem/pem_err.c +++ b/lib/libcrypto/pem/pem_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_err.c,v 1.14 2023/07/07 13:40:44 beck Exp $ */ +/* $OpenBSD: pem_err.c,v 1.15 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PEM,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PEM,0,reason) -static ERR_STRING_DATA PEM_str_functs[] = { +static const ERR_STRING_DATA PEM_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA PEM_str_reasons[] = { +static const ERR_STRING_DATA PEM_str_reasons[] = { {ERR_REASON(PEM_R_BAD_BASE64_DECODE) , "bad base64 decode"}, {ERR_REASON(PEM_R_BAD_DECRYPT) , "bad decrypt"}, {ERR_REASON(PEM_R_BAD_END_LINE) , "bad end line"}, @@ -109,8 +111,8 @@ ERR_load_PEM_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PEM_str_functs[0].error) == NULL) { - ERR_load_strings(0, PEM_str_functs); - ERR_load_strings(0, PEM_str_reasons); + ERR_load_const_strings(PEM_str_functs); + ERR_load_const_strings(PEM_str_reasons); } #endif } diff --git a/lib/libcrypto/pkcs12/pk12err.c b/lib/libcrypto/pkcs12/pk12err.c index 3af03528a..c04c83c4f 100644 --- a/lib/libcrypto/pkcs12/pk12err.c +++ b/lib/libcrypto/pkcs12/pk12err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk12err.c,v 1.14 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: pk12err.c,v 1.15 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PKCS12,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PKCS12,0,reason) -static ERR_STRING_DATA PKCS12_str_functs[]= { +static const ERR_STRING_DATA PKCS12_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA PKCS12_str_reasons[]= { +static const ERR_STRING_DATA PKCS12_str_reasons[] = { {ERR_REASON(PKCS12_R_CANT_PACK_STRUCTURE), "cant pack structure"}, {ERR_REASON(PKCS12_R_CONTENT_TYPE_NOT_DATA), "content type not data"}, {ERR_REASON(PKCS12_R_DECODE_ERROR) , "decode error"}, @@ -103,8 +105,8 @@ ERR_load_PKCS12_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PKCS12_str_functs[0].error) == NULL) { - ERR_load_strings(0, PKCS12_str_functs); - ERR_load_strings(0, PKCS12_str_reasons); + ERR_load_const_strings(PKCS12_str_functs); + ERR_load_const_strings(PKCS12_str_reasons); } #endif } diff --git a/lib/libcrypto/pkcs7/pkcs7err.c b/lib/libcrypto/pkcs7/pkcs7err.c index d3ca0ec6d..d4e6d7cf7 100644 --- a/lib/libcrypto/pkcs7/pkcs7err.c +++ b/lib/libcrypto/pkcs7/pkcs7err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs7err.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: pkcs7err.c,v 1.16 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PKCS7,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PKCS7,0,reason) -static ERR_STRING_DATA PKCS7_str_functs[]= { +static const ERR_STRING_DATA PKCS7_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA PKCS7_str_reasons[]= { +static const ERR_STRING_DATA PKCS7_str_reasons[] = { {ERR_REASON(PKCS7_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER), "cipher has no object identifier"}, {ERR_REASON(PKCS7_R_CIPHER_NOT_INITIALIZED), "cipher not initialized"}, @@ -135,8 +137,8 @@ ERR_load_PKCS7_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PKCS7_str_functs[0].error) == NULL) { - ERR_load_strings(0, PKCS7_str_functs); - ERR_load_strings(0, PKCS7_str_reasons); + ERR_load_const_strings(PKCS7_str_functs); + ERR_load_const_strings(PKCS7_str_reasons); } #endif } diff --git a/lib/libcrypto/rand/rand_err.c b/lib/libcrypto/rand/rand_err.c index b156c0c87..1f0e25120 100644 --- a/lib/libcrypto/rand/rand_err.c +++ b/lib/libcrypto/rand/rand_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rand_err.c,v 1.17 2023/07/07 12:01:32 beck Exp $ */ +/* $OpenBSD: rand_err.c,v 1.18 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_RAND,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_RAND,0,reason) -static ERR_STRING_DATA RAND_str_functs[] = { +static const ERR_STRING_DATA RAND_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA RAND_str_reasons[] = { +static const ERR_STRING_DATA RAND_str_reasons[] = { {ERR_REASON(RAND_R_DUAL_EC_DRBG_DISABLED), "dual ec drbg disabled"}, {ERR_REASON(RAND_R_ERROR_INITIALISING_DRBG), "error initialising drbg"}, {ERR_REASON(RAND_R_ERROR_INSTANTIATING_DRBG), "error instantiating drbg"}, @@ -86,8 +88,8 @@ ERR_load_RAND_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(RAND_str_functs[0].error) == NULL) { - ERR_load_strings(0, RAND_str_functs); - ERR_load_strings(0, RAND_str_reasons); + ERR_load_const_strings(RAND_str_functs); + ERR_load_const_strings(RAND_str_reasons); } #endif } diff --git a/lib/libcrypto/rsa/rsa_err.c b/lib/libcrypto/rsa/rsa_err.c index 8b5416890..934a59f66 100644 --- a/lib/libcrypto/rsa/rsa_err.c +++ b/lib/libcrypto/rsa/rsa_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_err.c,v 1.22 2023/07/08 12:26:45 beck Exp $ */ +/* $OpenBSD: rsa_err.c,v 1.23 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_RSA,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_RSA,0,reason) -static ERR_STRING_DATA RSA_str_functs[] = { +static const ERR_STRING_DATA RSA_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA RSA_str_reasons[] = { +static const ERR_STRING_DATA RSA_str_reasons[] = { {ERR_REASON(RSA_R_ALGORITHM_MISMATCH) , "algorithm mismatch"}, {ERR_REASON(RSA_R_BAD_E_VALUE) , "bad e value"}, {ERR_REASON(RSA_R_BAD_FIXED_HEADER_DECRYPT), "bad fixed header decrypt"}, @@ -150,8 +152,8 @@ ERR_load_RSA_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(RSA_str_functs[0].error) == NULL) { - ERR_load_strings(0, RSA_str_functs); - ERR_load_strings(0, RSA_str_reasons); + ERR_load_const_strings(RSA_str_functs); + ERR_load_const_strings(RSA_str_reasons); } #endif } diff --git a/lib/libcrypto/ts/ts_err.c b/lib/libcrypto/ts/ts_err.c index bb8209a85..c0dcc7309 100644 --- a/lib/libcrypto/ts/ts_err.c +++ b/lib/libcrypto/ts/ts_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_err.c,v 1.7 2023/07/07 07:25:21 beck Exp $ */ +/* $OpenBSD: ts_err.c,v 1.8 2024/06/24 06:43:22 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_TS,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_TS,0,reason) -static ERR_STRING_DATA TS_str_functs[] = { +static const ERR_STRING_DATA TS_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA TS_str_reasons[]= { +static const ERR_STRING_DATA TS_str_reasons[] = { {ERR_REASON(TS_R_BAD_PKCS7_TYPE) , "bad pkcs7 type"}, {ERR_REASON(TS_R_BAD_TYPE) , "bad type"}, {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, @@ -116,8 +118,8 @@ ERR_load_TS_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(TS_str_functs[0].error) == NULL) { - ERR_load_strings(0, TS_str_functs); - ERR_load_strings(0, TS_str_reasons); + ERR_load_const_strings(TS_str_functs); + ERR_load_const_strings(TS_str_reasons); } #endif } diff --git a/lib/libcrypto/ui/ui_err.c b/lib/libcrypto/ui/ui_err.c index 3f875da77..656fa4288 100644 --- a/lib/libcrypto/ui/ui_err.c +++ b/lib/libcrypto/ui/ui_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_err.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: ui_err.c,v 1.13 2024/06/24 06:43:23 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -60,17 +60,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason) -static ERR_STRING_DATA UI_str_functs[] = { +static const ERR_STRING_DATA UI_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA UI_str_reasons[] = { +static const ERR_STRING_DATA UI_str_reasons[] = { {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"}, {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"}, {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"}, @@ -88,8 +90,8 @@ ERR_load_UI_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(UI_str_functs[0].error) == NULL) { - ERR_load_strings(0, UI_str_functs); - ERR_load_strings(0, UI_str_reasons); + ERR_load_const_strings(UI_str_functs); + ERR_load_const_strings(UI_str_reasons); } #endif } diff --git a/lib/libcrypto/x509/x509_conf.c b/lib/libcrypto/x509/x509_conf.c index a9e5076dc..b506d3ddf 100644 --- a/lib/libcrypto/x509/x509_conf.c +++ b/lib/libcrypto/x509/x509_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_conf.c,v 1.17 2024/06/18 09:47:03 tb Exp $ */ +/* $OpenBSD: x509_conf.c,v 1.18 2024/06/24 06:32:04 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -198,32 +198,32 @@ do_ext_i2d(const X509V3_EXT_METHOD *method, int nid, int crit, ext_der = NULL; ext_len = ASN1_item_i2d(ext_struct, &ext_der, method->it); if (ext_len < 0) - goto merr; + goto err; } else { unsigned char *p; if ((ext_len = method->i2d(ext_struct, NULL)) <= 0) - goto merr; + goto err; if ((ext_der = calloc(1, ext_len)) == NULL) - goto merr; + goto err; p = ext_der; if (method->i2d(ext_struct, &p) != ext_len) - goto merr; + goto err; } if ((ext_oct = ASN1_OCTET_STRING_new()) == NULL) - goto merr; + goto err; ASN1_STRING_set0(ext_oct, ext_der, ext_len); ext_der = NULL; ext_len = 0; ext = X509_EXTENSION_create_by_NID(NULL, nid, crit, ext_oct); if (ext == NULL) - goto merr; + goto err; ASN1_OCTET_STRING_free(ext_oct); return ext; - merr: + err: free(ext_der); ASN1_OCTET_STRING_free(ext_oct); X509V3error(ERR_R_MALLOC_FAILURE); diff --git a/lib/libcrypto/x509/x509_err.c b/lib/libcrypto/x509/x509_err.c index 2cbd34935..cff045b10 100644 --- a/lib/libcrypto/x509/x509_err.c +++ b/lib/libcrypto/x509/x509_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_err.c,v 1.22 2023/05/14 17:20:26 tb Exp $ */ +/* $OpenBSD: x509_err.c,v 1.23 2024/06/24 06:43:23 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -61,17 +61,19 @@ #include #include +#include "err_local.h" + #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_X509,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_X509,0,reason) -static ERR_STRING_DATA X509_str_functs[] = { +static const ERR_STRING_DATA X509_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA X509_str_reasons[] = { +static const ERR_STRING_DATA X509_str_reasons[] = { {ERR_REASON(X509_R_BAD_X509_FILETYPE) , "bad x509 filetype"}, {ERR_REASON(X509_R_BASE64_DECODE_ERROR) , "base64 decode error"}, {ERR_REASON(X509_R_CANT_CHECK_DH_KEY) , "cant check dh key"}, @@ -108,12 +110,12 @@ static ERR_STRING_DATA X509_str_reasons[] = { #define ERR_FUNC(func) ERR_PACK(ERR_LIB_X509V3,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_X509V3,0,reason) -static ERR_STRING_DATA X509V3_str_functs[] = { +static const ERR_STRING_DATA X509V3_str_functs[] = { {ERR_FUNC(0xfff), "CRYPTO_internal"}, {0, NULL} }; -static ERR_STRING_DATA X509V3_str_reasons[] = { +static const ERR_STRING_DATA X509V3_str_reasons[] = { {ERR_REASON(X509V3_R_BAD_IP_ADDRESS) , "bad ip address"}, {ERR_REASON(X509V3_R_BAD_OBJECT) , "bad object"}, {ERR_REASON(X509V3_R_BN_DEC2BN_ERROR) , "bn dec2bn error"}, @@ -192,8 +194,8 @@ ERR_load_X509_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509_str_functs[0].error) == NULL) { - ERR_load_strings(0, X509_str_functs); - ERR_load_strings(0, X509_str_reasons); + ERR_load_const_strings(X509_str_functs); + ERR_load_const_strings(X509_str_reasons); } #endif } @@ -205,8 +207,8 @@ ERR_load_X509V3_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509V3_str_functs[0].error) == NULL) { - ERR_load_strings(0, X509V3_str_functs); - ERR_load_strings(0, X509V3_str_reasons); + ERR_load_const_strings(X509V3_str_functs); + ERR_load_const_strings(X509V3_str_reasons); } #endif } diff --git a/lib/libssl/ssl_err.c b/lib/libssl/ssl_err.c index 30ca96b2f..5b130d45e 100644 --- a/lib/libssl/ssl_err.c +++ b/lib/libssl/ssl_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_err.c,v 1.47 2024/02/03 15:58:33 beck Exp $ */ +/* $OpenBSD: ssl_err.c,v 1.49 2024/06/24 06:50:07 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -67,7 +67,7 @@ #define ERR_REASON(reason) ERR_PACK(ERR_LIB_SSL,0,reason) /* See SSL_state_func_code below */ -static ERR_STRING_DATA SSL_str_functs[]= { +static ERR_STRING_DATA SSL_str_functs[] = { {ERR_FUNC(1), "CONNECT_CW_FLUSH"}, {ERR_FUNC(2), "CONNECT_CW_CLNT_HELLO"}, {ERR_FUNC(3), "CONNECT_CW_CLNT_HELLO"}, @@ -136,19 +136,19 @@ static ERR_STRING_DATA SSL_str_functs[]= { {ERR_FUNC(70), "ACCEPT_SW_SESSION_TICKET"}, {ERR_FUNC(71), "ACCEPT_SW_CERT_STATUS"}, {ERR_FUNC(72), "ACCEPT_SW_CERT_STATUS"}, - {ERR_FUNC(73), "ST_BEFORE"}, - {ERR_FUNC(74), "ST_ACCEPT"}, - {ERR_FUNC(75), "ST_CONNECT"}, - {ERR_FUNC(76), "ST_OK"}, - {ERR_FUNC(77), "ST_RENEGOTIATE"}, - {ERR_FUNC(78), "ST_BEFORE_CONNECT"}, - {ERR_FUNC(79), "ST_OK_CONNECT"}, - {ERR_FUNC(80), "ST_BEFORE_ACCEPT"}, - {ERR_FUNC(81), "ST_OK_ACCEPT"}, + {ERR_FUNC(73), "ST_BEFORE"}, + {ERR_FUNC(74), "ST_ACCEPT"}, + {ERR_FUNC(75), "ST_CONNECT"}, + {ERR_FUNC(76), "ST_OK"}, + {ERR_FUNC(77), "ST_RENEGOTIATE"}, + {ERR_FUNC(78), "ST_BEFORE_CONNECT"}, + {ERR_FUNC(79), "ST_OK_CONNECT"}, + {ERR_FUNC(80), "ST_BEFORE_ACCEPT"}, + {ERR_FUNC(81), "ST_OK_ACCEPT"}, {ERR_FUNC(83), "DTLS1_ST_CR_HELLO_VERIFY_REQUEST"}, - {ERR_FUNC(84), "DTLS1_ST_CR_HELLO_VERIFY_REQUEST"}, - {ERR_FUNC(85), "DTLS1_ST_SW_HELLO_VERIFY_REQUEST"}, - {ERR_FUNC(86), "DTLS1_ST_SW_HELLO_VERIFY_REQUEST"}, + {ERR_FUNC(84), "DTLS1_ST_CR_HELLO_VERIFY_REQUEST"}, + {ERR_FUNC(85), "DTLS1_ST_SW_HELLO_VERIFY_REQUEST"}, + {ERR_FUNC(86), "DTLS1_ST_SW_HELLO_VERIFY_REQUEST"}, {ERR_FUNC(0xfff), "(UNKNOWN)SSL_internal"}, {0, NULL} }; diff --git a/regress/lib/libssl/rust-openssl/Makefile b/regress/lib/libssl/rust-openssl/Makefile index a243995f2..dc17deee6 100644 --- a/regress/lib/libssl/rust-openssl/Makefile +++ b/regress/lib/libssl/rust-openssl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2022/12/05 14:43:06 tb Exp $ +# $OpenBSD: Makefile,v 1.5 2024/06/23 13:53:21 tb Exp $ RUST_OPENSSL_TESTS = /usr/local/share/rust-openssl-tests CARGO = /usr/local/bin/cargo @@ -20,7 +20,7 @@ ${_WORKSPACE_COOKIE}: cp ${.CURDIR}/Cargo.toml ${.OBJDIR}/ . endif mkdir -p .cargo - cp ${.CURDIR}/config .cargo/ + cp ${.CURDIR}/config.toml .cargo/ cd ${.OBJDIR} && ln -sf ${WORKSPACE_LINKS:S,^,${RUST_OPENSSL_TESTS}/,} . touch $@ diff --git a/regress/lib/libssl/rust-openssl/config b/regress/lib/libssl/rust-openssl/config.toml similarity index 100% rename from regress/lib/libssl/rust-openssl/config rename to regress/lib/libssl/rust-openssl/config.toml diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c index ed3eae60e..c5adb4f98 100644 --- a/sys/arch/amd64/amd64/mem.c +++ b/sys/arch/amd64/amd64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.35 2021/03/24 14:26:39 bluhm Exp $ */ +/* $OpenBSD: mem.c,v 1.36 2024/06/23 22:08:37 kettenis Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -252,7 +252,7 @@ mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return mem_ioctl(dev, cmd, data, flags, p); } #endif - return (ENODEV); + return (ENOTTY); } #ifdef MTRR diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c index f0809db36..85c0f69d5 100644 --- a/sys/arch/arm/arm/mem.c +++ b/sys/arch/arm/arm/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.23 2021/03/25 04:12:00 jsg Exp $ */ +/* $OpenBSD: mem.c,v 1.24 2024/06/23 22:08:37 kettenis Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -251,5 +251,5 @@ mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return 0; } - return (EOPNOTSUPP); + return (ENOTTY); } diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index a80a30691..b5abc4f9c 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.120 2024/06/21 01:52:17 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.121 2024/06/23 10:17:16 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -1174,6 +1174,8 @@ cpu_init(void) if (ID_AA64MMFR1_PAN(id_aa64mmfr1) >= ID_AA64MMFR1_PAN_IMPL) { sctlr = READ_SPECIALREG(sctlr_el1); sctlr &= ~SCTLR_SPAN; + if (ID_AA64MMFR1_PAN(id_aa64mmfr1) >= ID_AA64MMFR1_PAN_EPAN) + sctlr |= SCTLR_EPAN; WRITE_SPECIALREG(sctlr_el1, sctlr); } diff --git a/sys/arch/arm64/arm64/mem.c b/sys/arch/arm64/arm64/mem.c index ace9d6699..2084b979d 100644 --- a/sys/arch/arm64/arm64/mem.c +++ b/sys/arch/arm64/arm64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.6 2018/05/04 15:45:11 visa Exp $ */ +/* $OpenBSD: mem.c,v 1.7 2024/06/23 22:08:37 kettenis Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -253,5 +253,5 @@ mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return 0; } - return (EOPNOTSUPP); + return (ENOTTY); } diff --git a/sys/arch/arm64/dev/agintc.c b/sys/arch/arm64/dev/agintc.c index 22b59258d..de7e54cee 100644 --- a/sys/arch/arm64/dev/agintc.c +++ b/sys/arch/arm64/dev/agintc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agintc.c,v 1.57 2024/06/19 22:10:45 patrick Exp $ */ +/* $OpenBSD: agintc.c,v 1.58 2024/06/23 21:58:34 patrick Exp $ */ /* * Copyright (c) 2007, 2009, 2011, 2017 Dale Rahn * Copyright (c) 2018 Mark Kettenis @@ -1516,6 +1516,7 @@ agintc_send_ipi(struct cpu_info *ci, int id) #define GITS_BASER_PGSZ_4K (0ULL << 8) #define GITS_BASER_PGSZ_16K (1ULL << 8) #define GITS_BASER_PGSZ_64K (2ULL << 8) +#define GITS_BASER_SZ_MASK (0xffULL) #define GITS_BASER_PA_MASK 0x7ffffffff000ULL #define GITS_TRANSLATER 0x10040 @@ -1572,6 +1573,7 @@ struct agintc_msi_softc { uint16_t sc_cmdidx; int sc_devbits; + uint32_t sc_deviceid_max; struct agintc_dmamem *sc_dtt; size_t sc_dtt_pgsz; uint8_t sc_dte_sz; @@ -1703,6 +1705,13 @@ agintc_msi_attach(struct device *parent, struct device *self, void *aux) size = (1ULL << sc->sc_devbits) * sc->sc_dte_sz; size = roundup(size, sc->sc_dtt_pgsz); + /* Clamp down to maximum configurable num pages */ + if (size / sc->sc_dtt_pgsz > GITS_BASER_SZ_MASK + 1) + size = (GITS_BASER_SZ_MASK + 1) * sc->sc_dtt_pgsz; + + /* Calculate max deviceid based off configured size */ + sc->sc_deviceid_max = (size / sc->sc_dte_sz) - 1; + /* Allocate table. */ sc->sc_dtt = agintc_dmamem_alloc(sc->sc_dmat, size, sc->sc_dtt_pgsz); @@ -1858,6 +1867,9 @@ agintc_msi_create_device(struct agintc_msi_softc *sc, uint32_t deviceid) struct agintc_msi_device *md; struct gits_cmd cmd; + if (deviceid > sc->sc_deviceid_max) + return NULL; + md = malloc(sizeof(*md), M_DEVBUF, M_ZERO | M_WAITOK); md->md_deviceid = deviceid; md->md_itt = agintc_dmamem_alloc(sc->sc_dmat, diff --git a/sys/arch/arm64/include/armreg.h b/sys/arch/arm64/include/armreg.h index 3aa58ef38..af325d1ce 100644 --- a/sys/arch/arm64/include/armreg.h +++ b/sys/arch/arm64/include/armreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armreg.h,v 1.34 2024/05/27 06:20:59 kettenis Exp $ */ +/* $OpenBSD: armreg.h,v 1.35 2024/06/23 10:17:16 kettenis Exp $ */ /*- * Copyright (c) 2013, 2014 Andrew Turner * Copyright (c) 2015 The FreeBSD Foundation @@ -705,6 +705,7 @@ #define SCTLR_EnIA 0x0000000080000000 #define SCTLR_BT0 0x0000000800000000 #define SCTLR_BT1 0x0000001000000000 +#define SCTLR_EPAN 0x0200000000000000 /* SPSR_EL1 */ /* diff --git a/sys/arch/arm64/stand/efiboot/conf.c b/sys/arch/arm64/stand/efiboot/conf.c index a1174dc8b..36090e2b7 100644 --- a/sys/arch/arm64/stand/efiboot/conf.c +++ b/sys/arch/arm64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.48 2024/06/14 19:49:17 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.49 2024/06/23 15:37:31 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -47,7 +47,7 @@ #include "efipxe.h" #include "softraid_arm64.h" -const char version[] = "1.19"; +const char version[] = "1.20"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/arm64/stand/efiboot/efiacpi.c b/sys/arch/arm64/stand/efiboot/efiacpi.c index 889b6f430..6f593cba8 100644 --- a/sys/arch/arm64/stand/efiboot/efiacpi.c +++ b/sys/arch/arm64/stand/efiboot/efiacpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiacpi.c,v 1.16 2023/10/09 22:05:27 patrick Exp $ */ +/* $OpenBSD: efiacpi.c,v 1.17 2024/06/23 15:37:31 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis @@ -402,7 +402,8 @@ static int gic_version; static uint64_t gicc_base; static uint64_t gicd_base; static uint64_t gicr_base; -static uint32_t gicr_size; +static uint64_t gicr_size; +static uint64_t gicr_stride; void efi_acpi_madt_gicc(struct acpi_madt_gicc *gicc) @@ -436,6 +437,30 @@ efi_acpi_madt_gicc(struct acpi_madt_gicc *gicc) /* Stash GIC information. */ gicc_base = gicc->base_address; + + /* + * The redistributor base address may be specified per-CPU. + * In that case we will need to reconstruct the base, size and + * stride to use for the redistributor registers. + */ + if (gicc->gicr_base_address > 0) { + if (gicr_base > 0) { + uint32_t size; + + if (gicc->gicr_base_address < gicr_base) + size = gicr_base - gicc->gicr_base_address; + else + size = gicc->gicr_base_address - gicr_base; + if (gicr_stride == 0 || size < gicr_stride) + gicr_stride = size; + if (gicr_size == 0 || size > gicr_size) + gicr_size = size; + gicr_base = MIN(gicr_base, gicc->gicr_base_address); + } else { + gicr_base = gicc->gicr_base_address; + gicr_size = 0x20000; + } + } } void @@ -579,7 +604,7 @@ efi_acpi_madt(struct acpi_table_header *hdr) reg[0] = htobe64(gicd_base); reg[1] = htobe64(0x10000); reg[2] = htobe64(gicr_base); - reg[3] = htobe64(gicr_size); + reg[3] = htobe64(gicr_size + gicr_stride); break; default: return; @@ -589,6 +614,11 @@ efi_acpi_madt(struct acpi_table_header *hdr) node = fdt_find_node("/interrupt-controller"); fdt_node_set_string_property(node, "compatible", compat); fdt_node_set_property(node, "reg", reg, sizeof(reg)); + if (gicr_stride > 0) { + uint64_t stride = htobe64(gicr_stride); + fdt_node_add_property(node, "redistributor-stride", + &stride, sizeof(stride)); + } fdt_node_set_string_property(node, "status", "okay"); } diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index 5b7245c75..b5d1124ea 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -1,5 +1,5 @@ /* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */ -/* $OpenBSD: mem.c,v 1.56 2023/03/08 04:43:07 guenther Exp $ */ +/* $OpenBSD: mem.c,v 1.57 2024/06/23 22:08:37 kettenis Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -260,7 +260,7 @@ mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return mem_ioctl(dev, cmd, data, flags, p); } #endif - return (ENODEV); + return (ENOTTY); } #ifdef MTRR diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index e880ccd45..75b6a1e44 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.70 2022/04/06 18:59:27 naddy Exp $ */ +/* $OpenBSD: acpibat.c,v 1.71 2024/06/24 15:56:07 mglocker Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -525,6 +525,12 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg) case 0x00: /* Poll sensors */ case 0x80: /* _BST changed */ acpibat_getbst(sc); + /* + * On some machines the Power Source Device doesn't get + * notified when the AC adapter is plugged or unplugged, + * but the battery does get notified. + */ + aml_notify_dev(ACPI_DEV_AC, 0x80); break; case 0x81: /* _BIF/_BIX changed */ acpibat_getbix(sc); diff --git a/sys/dev/fdt/qcscm.c b/sys/dev/fdt/qcscm.c index 1e39742e3..93ed4cd0d 100644 --- a/sys/dev/fdt/qcscm.c +++ b/sys/dev/fdt/qcscm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcscm.c,v 1.5 2023/07/22 22:48:35 patrick Exp $ */ +/* $OpenBSD: qcscm.c,v 1.6 2024/06/23 22:04:53 patrick Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -204,14 +204,25 @@ qcscm_smc_exec(uint64_t *in, uint64_t *out) "ldp x2, x3, [%0, #16]\n" "ldp x4, x5, [%0, #32]\n" "ldp x6, x7, [%0, #48]\n" + "ldp x8, x9, [%0, #64]\n" + "ldp x10, x11, [%0, #80]\n" + "ldp x12, x13, [%0, #96]\n" + "ldp x14, x15, [%0, #112]\n" + "ldp x16, x17, [%0, #128]\n" "smc #0\n" "stp x0, x1, [%1, #0]\n" "stp x2, x3, [%1, #16]\n" "stp x4, x5, [%1, #32]\n" - "stp x6, x7, [%1, #48]\n" :: + "stp x6, x7, [%1, #48]\n" + "stp x8, x9, [%1, #64]\n" + "stp x10, x11, [%1, #80]\n" + "stp x12, x13, [%1, #96]\n" + "stp x14, x15, [%1, #112]\n" + "stp x16, x17, [%1, #128]\n" :: "r" (in), "r" (out) : - "x0", "x1", "x2", "x3", - "x4", "x5", "x6", "x7", + "x0", "x1", "x2", "x3", "x4", "x5", + "x6", "x7", "x8", "x9", "x10", "x11", + "x12", "x13", "x14", "x15", "x16", "x17", "memory"); } @@ -219,7 +230,7 @@ int qcscm_smc_call(struct qcscm_softc *sc, uint8_t owner, uint8_t svc, uint8_t cmd, uint32_t arginfo, uint64_t *args, int arglen, uint64_t *res) { - uint64_t smcreq[8] = { 0 }, smcres[8] = { 0 }; + uint64_t smcreq[18] = { 0 }, smcres[18] = { 0 }; uint64_t *smcextreq; int i; diff --git a/sys/dev/fdt/rkusbphy.c b/sys/dev/fdt/rkusbphy.c index 7b2acad12..3807be0d6 100644 --- a/sys/dev/fdt/rkusbphy.c +++ b/sys/dev/fdt/rkusbphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkusbphy.c,v 1.4 2023/09/29 17:30:35 kettenis Exp $ */ +/* $OpenBSD: rkusbphy.c,v 1.5 2024/06/23 10:18:11 kettenis Exp $ */ /* * Copyright (c) 2023 David Gwynne @@ -90,6 +90,38 @@ static const struct rkusbphy_chip rkusbphy_rk3568[] = { }, }; +static const struct rkusbphy_regs rkusbphy_rk3588_regs = { + /* shift, mask, set */ + .clk_enable = { 0x0000, 0, 0x1, 0x0 }, + + .otg = { + .phy_enable = { 0x000c, 11, 0x1, 0x0 }, + }, + + .host = { + .phy_enable = { 0x0008, 2, 0x1, 0x0 }, + }, +}; + +static const struct rkusbphy_chip rkusbphy_rk3588[] = { + { + .c_base_addr = 0x0000, + .c_regs = &rkusbphy_rk3588_regs, + }, + { + .c_base_addr = 0x4000, + .c_regs = &rkusbphy_rk3588_regs, + }, + { + .c_base_addr = 0x8000, + .c_regs = &rkusbphy_rk3588_regs, + }, + { + .c_base_addr = 0xc000, + .c_regs = &rkusbphy_rk3588_regs, + }, +}; + /* * driver stuff */ @@ -159,6 +191,7 @@ struct rkusbphy_id { static const struct rkusbphy_id rkusbphy_ids[] = { RKUSBPHY_ID("rockchip,rk3568-usb2phy", rkusbphy_rk3568), + RKUSBPHY_ID("rockchip,rk3588-usb2phy", rkusbphy_rk3588), }; static const struct rkusbphy_id * @@ -213,7 +246,10 @@ rkusbphy_attach(struct device *parent, struct device *self, void *aux) sc->sc_node = faa->fa_node; grfph = OF_getpropint(sc->sc_node, "rockchip,usbgrf", 0); - sc->sc_grf = regmap_byphandle(grfph); + if (grfph) + sc->sc_grf = regmap_byphandle(grfph); + else + sc->sc_grf = regmap_bynode(OF_parent(faa->fa_node)); if (sc->sc_grf == NULL) { printf("%s: rockchip,usbgrf 0x%x not found\n", DEVNAME(sc), grfph); @@ -267,10 +303,8 @@ rkusbphy_register(struct rkusbphy_softc *sc, struct phy_device *pd, int node; node = OF_getnodebyname(sc->sc_node, pc->pc_name); - if (node == 0) { - printf("%s: cannot find %s\n", DEVNAME(sc), pc->pc_name); + if (node == 0) return; - } if (OF_getprop(node, "status", status, sizeof(status)) > 0 && strcmp(status, "disabled") == 0) diff --git a/sys/dev/pci/drm/i915/display/intel_audio.c b/sys/dev/pci/drm/i915/display/intel_audio.c index 294acf812..7e75b3867 100644 --- a/sys/dev/pci/drm/i915/display/intel_audio.c +++ b/sys/dev/pci/drm/i915/display/intel_audio.c @@ -1256,17 +1256,6 @@ static void i915_audio_component_init(struct drm_i915_private *i915) { #ifdef notyet u32 aud_freq, aud_freq_init; - int ret; - - ret = component_add_typed(i915->drm.dev, - &i915_audio_component_bind_ops, - I915_COMPONENT_AUDIO); - if (ret < 0) { - drm_err(&i915->drm, - "failed to add audio component (%d)\n", ret); - /* continue with reduced functionality */ - return; - } if (DISPLAY_VER(i915) >= 9) { aud_freq_init = intel_de_read(i915, AUD_FREQ_CNTRL); @@ -1289,6 +1278,23 @@ static void i915_audio_component_init(struct drm_i915_private *i915) /* init with current cdclk */ intel_audio_cdclk_change_post(i915); +#endif +} + +static void i915_audio_component_register(struct drm_i915_private *i915) +{ +#ifdef notyet + int ret; + + ret = component_add_typed(i915->drm.dev, + &i915_audio_component_bind_ops, + I915_COMPONENT_AUDIO); + if (ret < 0) { + drm_err(&i915->drm, + "failed to add audio component (%d)\n", ret); + /* continue with reduced functionality */ + return; + } i915->display.audio.component_registered = true; #endif @@ -1322,6 +1328,12 @@ void intel_audio_init(struct drm_i915_private *i915) i915_audio_component_init(i915); } +void intel_audio_register(struct drm_i915_private *i915) +{ + if (!i915->display.audio.lpe.platdev) + i915_audio_component_register(i915); +} + /** * intel_audio_deinit() - deinitialize the audio driver * @i915: the i915 drm device private data diff --git a/sys/dev/pci/drm/i915/display/intel_audio.h b/sys/dev/pci/drm/i915/display/intel_audio.h index 9bb9a19a4..289e74447 100644 --- a/sys/dev/pci/drm/i915/display/intel_audio.h +++ b/sys/dev/pci/drm/i915/display/intel_audio.h @@ -30,6 +30,7 @@ void intel_audio_codec_get_config(struct intel_encoder *encoder, void intel_audio_cdclk_change_pre(struct drm_i915_private *dev_priv); void intel_audio_cdclk_change_post(struct drm_i915_private *dev_priv); void intel_audio_init(struct drm_i915_private *dev_priv); +void intel_audio_register(struct drm_i915_private *i915); void intel_audio_deinit(struct drm_i915_private *dev_priv); void intel_audio_sdp_split_update(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state); diff --git a/sys/dev/pci/drm/i915/display/intel_display_driver.c b/sys/dev/pci/drm/i915/display/intel_display_driver.c index 69b5cef70..4b71b395d 100644 --- a/sys/dev/pci/drm/i915/display/intel_display_driver.c +++ b/sys/dev/pci/drm/i915/display/intel_display_driver.c @@ -388,6 +388,8 @@ void intel_display_driver_register(struct drm_i915_private *i915) intel_audio_init(i915); + intel_audio_register(i915); + intel_display_debugfs_register(i915); /* diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_object.h b/sys/dev/pci/drm/i915/gem/i915_gem_object.h index e5e9ea2f6..a4e14fa3a 100644 --- a/sys/dev/pci/drm/i915/gem/i915_gem_object.h +++ b/sys/dev/pci/drm/i915/gem/i915_gem_object.h @@ -285,7 +285,9 @@ bool i915_gem_object_has_iomem(const struct drm_i915_gem_object *obj); static inline bool i915_gem_object_is_shrinkable(const struct drm_i915_gem_object *obj) { - return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_SHRINKABLE); + /* TODO: make DPT shrinkable when it has no bound vmas */ + return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_SHRINKABLE) && + !obj->is_dpt; } static inline bool diff --git a/sys/dev/pci/drm/i915/gt/intel_breadcrumbs.c b/sys/dev/pci/drm/i915/gt/intel_breadcrumbs.c index f9d88fa8b..46b6d0fad 100644 --- a/sys/dev/pci/drm/i915/gt/intel_breadcrumbs.c +++ b/sys/dev/pci/drm/i915/gt/intel_breadcrumbs.c @@ -260,8 +260,13 @@ static void signal_irq_work(struct irq_work *work) i915_request_put(rq); } + /* Lazy irq enabling after HW submission */ if (!READ_ONCE(b->irq_armed) && !list_empty(&b->signalers)) intel_breadcrumbs_arm_irq(b); + + /* And confirm that we still want irqs enabled before we yield */ + if (READ_ONCE(b->irq_armed) && !atomic_read(&b->active)) + intel_breadcrumbs_disarm_irq(b); } struct intel_breadcrumbs * @@ -312,13 +317,7 @@ void __intel_breadcrumbs_park(struct intel_breadcrumbs *b) return; /* Kick the work once more to drain the signalers, and disarm the irq */ - irq_work_sync(&b->irq_work); - while (READ_ONCE(b->irq_armed) && !atomic_read(&b->active)) { - local_irq_disable(); - signal_irq_work(&b->irq_work); - local_irq_enable(); - cond_resched(); - } + irq_work_queue(&b->irq_work); } void intel_breadcrumbs_free(struct kref *kref) @@ -401,7 +400,7 @@ static void insert_breadcrumb(struct i915_request *rq) * the request as it may have completed and raised the interrupt as * we were attaching it into the lists. */ - if (!b->irq_armed || __i915_request_is_complete(rq)) + if (!READ_ONCE(b->irq_armed) || __i915_request_is_complete(rq)) irq_work_queue(&b->irq_work); } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 38057fceb..d561a7034 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.395 2024/06/07 18:24:16 bluhm Exp $ */ +/* $OpenBSD: ip_input.c,v 1.396 2024/06/24 12:19:19 bluhm Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1532,11 +1532,17 @@ const u_char inetctlerrmap[PRC_NCMDS] = { void ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) { - struct mbuf mfake, *mcopy; struct ip *ip = mtod(m, struct ip *); struct route iproute; struct rtentry *rt; - int error = 0, type = 0, code = 0, destmtu = 0, fake = 0, len; + u_int rtableid = m->m_pkthdr.ph_rtableid; + u_int8_t loopcnt = m->m_pkthdr.ph_loopcnt; + u_int icmp_len; + char icmp_buf[68]; + CTASSERT(sizeof(icmp_buf) <= MHLEN); + u_short mflags, pfflags; + struct mbuf *mcopy; + int error = 0, type = 0, code = 0, destmtu = 0; u_int32_t dest; dest = 0; @@ -1554,7 +1560,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) ro = &iproute; ro->ro_rt = NULL; } - rt = route_mpath(ro, &ip->ip_dst, &ip->ip_src, m->m_pkthdr.ph_rtableid); + rt = route_mpath(ro, &ip->ip_dst, &ip->ip_src, rtableid); if (rt == NULL) { ipstat_inc(ips_noroute); icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0); @@ -1562,24 +1568,14 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) } /* - * Save at most 68 bytes of the packet in case - * we need to generate an ICMP message to the src. - * The data is saved in the mbuf on the stack that - * acts as a temporary storage not intended to be - * passed down the IP stack or to the mfree. + * Save at most 68 bytes of the packet in case we need to generate + * an ICMP message to the src. The data is saved on the stack. + * A new mbuf is only allocated when ICMP is actually created. */ - memset(&mfake.m_hdr, 0, sizeof(mfake.m_hdr)); - mfake.m_type = m->m_type; - if (m_dup_pkthdr(&mfake, m, M_DONTWAIT) == 0) { - mfake.m_data = mfake.m_pktdat; - len = min(ntohs(ip->ip_len), 68); - m_copydata(m, 0, len, mfake.m_pktdat); - mfake.m_pkthdr.len = mfake.m_len = len; -#if NPF > 0 - pf_pkt_addr_changed(&mfake); -#endif /* NPF > 0 */ - fake = 1; - } + icmp_len = min(sizeof(icmp_buf), ntohs(ip->ip_len)); + mflags = m->m_flags; + pfflags = m->m_pkthdr.pf.flags; + m_copydata(m, 0, icmp_len, icmp_buf); ip->ip_ttl -= IPTTLDEC; @@ -1597,7 +1593,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && satosin(rt_key(rt))->sin_addr.s_addr != 0 && ip_sendredirects && !ISSET(flags, IP_REDIRECT) && - !arpproxy(satosin(rt_key(rt))->sin_addr, m->m_pkthdr.ph_rtableid)) { + !arpproxy(satosin(rt_key(rt))->sin_addr, rtableid)) { if ((ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_netmask) == ifatoia(rt->rt_ifa)->ia_net) { if (rt->rt_flags & RTF_GATEWAY) @@ -1621,9 +1617,6 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) else goto done; } - if (!fake) - goto done; - switch (error) { case 0: /* forwarded, but need redirect */ /* type, code set above */ @@ -1674,15 +1667,22 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags) code = ICMP_UNREACH_HOST; break; } - mcopy = m_copym(&mfake, 0, len, M_DONTWAIT); - if (mcopy != NULL) - icmp_error(mcopy, type, code, dest, destmtu); + + mcopy = m_gethdr(M_DONTWAIT, MT_DATA); + if (mcopy == NULL) + goto done; + mcopy->m_len = mcopy->m_pkthdr.len = icmp_len; + mcopy->m_flags |= (mflags & M_COPYFLAGS); + mcopy->m_pkthdr.ph_rtableid = rtableid; + mcopy->m_pkthdr.ph_ifidx = ifp->if_index; + mcopy->m_pkthdr.ph_loopcnt = loopcnt; + mcopy->m_pkthdr.pf.flags |= (pfflags & PF_TAG_GENERATED); + memcpy(mcopy->m_data, icmp_buf, icmp_len); + icmp_error(mcopy, type, code, dest, destmtu); done: if (ro == &iproute) rtfree(ro->ro_rt); - if (fake) - m_tag_delete_chain(&mfake); } int diff --git a/usr.bin/openssl/ca.c b/usr.bin/openssl/ca.c index 6fedd22c9..c0e011e7a 100644 --- a/usr.bin/openssl/ca.c +++ b/usr.bin/openssl/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.58 2024/02/04 13:08:29 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.59 2024/06/23 07:50:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2330,7 +2330,6 @@ certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509, if (sk_CONF_VALUE_num(sk) == 0) { BIO_printf(bio_err, "no name/value pairs found in %s\n", infile); - CONF_free(parms); goto err; } /* diff --git a/usr.bin/ssh/sshd_config.5 b/usr.bin/ssh/sshd_config.5 index 0a4d5d8ad..ef31e91b3 100644 --- a/usr.bin/ssh/sshd_config.5 +++ b/usr.bin/ssh/sshd_config.5 @@ -33,8 +33,8 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: sshd_config.5,v 1.363 2024/06/14 05:01:22 djm Exp $ -.Dd $Mdocdate: June 14 2024 $ +.\" $OpenBSD: sshd_config.5,v 1.365 2024/06/24 06:59:39 jmc Exp $ +.Dd $Mdocdate: June 24 2024 $ .Dt SSHD_CONFIG 5 .Os .Sh NAME @@ -1824,6 +1824,13 @@ via .Cm AcceptEnv or .Cm PermitUserEnvironment . +.It Cm SshdSessionPath +Overrides the default path to the +.Cm sshd-session +binary that is invoked to handle each connection. +The default is +.Pa /usr/libexec/sshd-session . +This option is intended for use by tests. .It Cm StreamLocalBindMask Sets the octal file creation mode mask .Pq umask diff --git a/usr.bin/tmux/cmd-refresh-client.c b/usr.bin/tmux/cmd-refresh-client.c index e1af3e859..04e5178bd 100644 --- a/usr.bin/tmux/cmd-refresh-client.c +++ b/usr.bin/tmux/cmd-refresh-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-refresh-client.c,v 1.48 2022/05/30 12:55:25 nicm Exp $ */ +/* $OpenBSD: cmd-refresh-client.c,v 1.49 2024/06/24 08:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,9 +34,10 @@ const struct cmd_entry cmd_refresh_client_entry = { .name = "refresh-client", .alias = "refresh", - .args = { "A:B:cC:Df:F:l::LRSt:U", 0, 1, NULL }, + .args = { "A:B:cC:Df:r:F:l::LRSt:U", 0, 1, NULL }, .usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] " - "[-C XxY] [-f flags] " CMD_TARGET_CLIENT_USAGE " [adjustment]", + "[-C XxY] [-f flags] [-r pane:report]" CMD_TARGET_CLIENT_USAGE + " [adjustment]", .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, .exec = cmd_refresh_client_exec @@ -193,6 +194,34 @@ cmd_refresh_client_clipboard(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_NORMAL); } +static void +cmd_refresh_report(struct tty *tty, const char *value) +{ + struct window_pane *wp; + u_int pane; + size_t size = 0; + char *copy, *split; + + if (*value != '%') + return; + copy = xstrdup(value); + if ((split = strchr(copy, ':')) == NULL) + goto out; + *split++ = '\0'; + + if (sscanf(copy, "%%%u", &pane) != 1) + goto out; + wp = window_pane_find_by_id(pane); + if (wp == NULL) + goto out; + + tty_keys_colours(tty, split, strlen(split), &size, &wp->control_fg, + &wp->control_bg); + +out: + free(copy); +} + static enum cmd_retval cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) { @@ -262,6 +291,8 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) server_client_set_flags(tc, args_get(args, 'F')); if (args_has(args, 'f')) server_client_set_flags(tc, args_get(args, 'f')); + if (args_has(args, 'r')) + cmd_refresh_report(tty, args_get(args, 'r')); if (args_has(args, 'A')) { if (~tc->flags & CLIENT_CONTROL) diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index faf9dacfe..53a4e34f6 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.130 2023/07/13 06:03:48 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.131 2024/06/24 08:11:46 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -88,7 +88,7 @@ grid_need_extended_cell(const struct grid_cell_entry *gce, return (1); if ((gc->fg & COLOUR_FLAG_RGB) || (gc->bg & COLOUR_FLAG_RGB)) return (1); - if (gc->us != 0) /* only supports 256 or RGB */ + if (gc->us != 8) /* only supports 256 or RGB */ return (1); if (gc->link != 0) return (1); diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 6d67917f4..7ee811379 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.224 2024/04/10 07:36:25 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.225 2024/06/24 08:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2652,6 +2652,44 @@ input_get_bg_client(struct window_pane *wp) return (-1); } +/* + * If any control mode client exists that has provided a bg color, return it. + * Otherwise, return -1. + */ +static int +input_get_bg_control_client(struct window_pane *wp) +{ + struct client *c; + + if (wp->control_bg == -1) + return (-1); + + TAILQ_FOREACH(c, &clients, entry) { + if (c->flags & CLIENT_CONTROL) + return (wp->control_bg); + } + return (-1); +} + +/* + * If any control mode client exists that has provided a fg color, return it. + * Otherwise, return -1. + */ +static int +input_get_fg_control_client(struct window_pane *wp) +{ + struct client *c; + + if (wp->control_fg == -1) + return (-1); + + TAILQ_FOREACH(c, &clients, entry) { + if (c->flags & CLIENT_CONTROL) + return (wp->control_fg); + } + return (-1); +} + /* Handle the OSC 10 sequence for setting and querying foreground colour. */ static void input_osc_10(struct input_ctx *ictx, const char *p) @@ -2663,11 +2701,14 @@ input_osc_10(struct input_ctx *ictx, const char *p) if (strcmp(p, "?") == 0) { if (wp == NULL) return; - tty_default_colours(&defaults, wp); - if (COLOUR_DEFAULT(defaults.fg)) - c = input_get_fg_client(wp); - else - c = defaults.fg; + c = input_get_fg_control_client(wp); + if (c == -1) { + tty_default_colours(&defaults, wp); + if (COLOUR_DEFAULT(defaults.fg)) + c = input_get_fg_client(wp); + else + c = defaults.fg; + } input_osc_colour_reply(ictx, 10, c); return; } @@ -2711,11 +2752,14 @@ input_osc_11(struct input_ctx *ictx, const char *p) if (strcmp(p, "?") == 0) { if (wp == NULL) return; - tty_default_colours(&defaults, wp); - if (COLOUR_DEFAULT(defaults.bg)) - c = input_get_bg_client(wp); - else - c = defaults.bg; + c = input_get_bg_control_client(wp); + if (c == -1) { + tty_default_colours(&defaults, wp); + if (COLOUR_DEFAULT(defaults.bg)) + c = input_get_bg_client(wp); + else + c = defaults.bg; + } input_osc_colour_reply(ictx, 11, c); return; } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 2185dc7cf..351208a70 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.945 2024/05/24 12:39:06 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.946 2024/06/24 08:30:50 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 24 2024 $ +.Dd $Mdocdate: June 24 2024 $ .Dt TMUX 1 .Os .Sh NAME @@ -1357,6 +1357,7 @@ specified multiple times. .Op Fl B Ar name:what:format .Op Fl C Ar size .Op Fl f Ar flags +.Op Fl r Ar pane:report .Op Fl l Op Ar target-pane .Op Fl t Ar target-client .Op Ar adjustment @@ -1467,6 +1468,12 @@ for all windows in the attached session. .Fl f sets a comma-separated list of client flags, see .Ic attach-session . +.Fl r +allows a control mode client to provide information about a pane via a report +(such as the response to OSC 10). +The argument is a pane ID (with a leading +.Ql % ) , +a colon, then a report escape sequence. .Pp .Fl l requests the clipboard from the client using the diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 0a9a557ff..fa84e9f6b 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1217 2024/05/19 03:27:58 jsg Exp $ */ +/* $OpenBSD: tmux.h,v 1.1218 2024/06/24 08:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1100,6 +1100,9 @@ struct window_pane { int border_gc_set; struct grid_cell border_gc; + int control_bg; + int control_fg; + TAILQ_ENTRY(window_pane) entry; /* link in list of all panes */ TAILQ_ENTRY(window_pane) sentry; /* link in list of last visited */ RB_ENTRY(window_pane) tree_entry; @@ -2407,6 +2410,8 @@ const struct utf8_data *tty_acs_rounded_borders(int); void tty_keys_build(struct tty *); void tty_keys_free(struct tty *); int tty_keys_next(struct tty *); +int tty_keys_colours(struct tty *, const char *, size_t, size_t *, + int *, int *); /* arguments.c */ void args_set(struct args *, u_char, struct args_value *, int); diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index 9bb184066..5027876bb 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.173 2024/03/21 11:47:55 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.174 2024/06/24 08:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -59,7 +59,6 @@ static int tty_keys_device_attributes2(struct tty *, const char *, size_t, size_t *); static int tty_keys_extended_device_attributes(struct tty *, const char *, size_t, size_t *); -static int tty_keys_colours(struct tty *, const char *, size_t, size_t *); /* A key tree entry. */ struct tty_key { @@ -721,7 +720,7 @@ tty_keys_next(struct tty *tty) } /* Is this a colours response? */ - switch (tty_keys_colours(tty, buf, len, &size)) { + switch (tty_keys_colours(tty, buf, len, &size, &tty->fg, &tty->bg)) { case 0: /* yes */ key = KEYC_UNKNOWN; goto complete_key; @@ -1490,8 +1489,9 @@ tty_keys_extended_device_attributes(struct tty *tty, const char *buf, * Handle foreground or background input. Returns 0 for success, -1 for * failure, 1 for partial. */ -static int -tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size) +int +tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size, + int *fg, int *bg) { struct client *c = tty->client; u_int i; @@ -1542,11 +1542,17 @@ tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size) n = colour_parseX11(tmp); if (n != -1 && buf[3] == '0') { - log_debug("%s: foreground is %s", c->name, colour_tostring(n)); - tty->fg = n; + if (c != NULL) + log_debug("%s fg is %s", c->name, colour_tostring(n)); + else + log_debug("fg is %s", colour_tostring(n)); + *fg = n; } else if (n != -1) { - log_debug("%s: background is %s", c->name, colour_tostring(n)); - tty->bg = n; + if (c != NULL) + log_debug("%s bg is %s", c->name, colour_tostring(n)); + else + log_debug("bg is %s", colour_tostring(n)); + *bg = n; } return (0); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index e9a9a1ef2..5aebeedaa 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.290 2024/04/10 07:15:21 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.291 2024/06/24 08:30:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -937,6 +937,9 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) wp->pipe_fd = -1; + wp->control_bg = -1; + wp->control_fg = -1; + colour_palette_init(&wp->palette); colour_palette_from_option(&wp->palette, wp->options);