From 25aa71bc5fa849cc0878e77f479d1a538f34bd21 Mon Sep 17 00:00:00 2001 From: purplerain Date: Mon, 15 Jan 2024 03:18:19 +0000 Subject: [PATCH] sync with OpenBSD -current --- lib/libcrypto/cms/cms_enc.c | 5 ++++- lib/libcrypto/cms/cms_env.c | 7 ++++--- lib/libcrypto/cms/cms_ess.c | 6 +++--- lib/libcrypto/cms/cms_pwri.c | 3 ++- libexec/ld.so/loader.c | 32 +++++++++++++++++++++++++++++++- sys/sys/sched.h | 24 ++++++++++++------------ 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/lib/libcrypto/cms/cms_enc.c b/lib/libcrypto/cms/cms_enc.c index 547f9ff74..dee643fa1 100644 --- a/lib/libcrypto/cms/cms_enc.c +++ b/lib/libcrypto/cms/cms_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_enc.c,v 1.23 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: cms_enc.c,v 1.24 2024/01/14 18:40:24 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,7 +61,10 @@ #include #include #include + #include "cms_local.h" +#include "evp_local.h" +#include "x509_local.h" /* CMS EncryptedData Utilities */ diff --git a/lib/libcrypto/cms/cms_env.c b/lib/libcrypto/cms/cms_env.c index 7bb8f613a..98979cdae 100644 --- a/lib/libcrypto/cms/cms_env.c +++ b/lib/libcrypto/cms/cms_env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_env.c,v 1.26 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: cms_env.c,v 1.27 2024/01/14 18:40:24 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -54,16 +54,17 @@ #include -#include "cryptlib.h" #include #include #include #include #include #include -#include "cms_local.h" + #include "asn1/asn1_local.h" +#include "cms_local.h" #include "evp/evp_local.h" +#include "x509_local.h" /* CMS EnvelopedData Utilities */ diff --git a/lib/libcrypto/cms/cms_ess.c b/lib/libcrypto/cms/cms_ess.c index b9a4cd8af..16b54c199 100644 --- a/lib/libcrypto/cms/cms_ess.c +++ b/lib/libcrypto/cms/cms_ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_ess.c,v 1.23 2023/07/08 08:26:26 beck Exp $ */ +/* $OpenBSD: cms_ess.c,v 1.24 2024/01/14 18:40:24 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -54,15 +54,15 @@ #include -#include "cryptlib.h" #include #include #include #include #include #include -#include "cms_local.h" +#include "cms_local.h" +#include "x509_local.h" CMS_ReceiptRequest * d2i_CMS_ReceiptRequest(CMS_ReceiptRequest **a, const unsigned char **in, long len) diff --git a/lib/libcrypto/cms/cms_pwri.c b/lib/libcrypto/cms/cms_pwri.c index a5581a58b..b6fe5df96 100644 --- a/lib/libcrypto/cms/cms_pwri.c +++ b/lib/libcrypto/cms/cms_pwri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_pwri.c,v 1.30 2023/12/20 18:38:19 tb Exp $ */ +/* $OpenBSD: cms_pwri.c,v 1.31 2024/01/14 18:40:24 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -66,6 +66,7 @@ #include "cms_local.h" #include "evp_local.h" +#include "x509_local.h" int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 9f15530e2..de53dc85d 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.218 2023/12/19 16:13:22 deraadt Exp $ */ +/* $OpenBSD: loader.c,v 1.219 2024/01/14 09:39:03 kettenis Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -70,6 +70,7 @@ int _dl_trust __relro = 0; char **_dl_libpath __relro = NULL; const char **_dl_argv __relro = NULL; int _dl_argc __relro = 0; +const char *_dl_libcname; char *_dl_preload __boot_data = NULL; char *_dl_tracefmt1 __boot_data = NULL; @@ -358,6 +359,31 @@ _dl_load_dep_libs(elf_object_t *object, int flags, int booting) if (dynp->d_tag == DT_NEEDED) liblist[loop++].dynp = dynp; + /* + * We can't support multiple versions of libc + * in a single process. So remember the first + * libc SONAME we encounter as a dependency + * and use it in further loads of libc. In + * practice this means we will always use the + * libc version that the binary was linked + * against. This isn't entirely correct, but + * it will keep most binaries running when + * transitioning over a libc major bump. + */ + if (_dl_libcname == NULL) { + for (loop = 0; loop < libcount; loop++) { + const char *libname; + libname = dynobj->dyn.strtab; + libname += + liblist[loop].dynp->d_un.d_val; + if (_dl_strncmp(libname, + "libc.so.", 8) == 0) { + _dl_libcname = libname; + break; + } + } + } + /* Randomize these */ for (loop = 0; loop < libcount; loop++) randomlist[loop] = loop; @@ -380,6 +406,10 @@ _dl_load_dep_libs(elf_object_t *object, int flags, int booting) liblist[randomlist[loop]].dynp->d_un.d_val; DL_DEB(("loading: %s required by %s\n", libname, dynobj->load_name)); + if (_dl_strncmp(libname, "libc.so.", 8) == 0) { + if (_dl_libcname) + libname = _dl_libcname; + } depobj = _dl_load_shlib(libname, dynobj, OBJTYPE_LIB, depflags, nodelete); if (depobj == 0) { diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 5a07f9718..a2158fcea 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sched.h,v 1.67 2023/10/24 13:20:11 claudio Exp $ */ +/* $OpenBSD: sched.h,v 1.69 2024/01/14 17:23:56 cheloha Exp $ */ /* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */ /*- @@ -69,8 +69,6 @@ #ifndef _SYS_SCHED_H_ #define _SYS_SCHED_H_ -#include - /* * Posix defines a which may want to include */ @@ -88,6 +86,17 @@ #define CP_IDLE 5 #define CPUSTATES 6 +struct cpustats { + uint64_t cs_time[CPUSTATES]; /* CPU state statistics */ + uint64_t cs_flags; /* see below */ +}; + +#define CPUSTATS_ONLINE 0x0001 /* CPU is schedulable */ + +#ifdef _KERNEL + +#include + #define SCHED_NQS 32 /* 32 run queues. */ struct clockintr; @@ -124,15 +133,6 @@ struct schedstate_percpu { u_char spc_smrgp; /* this CPU's view of grace period */ }; -struct cpustats { - uint64_t cs_time[CPUSTATES]; /* CPU state statistics */ - uint64_t cs_flags; /* see below */ -}; - -#define CPUSTATS_ONLINE 0x0001 /* CPU is schedulable */ - -#ifdef _KERNEL - /* spc_flags */ #define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */ #define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */