sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-08-30 17:35:22 +00:00
parent 708141b7a2
commit 085b88af82
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
18 changed files with 307 additions and 35 deletions

View File

@ -1918,6 +1918,7 @@
./usr/share/man/man3/EVP_AEAD_CTX_init.3
./usr/share/man/man3/EVP_BytesToKey.3
./usr/share/man/man3/EVP_CIPHER_CTX_get_cipher_data.3
./usr/share/man/man3/EVP_CIPHER_do_all.3
./usr/share/man/man3/EVP_CIPHER_meth_new.3
./usr/share/man/man3/EVP_DigestInit.3
./usr/share/man/man3/EVP_DigestSignInit.3

View File

@ -1,4 +1,4 @@
/* $OpenBSD: a_time_tm.c,v 1.29 2023/07/07 19:37:52 beck Exp $ */
/* $OpenBSD: a_time_tm.c,v 1.30 2023/08/30 10:13:12 job Exp $ */
/*
* Copyright (c) 2015 Bob Beck <beck@openbsd.org>
*
@ -610,6 +610,8 @@ ASN1_TIME_normalize(ASN1_TIME *t)
{
struct tm tm;
if (t == NULL)
return 0;
if (!ASN1_TIME_to_tm(t, &tm))
return 0;
return tm_to_rfc5280_time(&tm, t) != NULL;

View File

@ -0,0 +1,134 @@
.\" $OpenBSD: EVP_CIPHER_do_all.3,v 1.1 2023/08/30 00:58:57 tb Exp $
.\"
.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 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: August 30 2023 $
.Dt EVP_CIPHER_DO_ALL 3
.Os
.Sh NAME
.Nm EVP_CIPHER_do_all ,
.Nm EVP_CIPHER_do_all_sorted ,
.Nm EVP_MD_do_all ,
.Nm EVP_MD_do_all_sorted
.Nd iterate over lookup tables for ciphers and digests
.Sh SYNOPSIS
.In openssl/evp.h
.Ft void
.Fo EVP_CIPHER_do_all
.Fa "void (*fn)(const EVP_CIPHER *cipher, const char *from,\
const char *to, void *arg)"
.Fa "void *arg"
.Fc
.Ft void
.Fo EVP_CIPHER_do_all_sorted
.Fa "void (*fn)(const EVP_CIPHER *cipher, const char *from,\
const char *to, void *arg)"
.Fa "void *arg"
.Fc
.Ft void
.Fo EVP_MD_do_all
.Fa "void (*fn)(const EVP_MD *md, const char *from,\
const char *to, void *arg)"
.Fa "void *arg"
.Fc
.Ft void
.Fo EVP_MD_do_all_sorted
.Fa "void (*fn)(const EVP_MD *md, const char *from,\
const char *to, void *arg)"
.Fa "void *arg"
.Fc
.Sh DESCRIPTION
.Fn EVP_CIPHER_do_all
calls
.Fa fn
on every entry of the global table of cipher names and aliases.
For a cipher name entry,
.Fa fn
is called with a non-NULL
.Fa cipher ,
its non-NULL cipher name
.Fa from ,
a NULL
.Fa to ,
and the
.Fa arg
pointer.
For an alias entry,
.Fa fn
is called with a NULL
.Fa cipher ,
its alias
.Fa from ,
the cipher name that alias points
.Fa to ,
and the
.Fa arg
pointer.
.Pp
.Fn EVP_CIPHER_do_all_sorted
is similar, except that it processes the cipher names and aliases
in lexicographic order of their
.Fa from
names as determined by
.Xr strcmp 3 .
.Pp
.Fn EVP_MD_do_all
calls
.Fa fn
on every entry of the global table of digest names and aliases.
For a digest name entry,
.Fa fn
is called with a non-NULL
.Fa md ,
its non-NULL digest name
.Fa from ,
a NULL
.Fa to ,
and the
.Fa arg
pointer.
For an alias entry,
.Fa fn
is called with a NULL
.Fa md ,
its alias
.Fa from ,
the digest name that alias points
.Fa to ,
and the
.Fa arg
pointer.
.Pp
.Fn EVP_MD_do_all_sorted
is similar, except that it processes the digest names and aliases
in lexicographic order of their
.Fa from
names as determined by
.Xr strcmp 3 .
.Sh SEE ALSO
.Xr evp 3 ,
.Xr EVP_add_cipher 3 ,
.Xr OBJ_NAME_do_all 3
.Sh HISTORY
These functions first appeared in OpenSSL 1.0.0 and have been available since
.Ox 4.9 .
.Sh BUGS
.Fn EVP_CIPHER_do_all_sorted
and
.Fn EVP_MD_do_all_sorted
are wrappers of
.Xr OBJ_NAME_do_all_sorted 3 .
In particular, if memory allocation fails, they do nothing at all
without telling the caller about the problem.

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.264 2023/08/27 15:33:08 schwarze Exp $
# $OpenBSD: Makefile,v 1.265 2023/08/30 00:58:57 tb Exp $
.include <bsd.own.mk>
@ -165,6 +165,7 @@ MAN= \
EVP_AEAD_CTX_init.3 \
EVP_BytesToKey.3 \
EVP_CIPHER_CTX_get_cipher_data.3 \
EVP_CIPHER_do_all.3 \
EVP_CIPHER_meth_new.3 \
EVP_DigestInit.3 \
EVP_DigestSignInit.3 \

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: evp.3,v 1.20 2023/08/27 15:33:08 schwarze Exp $
.\" $OpenBSD: evp.3,v 1.21 2023/08/30 00:58:57 tb Exp $
.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100
.\"
.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@ -51,7 +51,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: August 27 2023 $
.Dd $Mdocdate: August 30 2023 $
.Dt EVP 3
.Os
.Sh NAME
@ -200,6 +200,7 @@ operations are more efficient using the high-level interfaces.
.Xr EVP_camellia_128_cbc 3 ,
.Xr EVP_chacha20 3 ,
.Xr EVP_CIPHER_CTX_get_cipher_data 3 ,
.Xr EVP_CIPHER_do_all 3 ,
.Xr EVP_CIPHER_meth_new 3 ,
.Xr EVP_des_cbc 3 ,
.Xr EVP_DigestInit 3 ,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x509_alt.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */
/* $OpenBSD: x509_alt.c,v 1.16 2023/08/30 00:49:32 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
*/
@ -354,10 +354,11 @@ err:
static int
copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
{
GENERAL_NAMES *ialt;
GENERAL_NAME *gen;
GENERAL_NAMES *ialt = NULL;
GENERAL_NAME *gen = NULL;
X509_EXTENSION *ext;
int i;
int ret = 0;
if (ctx && (ctx->flags == CTX_TEST))
return 1;
@ -375,19 +376,24 @@ copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
}
for (i = 0; i < sk_GENERAL_NAME_num(ialt); i++) {
gen = sk_GENERAL_NAME_value(ialt, i);
GENERAL_NAME *val = sk_GENERAL_NAME_value(ialt, i);
if ((gen = GENERAL_NAME_dup(val)) == NULL)
goto err;
if (!sk_GENERAL_NAME_push(gens, gen)) {
X509V3error(ERR_R_MALLOC_FAILURE);
goto err;
}
gen = NULL;
}
sk_GENERAL_NAME_free(ialt);
return 1;
ret = 1;
err:
return 0;
err:
sk_GENERAL_NAME_pop_free(ialt, GENERAL_NAME_free);
GENERAL_NAME_free(gen);
return ret;
}
static GENERAL_NAMES *

View File

@ -1,4 +1,4 @@
/* $OpenBSD: asn1time.c,v 1.16 2022/09/05 21:06:31 tb Exp $ */
/* $OpenBSD: asn1time.c,v 1.17 2023/08/30 10:13:12 job Exp $ */
/*
* Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
*
@ -528,5 +528,8 @@ main(int argc, char **argv)
failed |= asn1_time_test(i, att, V_ASN1_GENERALIZEDTIME);
}
/* Check for a leak in ASN1_TIME_normalize(). */
failed |= ASN1_TIME_normalize(NULL) != 0;
return (failed);
}

View File

@ -1,13 +1,15 @@
# $OpenBSD: Makefile,v 1.6 2023/08/21 18:56:06 kn Exp $
# $OpenBSD: Makefile,v 1.7 2023/08/30 16:45:57 kn Exp $
BIOCTL ?= /sbin/bioctl
CHUNKFILE = disk.img
CHUNKDEVFILE = chunk.txt
VOLDEVFILE = vol.txt
ROUNDSFILE = rounds.txt
OLDPW = oldsecret
NEWPW = securenew
NROUNDS ?= 17
REGRESS_SETUP_ONCE = create-chunk
@ -19,7 +21,8 @@ create-chunk:
SUCCESS_TESTS = scripted-create-volume \
scripted-recreate-volume \
scripted-change-passphrase
scripted-change-passphrase \
verify-increased-rounds
REGRESS_TARGETS = ${SUCCESS_TESTS}
REGRESS_ROOT_TARGETS = ${SUCCESS_TESTS}
@ -30,12 +33,19 @@ scripted-create-volume:
scripted-recreate-volume: detach-volume
printf '%s\n' '${OLDPW}' | \
${SUDO} ${BIOCTL} -s -Cforce -r17 -cC -l"$$(<${CHUNKDEVFILE})a" -- softraid0 | \
${SUDO} ${BIOCTL} -s -Cforce -r${NROUNDS} -cC -l"$$(<${CHUNKDEVFILE})a" -- softraid0 | \
grep -o 'sd[0-9]*$$' -- 1>${VOLDEVFILE}
scripted-change-passphrase:
printf '%s\n%s\n' '${OLDPW}' '${NEWPW}' | \
${SUDO} ${BIOCTL} -s -P -- "$$(<${VOLDEVFILE})"
${SUDO} ${BIOCTL} -s -P -v -- "$$(<${VOLDEVFILE})" | \
tee -- ${ROUNDSFILE}
verify-increased-rounds:
awk -safe -vOLD=${NROUNDS} -- '\
NR == 1 { old = $$7 }; \
NR == 2 { new = $$7 }; \
END { exit !(OLD == old && old <= new) }' ${ROUNDSFILE}
FAILURE_TESTS = reuse-active-chunk \

