sync with OpenBSD -current

This commit is contained in:
purplerain 2024-07-11 15:49:23 +00:00
parent a8049e67d3
commit ae019f102d
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
77 changed files with 4413 additions and 6362 deletions

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.4 2023/06/22 19:23:27 tb Exp $
# $OpenBSD: Makefile,v 1.5 2024/07/10 13:11:22 tb Exp $
TESTS = \
symbols
@ -22,7 +22,7 @@ LDADD= -lcrypto
DPADD= ${LIBCRYPTO}
LDFLAGS+= -lcrypto
LDFLAGS+= -Wl,--no-allow-shlib-undefined
CFLAGS+= -Wno-deprecated-declarations
CFLAGS+= -Wno-deprecated-declarations -DUSE_LIBRESSL_NAMESPACE
CLEANFILES+= include_headers.c symbols.c symbols.c.tmp

View file

@ -1,4 +1,4 @@
# $OpenBSD: symbols.awk,v 1.11 2024/04/15 16:49:13 tb Exp $
# $OpenBSD: symbols.awk,v 1.12 2024/07/10 13:11:22 tb Exp $
# Copyright (c) 2018,2020 Theo Buehler <tb@openbsd.org>
#
@ -32,6 +32,8 @@ BEGIN {
# Undefine aliases, so we don't accidentally leave them in Symbols.list.
printf("#ifdef %s\n#undef %s\n#endif\n", $0, $0)
printf("static typeof(%s) *_libre_%s;\n", $0, $0);
}
END {
@ -41,12 +43,16 @@ END {
printf("\tstruct {\n")
printf("\t\tconst char *const name;\n")
printf("\t\tconst void *addr;\n")
printf("\t\tconst void *libre_addr;\n")
printf("\t} symbols[] = {\n")
for (symbol in symbols) {
printf("\t\t{\n")
printf("\t\t\t.name = \"%s\",\n", symbol)
printf("\t\t\t.addr = &%s,\n", symbol)
printf("#if defined(USE_LIBRESSL_NAMESPACE)\n")
printf("\t\t\t.libre_addr = &_libre_%s,\n", symbol)
printf("#endif\n")
printf("\t\t},\n")
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ssl_set_alpn_protos.c,v 1.3 2024/06/28 14:50:37 tb Exp $ */
/* $OpenBSD: ssl_set_alpn_protos.c,v 1.4 2024/07/11 13:51:47 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
*
@ -202,162 +202,138 @@ test_ssl_set_alpn_protos_edge_cases(void)
}
static const struct select_next_proto_test {
const unsigned char *server_list;
size_t server_list_len;
const unsigned char *client_list;
size_t client_list_len;
const unsigned char *peer_list;
size_t peer_list_len;
const unsigned char *supported_list;
size_t supported_list_len;
int want_ret;
const unsigned char *want_out;
unsigned char want_out_len; /* yes, unsigned char */
} select_next_proto_tests[] = {
{
.server_list = "\x01" "a" "\x01" "b" "\x01" "c",
.server_list_len = 6,
.client_list = "\x01" "a",
.client_list_len = 2,
.peer_list = "\x01" "a" "\x01" "b" "\x01" "c",
.peer_list_len = 6,
.supported_list = "\x01" "a",
.supported_list_len = 2,
.want_ret = OPENSSL_NPN_NEGOTIATED,
.want_out = "a",
.want_out_len = 1,
},
{
.server_list = "\x01" "a" "\x01" "b" "\x01" "c",
.server_list_len = 6,
.client_list = "\x02" "aa" "\x01" "b" "\x01" "c",
.client_list_len = 7,
.peer_list = "\x01" "a" "\x01" "b" "\x01" "c",
.peer_list_len = 6,
.supported_list = "\x02" "aa" "\x01" "b" "\x01" "c",
.supported_list_len = 7,
.want_ret = OPENSSL_NPN_NEGOTIATED,
.want_out = "b",
.want_out_len = 1,
},
{
/* Use server preference. */
.server_list = "\x01" "a" "\x01" "b" "\x01" "c",
.server_list_len = 6,
.client_list = "\x01" "c" "\x01" "b" "\x01" "a",
.client_list_len = 6,
/* Use peer preference. */
.peer_list = "\x01" "a" "\x01" "b" "\x01" "c",
.peer_list_len = 6,
.supported_list = "\x01" "c" "\x01" "b" "\x01" "a",
.supported_list_len = 6,
.want_ret = OPENSSL_NPN_NEGOTIATED,
.want_out = "a",
.want_out_len = 1,
},
{
/* Again server preference wins. */
.server_list = "\x01" "a" "\x03" "bbb" "\x02" "cc",
.server_list_len = 9,
.client_list = "\x01" "z" "\x02" "cc" "\x03" "bbb",
.client_list_len = 9,
/* Again peer preference wins. */
.peer_list = "\x01" "a" "\x03" "bbb" "\x02" "cc",
.peer_list_len = 9,
.supported_list = "\x01" "z" "\x02" "cc" "\x03" "bbb",
.supported_list_len = 9,
.want_ret = OPENSSL_NPN_NEGOTIATED,
.want_out = "bbb",
.want_out_len = 3,
},
{
/* No overlap fails with first client protocol. */
.server_list = "\x01" "a" "\x01" "b" "\x01" "c",
.server_list_len = 6,
.client_list = "\x01" "z" "\x01" "y",
.client_list_len = 4,
/* No overlap fails with first supported protocol. */
.peer_list = "\x01" "a" "\x01" "b" "\x01" "c",
.peer_list_len = 6,
.supported_list = "\x01" "z" "\x01" "y",
.supported_list_len = 4,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
.want_out = "z",
.want_out_len = 1,
},
{
/*
* No server protocols is a misconfiguration, but should fail
* cleanly.
*/
.server_list = "",
.server_list_len = 0,
.client_list = "\x01" "a" "\x01" "b" "\x01" "c",
.client_list_len = 6,
/* No peer protocols fails cleanly. */
.peer_list = "",
.peer_list_len = 0,
.supported_list = "\x01" "a" "\x01" "b" "\x01" "c",
.supported_list_len = 6,
.want_out = "a",
.want_out_len = 1,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* NULL server protocols is a programming error that fails
* cleanly.
*/
.server_list = NULL,
.server_list_len = 0,
.client_list = "\x01" "a" "\x01" "b" "\x01" "c",
.client_list_len = 6,
/* NULL peer protocols fails cleanly. */
.peer_list = NULL,
.peer_list_len = 0,
.supported_list = "\x01" "a" "\x01" "b" "\x01" "c",
.supported_list_len = 6,
.want_out = "a",
.want_out_len = 1,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* Malformed server protocols is a misconfiguration, but it
* should fail cleanly.
*/
.server_list = "\x00",
.server_list_len = 1,
.client_list = "\x01" "a" "\x01" "b" "\x01" "c",
.client_list_len = 6,
/* Malformed peer protocols fails cleanly. */
.peer_list = "\x00",
.peer_list_len = 1,
.supported_list = "\x01" "a" "\x01" "b" "\x01" "c",
.supported_list_len = 6,
.want_out = "a",
.want_out_len = 1,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* Malformed server protocols is a misconfiguration, but it
* should fail cleanly.
*/
.server_list = "\x01" "a" "\x03" "bb",
.server_list_len = 5,
.client_list = "\x01" "a" "\x01" "b" "\x01" "c",
.client_list_len = 6,
/* Malformed peer protocols fails cleanly. */
.peer_list = "\x01" "a" "\x03" "bb",
.peer_list_len = 5,
.supported_list = "\x01" "a" "\x01" "b" "\x01" "c",
.supported_list_len = 6,
.want_out = "a",
.want_out_len = 1,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* Empty client protocols is not reachable from the ALPN
* callback. It fails cleanly with NULL protocol and 0 length.
*/
.server_list = "\x01" "a",
.server_list_len = 2,
.client_list = "",
.client_list_len = 0,
/* Empty supported list fails cleanly. */
.peer_list = "\x01" "a",
.peer_list_len = 2,
.supported_list = "",
.supported_list_len = 0,
.want_out = NULL,
.want_out_len = 0,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* NULL client protocols is not reachable from the ALPN
* callback. It fails cleanly with NULL protocol and 0 length.
*/
.server_list = "\x01" "a",
.server_list_len = 2,
.client_list = NULL,
.client_list_len = 0,
/* NULL supported list fails cleanly. */
.peer_list = "\x01" "a",
.peer_list_len = 2,
.supported_list = NULL,
.supported_list_len = 0,
.want_out = NULL,
.want_out_len = 0,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* Malformed client list fails cleanly with NULL protocol and
* 0 length.
*/
.server_list = "\x01" "a",
.server_list_len = 2,
.client_list = "\x01" "a" "\x02" "bb" "\x03" "cc" "\x04" "ddd",
.client_list_len = 12,
/* Malformed supported list fails cleanly. */
.peer_list = "\x01" "a",
.peer_list_len = 2,
.supported_list = "\x01" "a" "\x02" "bb" "\x03" "cc" "\x04" "ddd",
.supported_list_len = 12,
.want_out = NULL,
.want_out_len = 0,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/*
* Malformed client list fails cleanly with NULL protocol and
* 0 length.
*/
.server_list = "\x01" "a",
.server_list_len = 2,
.client_list = "\x01" "a" "\x02" "bb" "\x00" "\x03" "ddd",
.client_list_len = 10,
/* Malformed client list fails cleanly. */
.peer_list = "\x01" "a",
.peer_list_len = 2,
.supported_list = "\x01" "a" "\x02" "bb" "\x00" "\x03" "ddd",
.supported_list_len = 10,
.want_out = NULL,
.want_out_len = 0,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
@ -368,58 +344,58 @@ static const struct select_next_proto_test {
*/
{
.server_list = "\x08" "http/1.1" "\x06" "spdy/1",
.server_list_len = 16,
.client_list = "\x08" "http/2.0" "\x08" "http/1.1",
.client_list_len = 18,
.peer_list = "\x08" "http/1.1" "\x06" "spdy/1",
.peer_list_len = 16,
.supported_list = "\x08" "http/2.0" "\x08" "http/1.1",
.supported_list_len = 18,
.want_out = "http/1.1",
.want_out_len = 8,
.want_ret = OPENSSL_NPN_NEGOTIATED,
},
{
.server_list = "\x08" "http/2.0" "\x06" "spdy/1",
.server_list_len = 16,
.client_list = "\x08" "http/1.0" "\x08" "http/1.1",
.client_list_len = 18,
.peer_list = "\x08" "http/2.0" "\x06" "spdy/1",
.peer_list_len = 16,
.supported_list = "\x08" "http/1.0" "\x08" "http/1.1",
.supported_list_len = 18,
.want_out = "http/1.0",
.want_out_len = 8,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
.server_list = "\x08" "http/1.1" "\x08" "http/1.0",
.server_list_len = 18,
.client_list = "\x08" "http/1.0" "\x08" "http/1.1",
.client_list_len = 18,
.peer_list = "\x08" "http/1.1" "\x08" "http/1.0",
.peer_list_len = 18,
.supported_list = "\x08" "http/1.0" "\x08" "http/1.1",
.supported_list_len = 18,
.want_out = "http/1.1",
.want_out_len = 8,
.want_ret = OPENSSL_NPN_NEGOTIATED,
},
{
/* Server malformed. */
.server_list = "\x08" "http/1.1" "\x07" "http/1.0",
.server_list_len = 18,
.client_list = "\x08" "http/1.0" "\x08" "http/1.1",
.client_list_len = 18,
/* Peer list malformed. */
.peer_list = "\x08" "http/1.1" "\x07" "http/1.0",
.peer_list_len = 18,
.supported_list = "\x08" "http/1.0" "\x08" "http/1.1",
.supported_list_len = 18,
.want_out = "http/1.0",
.want_out_len = 8,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/* Server malformed. */
.server_list = "\x07" "http/1.1" "\x08" "http/1.0",
.server_list_len = 18,
.client_list = "\x08" "http/1.0" "\x08" "http/1.1",
.client_list_len = 18,
/* Peer list malformed. */
.peer_list = "\x07" "http/1.1" "\x08" "http/1.0",
.peer_list_len = 18,
.supported_list = "\x08" "http/1.0" "\x08" "http/1.1",
.supported_list_len = 18,
.want_out = "http/1.0",
.want_out_len = 8,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
},
{
/* Client has trailing bytes. */
.server_list = "\x08" "http/1.1" "\x08" "http/1.0",
.server_list_len = 18,
.client_list = "\x08" "http/1.0" "\x07" "http/1.1",
.client_list_len = 18,
/* Supported list has trailing bytes. */
.peer_list = "\x08" "http/1.1" "\x08" "http/1.0",
.peer_list_len = 18,
.supported_list = "\x08" "http/1.0" "\x07" "http/1.1",
.supported_list_len = 18,
.want_out = NULL,
.want_out_len = 0,
.want_ret = OPENSSL_NPN_NO_OVERLAP,
@ -437,8 +413,8 @@ select_next_proto_testcase(const struct select_next_proto_test *test)
int ret;
int failed = 0;
ret = SSL_select_next_proto(&out, &out_len, test->server_list,
test->server_list_len, test->client_list, test->client_list_len);
ret = SSL_select_next_proto(&out, &out_len, test->peer_list,
test->peer_list_len, test->supported_list, test->supported_list_len);
if (ret != test->want_ret || out_len != test->want_out_len ||
(out == NULL && test->want_out != NULL) ||
@ -452,9 +428,9 @@ select_next_proto_testcase(const struct select_next_proto_test *test)
fprintf(stderr, "\nwant:\n");
hexdump(test->want_out, test->want_out_len);
fprintf(stderr, "\nserver:\n");
hexdump(test->server_list, test->server_list_len);
hexdump(test->peer_list, test->peer_list_len);
fprintf(stderr, "\nclient:\n");
hexdump(test->client_list, test->client_list_len);
hexdump(test->supported_list, test->supported_list_len);
fprintf(stderr, "\n");
failed = 1;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: t8.2,v 1.1 2003/07/17 21:04:04 otto Exp $ */
/* $OpenBSD: t8.2,v 1.2 2024/07/10 09:20:33 krw Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@ -76,7 +76,7 @@ struct kmemusage *kmemusage;
char *kmembase, *kmemlimit;
char buckstring[16 * sizeof("123456,")];
int buckstring_init = 0;
#if defined(KMEMSTATS) || defined(DIAGNOSTIC) || defined(FFS_SOFTUPDATES)
#if defined(KMEMSTATS) || defined(DIAGNOSTIC)
char *memname[] = INITKMEMNAMES;
char *memall = NULL;
extern struct lock sysctl_kmemlock;
@ -561,7 +561,7 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p)
return (EOPNOTSUPP);
#endif
case KERN_MALLOC_KMEMNAMES:
#if defined(KMEMSTATS) || defined(DIAGNOSTIC) || defined(FFS_SOFTUPDATES)
#if defined(KMEMSTATS) || defined(DIAGNOSTIC)
if (memall == NULL) {
int totlen;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: t9.2,v 1.2 2013/12/01 16:40:56 krw Exp $ */
/* $OpenBSD: t9.2,v 1.4 2024/07/10 09:24:03 krw Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@ -591,10 +591,6 @@ sys_statfs(p, v, retval)
if ((error = VFS_STATFS(mp, sp, p)) != 0)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
#if notyet
if (mp->mnt_flag & MNT_SOFTDEP)
sp->f_eflags = STATFS_SOFTUPD;
#endif
/* Don't let non-root see filesystem id (for NFS security) */
if (suser(p->p_ucred, &p->p_acflag)) {
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
@ -633,10 +629,6 @@ sys_fstatfs(p, v, retval)
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
#if notyet
if (mp->mnt_flag & MNT_SOFTDEP)
sp->f_eflags = STATFS_SOFTUPD;
#endif
/* Don't let non-root see filesystem id (for NFS security) */
if (suser(p->p_ucred, &p->p_acflag)) {
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
@ -689,10 +681,6 @@ sys_getfsstat(p, v, retval)
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
#if notyet
if (mp->mnt_flag & MNT_SOFTDEP)
sp->f_eflags = STATFS_SOFTUPD;
#endif
if (suser(p->p_ucred, &p->p_acflag)) {
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
@ -2292,10 +2280,6 @@ sys_fsync(p, v, retval)
vp = (struct vnode *)fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
#ifdef FFS_SOFTUPDATES
if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP))
error = softdep_fsync(vp);
#endif
VOP_UNLOCK(vp, 0, p);
FRELE(fp);