View File

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2045 2023/08/09 21:27:47 kmos Exp $
$OpenBSD: pcidevs,v 1.2046 2023/08/30 07:11:48 kevlo Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/*
@ -8236,6 +8236,7 @@ product PHILIPS SAA7231 0x7231 SAA7231 TV
/* Phison products */
product PHISON PS5000 0x5000 PS5000
product PHISON PS5021 0x5021 PS5021
/* Picopower */
product PICOPOWER PT80C826 0x0000 PT80C826

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2045 2023/08/09 21:27:47 kmos Exp
* OpenBSD: pcidevs,v 1.2046 2023/08/30 07:11:48 kevlo Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -8241,6 +8241,7 @@
/* Phison products */
#define PCI_PRODUCT_PHISON_PS5000 0x5000 /* PS5000 */
#define PCI_PRODUCT_PHISON_PS5021 0x5021 /* PS5021 */
/* Picopower */
#define PCI_PRODUCT_PICOPOWER_PT80C826 0x0000 /* PT80C826 */

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2045 2023/08/09 21:27:47 kmos Exp
* OpenBSD: pcidevs,v 1.2046 2023/08/30 07:11:48 kevlo Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -29663,6 +29663,10 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5000,
"PS5000",
},
{
PCI_VENDOR_PHISON, PCI_PRODUCT_PHISON_PS5021,
"PS5021",
},
{
PCI_VENDOR_PICOPOWER, PCI_PRODUCT_PICOPOWER_PT80C826,
"PT80C826",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_umb.c,v 1.52 2023/08/26 11:33:46 dlg Exp $ */
/* $OpenBSD: if_umb.c,v 1.54 2023/08/29 23:28:38 dlg Exp $ */
/*
* Copyright (c) 2016 genua mbH
@ -23,13 +23,16 @@
* Compliance testing guide
* https://www.usb.org/sites/default/files/MBIM-Compliance-1.0.pdf
*/
#include "bpfilter.h"
#include "kstat.h"
#include <sys/param.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/syslog.h>
#include <sys/kstat.h>
#if NBPFILTER > 0
#include <net/bpf.h>
@ -203,6 +206,17 @@ void umb_decode_qmi(struct umb_softc *, uint8_t *, int);
void umb_intr(struct usbd_xfer *, void *, usbd_status);
#if NKSTAT > 0
void umb_kstat_attach(struct umb_softc *);
void umb_kstat_detach(struct umb_softc *);
struct umb_kstat_signal {
struct kstat_kv rssi;
struct kstat_kv error_rate;
struct kstat_kv reports;
};
#endif
int umb_xfer_tout = USBD_DEFAULT_TIMEOUT;
uint8_t umb_uuid_basic_connect[] = MBIM_UUID_BASIC_CONNECT;
@ -618,6 +632,11 @@ umb_attach(struct device *parent, struct device *self, void *aux)
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(uint32_t));
#endif
#if NKSTAT > 0
umb_kstat_attach(sc);
#endif
/*
* Open the device now so that we are able to query device information.
* XXX maybe close when done?
@ -645,6 +664,10 @@ umb_detach(struct device *self, int flags)
umb_down(sc, 1);
umb_close(sc);
#if NKSTAT > 0
umb_kstat_detach(sc);
#endif
usb_rem_wait_task(sc->sc_udev, &sc->sc_get_response_task);
if (timeout_initialized(&sc->sc_statechg_timer))
timeout_del(&sc->sc_statechg_timer);
@ -1670,6 +1693,9 @@ umb_decode_signal_state(struct umb_softc *sc, void *data, int len)
struct mbim_cid_signal_state *ss = data;
struct ifnet *ifp = GET_IFP(sc);
int rssi;
#if NKSTAT > 0
struct kstat *ks;
#endif
if (len < sizeof (*ss))
return 0;
@ -1684,8 +1710,37 @@ umb_decode_signal_state(struct umb_softc *sc, void *data, int len)
}
sc->sc_info.rssi = rssi;
sc->sc_info.ber = letoh32(ss->err_rate);
if (sc->sc_info.ber == -99)
if (sc->sc_info.ber == 99)
sc->sc_info.ber = UMB_VALUE_UNKNOWN;
#if NKSTAT > 0
ks = sc->sc_kstat_signal;
if (ks != NULL) {
struct umb_kstat_signal *uks = ks->ks_data;
rw_enter_write(&sc->sc_kstat_lock);
kstat_kv_u64(&uks->reports)++;
if (sc->sc_info.rssi == UMB_VALUE_UNKNOWN)
uks->rssi.kv_type = KSTAT_KV_T_NULL;
else {
uks->rssi.kv_type = KSTAT_KV_T_INT32;
kstat_kv_s32(&uks->rssi) = sc->sc_info.rssi;
}
if (sc->sc_info.ber == UMB_VALUE_UNKNOWN)
uks->error_rate.kv_type = KSTAT_KV_T_NULL;
else {
uks->error_rate.kv_type = KSTAT_KV_T_INT32;
kstat_kv_s32(&uks->error_rate) = sc->sc_info.ber;
}
ks->ks_interval.tv_sec = letoh32(ss->ss_intvl);
getnanouptime(&ks->ks_updated);
rw_exit_write(&sc->sc_kstat_lock);
}
#endif
return 1;
}
@ -3146,3 +3201,51 @@ umb_dump(void *buf, int len)
addlog("\n");
}
#endif /* UMB_DEBUG */
#if NKSTAT > 0
void
umb_kstat_attach(struct umb_softc *sc)
{
struct kstat *ks;
struct umb_kstat_signal *uks;
rw_init(&sc->sc_kstat_lock, "umbkstat");
ks = kstat_create(DEVNAM(sc), 0, "mbim-signal", 0, KSTAT_T_KV, 0);
if (ks == NULL)
return;
uks = malloc(sizeof(*uks), M_DEVBUF, M_WAITOK|M_ZERO);
kstat_kv_init(&uks->rssi, "rssi", KSTAT_KV_T_NULL);
kstat_kv_init(&uks->error_rate, "error rate", KSTAT_KV_T_NULL);
kstat_kv_init(&uks->reports, "reports", KSTAT_KV_T_COUNTER64);
kstat_set_rlock(ks, &sc->sc_kstat_lock);
ks->ks_data = uks;
ks->ks_datalen = sizeof(*uks);
ks->ks_read = kstat_read_nop;
ks->ks_softc = sc;
sc->sc_kstat_signal = ks;
kstat_install(ks);
}
void
umb_kstat_detach(struct umb_softc *sc)
{
struct kstat *ks = sc->sc_kstat_signal;
struct umb_kstat_signal *uks;
if (ks == NULL)
return;
kstat_remove(ks);
sc->sc_kstat_signal = NULL;
uks = ks->ks_data;
free(uks, M_DEVBUF, sizeof(*uks));
kstat_destroy(ks);
}
#endif /* NKSTAT > 0 */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_umb.h,v 1.10 2021/07/04 19:22:32 sthen Exp $ */
/* $OpenBSD: if_umb.h,v 1.11 2023/08/29 23:26:40 dlg Exp $ */
/*
* Copyright (c) 2016 genua mbH
@ -388,5 +388,8 @@ struct umb_softc {
#define sc_state sc_info.state
#define sc_roaming sc_info.enable_roaming
struct umb_info sc_info;
struct rwlock sc_kstat_lock;
struct kstat *sc_kstat_signal;
};
#endif /* _KERNEL */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sched_bsd.c,v 1.84 2023/08/29 16:19:34 claudio Exp $ */
/* $OpenBSD: sched_bsd.c,v 1.85 2023/08/30 09:02:38 claudio Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@ -106,7 +106,7 @@ roundrobin(struct clockintr *cl, void *cf)
}
}
if (spc->spc_nrun)
if (spc->spc_nrun || spc->spc_schedflags & SPCF_SHOULDYIELD)
need_resched(ci);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bgpd.h,v 1.476 2023/08/16 08:26:35 claudio Exp $ */
/* $OpenBSD: bgpd.h,v 1.477 2023/08/30 08:16:28 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -691,7 +691,8 @@ enum ctl_results {
CTL_RES_NOMEM,
CTL_RES_BADPEER,
CTL_RES_BADSTATE,
CTL_RES_NOSUCHRIB
CTL_RES_NOSUCHRIB,
CTL_RES_OPNOTSUPP,
};
/* needed for session.h parse prototype */
@ -1709,7 +1710,8 @@ static const char * const ctl_res_strerror[] = {
"out of memory",
"not a cloned peer",
"peer still active, down peer first",
"no such RIB"
"no such RIB",
"operation not supported",
};
static const char * const timernames[] = {

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: BaseState.pm,v 1.3 2023/06/13 09:07:17 espie Exp $
# $OpenBSD: BaseState.pm,v 1.4 2023/08/30 12:04:09 espie Exp $
#
# Copyright (c) 2007-2022 Marc Espie <espie@openbsd.org>
#
@ -171,7 +171,7 @@ sub child_error($self, $error = $?)
}
if ($error & 127) {
return $self->f("killed by signal #1#2",
find_signal($error & 127), $extra);
$self->find_signal($error & 127), $extra);
} else {
return $self->f("exit(#1)#2", ($error >> 8), $extra);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.244 2023/06/29 14:33:35 tb Exp $ */
/* $OpenBSD: main.c,v 1.246 2023/08/30 10:02:28 job Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -136,7 +136,7 @@ get_current_time(void)
/*
* Read a queue entity from the descriptor.
* Matched by entity_buffer_req().
* Matched by entity_write_req().
* The pointer must be passed entity_free().
*/
void
@ -174,7 +174,7 @@ entity_write_req(const struct entity *ent)
}
static void
entity_write_repo(struct repo *rp)
entity_write_repo(const struct repo *rp)
{
struct ibuf *b;
enum rtype type = RTYPE_REPO;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parser.c,v 1.97 2023/06/29 10:28:25 tb Exp $ */
/* $OpenBSD: parser.c,v 1.98 2023/08/30 10:01:52 job Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -616,7 +616,7 @@ parse_load_file(struct entity *entp, unsigned char **f, size_t *flen)
}
/*
* Process an entity and responing to parent process.
* Process an entity and respond to parent process.
*/
static void
parse_entity(struct entityq *q, struct msgbuf *msgq)