From c78abe7784e71f18b09b18832b02c1fbd83e2d0e Mon Sep 17 00:00:00 2001 From: purplerain Date: Sun, 18 Aug 2024 01:23:47 +0000 Subject: [PATCH] sync with OpenBSD -current --- distrib/sets/lists/comp/mi | 1 - gnu/usr.bin/texinfo/info/infomap.h | 4 +- gnu/usr.bin/texinfo/lib/system.h | 11 +- gnu/usr.bin/texinfo/makeinfo/files.c | 6 +- gnu/usr.bin/texinfo/makeinfo/xml.c | 4 +- gnu/usr.bin/texinfo/util/texindex.c | 5 +- lib/csu/arm/md_init.h | 3 +- lib/libcrypto/man/Makefile | 3 +- lib/libcrypto/man/X509_TRUST_set.3 | 286 ------------------- lib/libcrypto/man/X509_check_trust.3 | 47 +-- lib/libcrypto/man/X509_new.3 | 5 +- sbin/iked/radius.c | 16 +- share/man/man4/sti.4 | 14 +- share/man/man4/tty.4 | 6 +- sys/dev/i2c/icc.c | 3 +- sys/dev/ic/dwiic.c | 102 ++++--- sys/dev/ic/qwx.c | 8 +- sys/dev/ic/sti.c | 147 +++++++--- sys/dev/ic/stireg.h | 16 +- sys/dev/ic/stivar.h | 12 +- sys/dev/pci/drm/amd/amdgpu/amdgpu.h | 2 + sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c | 17 ++ sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c | 11 +- sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c | 24 +- sys/dev/pci/drm/drm_drv.c | 14 +- sys/dev/pci/drm/include/generated/autoconf.h | 1 + sys/dev/pci/drm/include/linux/pci.h | 8 +- sys/dev/pci/drm/include/linux/pm_runtime.h | 6 + sys/dev/pci/dwiic_pci.c | 11 +- sys/dev/pci/sti_pci.c | 24 +- sys/dev/pci/xhci_pci.c | 7 +- sys/dev/pv/if_vio.c | 5 +- sys/dev/usb/xhci.c | 33 +-- sys/dev/usb/xhcivar.h | 5 +- sys/dev/wscons/wsmux.c | 4 +- sys/kern/kern_exit.c | 6 +- sys/kern/kern_fork.c | 19 +- sys/kern/uipc_domain.c | 14 +- sys/net/ppp_tty.c | 3 +- sys/netinet/in_proto.c | 4 +- sys/netinet/ip_divert.c | 25 +- sys/netinet6/in6_proto.c | 4 +- sys/netinet6/ip6_divert.c | 23 +- sys/nfs/nfs_serv.c | 38 ++- sys/sys/protosw.h | 3 +- usr.bin/login/login.1 | 5 +- usr.bin/rpcinfo/rpcinfo.c | 12 +- usr.bin/ssh/servconf.c | 3 +- usr.bin/ssh/ssh-keygen.1 | 8 +- usr.bin/ssh/sshd.c | 4 +- usr.sbin/nsd/nsd.8.in | 6 +- usr.sbin/nsd/nsd.conf.5.in | 6 +- usr.sbin/pppd/chat/chat.c | 30 +- usr.sbin/pppd/sys-bsd.c | 20 +- usr.sbin/radiusd/radiusd_eap2mschap.c | 14 +- usr.sbin/radiusd/radiusd_ipcp.c | 37 ++- usr.sbin/radiusd/radiusd_local.h | 3 +- usr.sbin/radiusd/radiusd_radius.c | 3 +- usr.sbin/vmctl/main.c | 4 +- 59 files changed, 509 insertions(+), 656 deletions(-) delete mode 100644 lib/libcrypto/man/X509_TRUST_set.3 diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index e9fc7725b..b92c33cb9 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -2227,7 +2227,6 @@ ./usr/share/man/man3/X509_STORE_new.3 ./usr/share/man/man3/X509_STORE_set1_param.3 ./usr/share/man/man3/X509_STORE_set_verify_cb_func.3 -./usr/share/man/man3/X509_TRUST_set.3 ./usr/share/man/man3/X509_VERIFY_PARAM_new.3 ./usr/share/man/man3/X509_VERIFY_PARAM_set_flags.3 ./usr/share/man/man3/X509_add1_trust_object.3 diff --git a/gnu/usr.bin/texinfo/info/infomap.h b/gnu/usr.bin/texinfo/info/infomap.h index 5edc76c45..4344d3d5e 100644 --- a/gnu/usr.bin/texinfo/info/infomap.h +++ b/gnu/usr.bin/texinfo/info/infomap.h @@ -1,5 +1,5 @@ /* infomap.h -- description of a keymap in Info and related functions. - $Id: infomap.h,v 1.1.1.4 2006/07/17 16:03:43 espie Exp $ + $Id: infomap.h,v 1.2 2024/08/16 23:09:25 guenther Exp $ Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc. @@ -40,7 +40,7 @@ #define Meta_p(c) (((c) > meta_character_threshold)) #define Control_p(c) ((c) < control_character_threshold) -#define Meta(c) ((c) | (meta_character_bit)) +#define Meta(c) ((unsigned char)((c) | (meta_character_bit))) #define UnMeta(c) ((c) & (~meta_character_bit)) #define Control(c) ((toupper (c)) & (~control_character_bit)) #define UnControl(c) (tolower ((c) | control_character_bit)) diff --git a/gnu/usr.bin/texinfo/lib/system.h b/gnu/usr.bin/texinfo/lib/system.h index ca033e587..76df1cf46 100644 --- a/gnu/usr.bin/texinfo/lib/system.h +++ b/gnu/usr.bin/texinfo/lib/system.h @@ -1,5 +1,5 @@ /* system.h: system-dependent declarations; include this first. - $Id: system.h,v 1.5 2006/07/17 16:12:36 espie Exp $ + $Id: system.h,v 1.6 2024/08/16 22:57:03 guenther Exp $ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @@ -60,6 +60,7 @@ extern char *substring (const char *, const char *); #ifdef STDC_HEADERS #define getopt system_getopt #include +#include #undef getopt #else extern char *getenv (); @@ -117,14 +118,6 @@ extern char *strerror (); #define PATH_MAX _POSIX_PATH_MAX #endif -#ifndef HAVE_DECL_STRCASECMP -extern int strcasecmp (); -#endif - -#ifndef HAVE_DECL_STRNCASECMP -extern int strncasecmp (); -#endif - #ifndef HAVE_DECL_STRCOLL extern int strcoll (); #endif diff --git a/gnu/usr.bin/texinfo/makeinfo/files.c b/gnu/usr.bin/texinfo/makeinfo/files.c index 474162325..f4c6bbec7 100644 --- a/gnu/usr.bin/texinfo/makeinfo/files.c +++ b/gnu/usr.bin/texinfo/makeinfo/files.c @@ -1,5 +1,5 @@ /* files.c -- file-related functions for makeinfo. - $Id: files.c,v 1.1.1.3 2006/07/17 16:03:46 espie Exp $ + $Id: files.c,v 1.2 2024/08/16 22:53:32 guenther Exp $ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @@ -456,8 +456,8 @@ full_pathname (char *filename) temp_home = (char *) getenv ("HOME"); result = xmalloc (strlen (&filename[1]) + 1 - + temp_home ? strlen (temp_home) - : 0); + + (temp_home ? strlen (temp_home) + : 0)); *result = 0; if (temp_home) diff --git a/gnu/usr.bin/texinfo/makeinfo/xml.c b/gnu/usr.bin/texinfo/makeinfo/xml.c index a6b80de6a..3812c428f 100644 --- a/gnu/usr.bin/texinfo/makeinfo/xml.c +++ b/gnu/usr.bin/texinfo/makeinfo/xml.c @@ -1,5 +1,5 @@ /* xml.c -- xml output. - $Id: xml.c,v 1.3 2019/05/27 07:13:38 otto Exp $ + $Id: xml.c,v 1.4 2024/08/16 22:57:44 guenther Exp $ Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @@ -871,7 +871,7 @@ xml_insert_element_with_attribute (elt, arg, format, va_alist) return; } - if (!xml_element_list[elt].name || !strlen (xml_element_list[elt].name)) + if (!strlen (xml_element_list[elt].name)) { /*printf ("Warning: Inserting empty element %d\n", elt);*/ return; diff --git a/gnu/usr.bin/texinfo/util/texindex.c b/gnu/usr.bin/texinfo/util/texindex.c index 59247ce74..7aa9fa838 100644 --- a/gnu/usr.bin/texinfo/util/texindex.c +++ b/gnu/usr.bin/texinfo/util/texindex.c @@ -1,5 +1,5 @@ /* texindex -- sort TeX index dribble output into an actual index. - $Id: texindex.c,v 1.6 2015/11/14 23:06:06 deraadt Exp $ + $Id: texindex.c,v 1.7 2024/08/16 22:58:54 guenther Exp $ Copyright (C) 1987, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @@ -143,7 +143,6 @@ int merge_direct (char **infiles, int nfiles, char *outfile); void pfatal_with_name (const char *name); void fatal (const char *format, const char *arg); void error (const char *format, const char *arg); -void *xmalloc (), *xrealloc (); char *concat (char *s1, char *s2); void flush_tempfiles (int to_count); @@ -565,7 +564,7 @@ find_field (struct keyfield *keyfield, char *str, long int *lengthptr) { char *start; char *end; - char *(*fun) (); + char *(*fun) (char *, int, int, int); if (keyfield->braced) fun = find_braced_pos; diff --git a/lib/csu/arm/md_init.h b/lib/csu/arm/md_init.h index 3d9c7f6ac..15517ebd8 100644 --- a/lib/csu/arm/md_init.h +++ b/lib/csu/arm/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.18 2023/11/18 16:26:16 deraadt Exp $ */ +/* $OpenBSD: md_init.h,v 1.19 2024/08/17 09:48:31 phessler Exp $ */ /*- * Copyright (c) 2001 Ross Harvey @@ -87,7 +87,6 @@ * of COPY relocations for WEAK symbols. */ #define MD_CRT0_START \ - char **environ, *__progname; \ __asm( \ ".text \n" \ " .align 0 \n" \ diff --git a/lib/libcrypto/man/Makefile b/lib/libcrypto/man/Makefile index 3bb9348af..d4633eddd 100644 --- a/lib/libcrypto/man/Makefile +++ b/lib/libcrypto/man/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.288 2024/07/10 08:51:28 tb Exp $ +# $OpenBSD: Makefile,v 1.289 2024/08/17 09:16:37 tb Exp $ .include @@ -349,7 +349,6 @@ MAN= \ X509_STORE_new.3 \ X509_STORE_set1_param.3 \ X509_STORE_set_verify_cb_func.3 \ - X509_TRUST_set.3 \ X509_VERIFY_PARAM_new.3 \ X509_VERIFY_PARAM_set_flags.3 \ X509_add1_trust_object.3 \ diff --git a/lib/libcrypto/man/X509_TRUST_set.3 b/lib/libcrypto/man/X509_TRUST_set.3 deleted file mode 100644 index f363ead18..000000000 --- a/lib/libcrypto/man/X509_TRUST_set.3 +++ /dev/null @@ -1,286 +0,0 @@ -.\" $OpenBSD: X509_TRUST_set.3,v 1.1 2021/07/24 14:33:14 schwarze Exp $ -.\" -.\" Copyright (c) 2021 Ingo Schwarze -.\" -.\" 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: July 24 2021 $ -.Dt X509_TRUST_SET 3 -.Os -.Sh NAME -.Nm X509_TRUST_set , -.Nm X509_TRUST_get_by_id , -.Nm X509_TRUST_add , -.Nm X509_TRUST_get_count , -.Nm X509_TRUST_cleanup , -.Nm X509_TRUST_get0 , -.Nm X509_TRUST_get_trust , -.Nm X509_TRUST_get0_name , -.Nm X509_TRUST_get_flags -.Nd trust objects, indices, and identifiers -.Sh SYNOPSIS -.In openssl/x509.h -.Ft int -.Fo X509_TRUST_set -.Fa "int *id_out" -.Fa "int id_in" -.Fc -.Ft int -.Fn X509_TRUST_get_by_id "int identifier" -.Ft int -.Fo X509_TRUST_add -.Fa "int identifier" -.Fa "int flags" -.Fa "int (*check_trust)(X509_TRUST *, X509 *, int)" -.Fa "const char *name" -.Fa "int arg1" -.Fa "void *arg2" -.Fc -.Ft int -.Fn X509_TRUST_get_count void -.Ft void -.Fn X509_TRUST_cleanup void -.Ft X509_TRUST * -.Fn X509_TRUST_get0 "int index" -.Ft int -.Fn X509_TRUST_get_trust "const X509_TRUST *object" -.Ft char * -.Fn X509_TRUST_get0_name "const X509_TRUST *object" -.Ft int -.Fn X509_TRUST_get_flags "const X509_TRUST *object" -.Sh DESCRIPTION -The purposes that an X.509 certificate is trusted for -can be identified in three equivalent ways: -.Bl -enum -.It -By trust identifiers, which are positive integer constants. -Standard trust identifiers lie in the range from -.Dv X509_TRUST_MIN -to -.Dv X509_TRUST_MAX , -inclusive. -User defined trust identifiers are larger than -.Dv X509_TRUST_MAX . -.It -By trust indices, which are non-negative integer constants but -differ from the trust identifiers expressing the same kind of trust. -Standard trust indices are smaller than -.Dv X509_TRUST_MAX . -User defined trust indices are larger than or equal to -.Dv X509_TRUST_MAX . -.It -By trust objects of the type -.Vt X509_TRUST . -Standard trust objects are available in static storage. -User defined trust objects can be created with -.Fn X509_TRUST_add . -.El -.Pp -Application programmers cannot choose the way to identify kinds of trust -that they like best; depending on the circumstances, all three ways -are needed. -Be warned that the naming of most functions is misleading. -.Pp -Most API functions documented outside the present manual page -use trust identifiers rather than trust indices. -.Pp -ASN.1 object identifiers and NIDs provide a fourth and a fifth way -to identify purposes that a certificate is trusted for. -These are almost, but not exactly, equivalent -to the three ways listed above; see the -.Xr X509_check_trust 3 -manual for details. -.Ss Using trust identifiers -.Fn X509_TRUST_set -validates the trust identifier -.Fa id_in . -If it is valid, it is copied to -.Pf * Fa id_out . -Otherwise, -.Pf * Fa id_out -remains unchanged. -.Pp -.Fn X509_TRUST_get_by_id -converts the trust -.Fa identifier -to the corresponding trust -.Fa index . -To find the corresponding trust object, pass the result to -.Fn X509_TRUST_get0 . -.Pp -.Fn X509_TRUST_add -defines a purpose certificates can be trusted for with the given -.Fa identifier -or modifies its properties if it already exists. -The trust -.Fa identifier , -the -.Fa flags , -the -.Fa check_trust -function, the -.Fa name , -the number -.Fa arg1 , -and the pointer -.Fa arg2 -are copied into the -.Vt X509_TRUST -object. -When modifying an existing trust object, previous -values of fields are overwritten and a previous -.Fa name -string is freed if it was dynamically allocated. -When creating a new trust object, -it is added to the global array of user-defined trust objects. -.Pp -.Dv X509_TRUST_DYNAMIC -and -.Dv X509_TRUST_DYNAMIC_NAME -are always ignored in the -.Fa flags -argument. -.Dv X509_TRUST_DYNAMIC -is automatically set if the object was created by the user. -It is never set for standard objects, -not even if they were modified by the user. -.Dv X509_trust_DYNAMIC_NAME -is automatically set if the object was created or modified by the user. -It is only unset for unmodified standard objects. -The library does not appear to define any other flags, -so the flags argument is probably useless -unless users define their own flags and use them in the -.Fa check_trust -function. -.Pp -The third and final argument of the -.Fa check_trust -function is the -.Fa flags -argument of -.Fn X509_check_trust . -.Pp -The built-in trust checking functions documented in the -.Xr X509_check_trust 3 -manual page use -.Fa arg1 -as the corresponding ASN.1 object NID and ignore -.Fa arg2 -and -.Fa flags , -but a user-supplied -.Fa check_trust -function can use these fields in any arbitrary way. -.Pp -.Fn X509_TRUST_get_count -returns the total number of trust objects currently existing, -including both standard and user-defined objects. -If no user-defined objects exist, the returned value is -.Dv X509_TRUST_MAX . -.Pp -.Fn X509_TRUST_cleanup -deletes all user-defined trust objects -and invalidates their trust identifiers and trust indices. -If any of the standard trust objects were modified by the user, -those changes are -.Em not -reverted. -.Ss Using trust indices -.Fn X509_TRUST_get0 -converts the trust -.Fa index -to a pointer to the corresponding trust object. -To find the corresponding trust identifier, pass the result to -.Fn X509_TRUST_get_trust . -.Ss Using trust objects -.Fn X509_TRUST_get_trust -converts a pointer to a trust -.Fa object -to the corresponding trust identifier. -To find the corresponding trust index, pass the result to -.Fn X509_TRUST_get_by_id . -.Pp -.Fn X509_TRUST_get0_name -and -.Fn X509_TRUST_get_flags -retrieve the name and flags from the -.Fa object , -respectively. -.Sh RETURN VALUES -.Fn X509_TRUST_set -returns 1 if -.Fa id_in -is valid or 0 otherwise. -.Pp -.Fn X509_TRUST_get_by_id -returns the corresponding trust index or -1 if the -.Fa identifier -is invalid. -.Pp -.Fn X509_TRUST_add -returns 1 for success or 0 for failure. -.Pp -.Fn X509_TRUST_get_count -returns the total number of trust objects currently existing. -.Pp -.Fn X509_TRUST_get0 -returns a standard or user-defined trust object or -.Dv NULL -if the -.Fa index -is invalid. -.Pp -.Fn X509_TRUST_get_trust -always returns a valid trust identifier. -.Pp -.Fn X509_TRUST_get0_name -returns a pointer to storage owned by the -.Fa object . -.Pp -.Fn X509_TRUST_get_flags -returns the flags associated with the -.Fa object . -.Sh ERRORS -The following diagnostics can be retrieved with -.Xr ERR_get_error 3 , -.Xr ERR_GET_REASON 3 , -and -.Xr ERR_reason_error_string 3 : -.Bl -tag -width Ds -.It Dv X509_R_INVALID_TRUST Qq "invalid trust" -.Fn X509_TRUST_set -was called with an invalid -.Fa id_in -argument. -.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure" -.Fn X509_TRUST_add -failed to allocate memory. -.El -.Pp -The other functions provide no diagnostics. -.Sh SEE ALSO -.Xr X509_check_trust 3 , -.Xr X509_new 3 , -.Xr X509_PURPOSE_set 3 , -.Xr X509_VERIFY_PARAM_set_trust 3 -.Sh HISTORY -.Fn X509_TRUST_set -first appeared in OpenSSL 0.9.7 and has been available since -.Ox 3.2 . -.Pp -The other functions first appeared in OpenSSL 0.9.5 -and have been available since -.Ox 2.7 . -.Sh CAVEATS -The difference between trust identifiers and trust indices -provides an ideal breeding ground for off-by-one bugs. diff --git a/lib/libcrypto/man/X509_check_trust.3 b/lib/libcrypto/man/X509_check_trust.3 index 0f02a1b1e..f085bfcf2 100644 --- a/lib/libcrypto/man/X509_check_trust.3 +++ b/lib/libcrypto/man/X509_check_trust.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_check_trust.3,v 1.8 2023/04/30 14:49:47 tb Exp $ +.\" $OpenBSD: X509_check_trust.3,v 1.10 2024/08/17 09:19:04 tb Exp $ .\" .\" Copyright (c) 2021 Ingo Schwarze .\" @@ -14,12 +14,11 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 30 2023 $ +.Dd $Mdocdate: August 17 2024 $ .Dt X509_CHECK_TRUST 3 .Os .Sh NAME -.Nm X509_check_trust , -.Nm X509_TRUST_set_default +.Nm X509_check_trust .Nd check whether a certificate is trusted .Sh SYNOPSIS .In openssl/x509.h @@ -29,12 +28,6 @@ .Fa "int trust" .Fa "int flags" .Fc -.Ft int -.Fo "(*X509_TRUST_set_default(int (*handler)(int, X509 *, int)))" -.Fa "int trust" -.Fa "X509 *certificate" -.Fa "int flags" -.Fc .Sh DESCRIPTION .Fn X509_check_trust checks whether the @@ -183,27 +176,6 @@ identifiers listed above, or it may have installed additional, user-supplied checking functions for user-defined .Fa trust identifiers not listed above. -.Pp -If the function -.Fn X509_TRUST_set_default -was called, the -.Fa handler -function passed to it is used instead of the standard algorithm, -but only in the case where the -.Fa trust -argument of -.Fn X509_check_trust -is invalid. -The compatibility step is not used in this case. -.Pp -If the return value of the first call to -.Fn X509_TRUST_set_default -is saved and passed back to -.Fn X509_TRUST_set_default -later on, the standard behaviour -of using the standard algorithm for invalid -.Fa trust -arguments is restored. .Sh RETURN VALUES .Fn X509_check_trust returns the following values: @@ -222,27 +194,14 @@ The is neither trusted nor explicitly rejected, which implies that it is not trusted. .El -.Pp -.Fn X509_TRUST_set_default -returns a pointer to the handler function for invalid -.Fa trust -that was installed before the call, which may either be a pointer -to a function installed by a previous call to -.Fn X509_TRUST_set_default -or a pointer to the built-in function implementing the standard algorithm if -.Fn X509_TRUST_set_default -was never called before. .Sh SEE ALSO .Xr PEM_read_X509_AUX 3 , .Xr X509_add1_trust_object 3 , .Xr X509_CERT_AUX_new 3 , .Xr X509_check_purpose 3 , .Xr X509_new 3 , -.Xr X509_TRUST_set 3 , .Xr X509_VERIFY_PARAM_set_trust 3 .Sh HISTORY .Fn X509_check_trust -and -.Fn X509_TRUST_set_default first appeared in OpenSSL 0.9.5 and has been available since .Ox 2.7 . diff --git a/lib/libcrypto/man/X509_new.3 b/lib/libcrypto/man/X509_new.3 index 3e7fb0a79..9bc3ee95c 100644 --- a/lib/libcrypto/man/X509_new.3 +++ b/lib/libcrypto/man/X509_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_new.3,v 1.43 2023/09/29 08:57:49 tb Exp $ +.\" $OpenBSD: X509_new.3,v 1.44 2024/08/17 09:16:37 tb Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file is a derived work. @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 29 2023 $ +.Dd $Mdocdate: August 17 2024 $ .Dt X509_NEW 3 .Os .Sh NAME @@ -241,7 +241,6 @@ if an error occurs. .Xr X509_STORE_CTX_new 3 , .Xr X509_STORE_get_by_subject 3 , .Xr X509_STORE_new 3 , -.Xr X509_TRUST_set 3 , .Xr X509v3_addr_add_inherit 3 , .Xr X509v3_addr_get_range 3 , .Xr X509v3_addr_inherits 3 , diff --git a/sbin/iked/radius.c b/sbin/iked/radius.c index e30a9f17a..5847795a1 100644 --- a/sbin/iked/radius.c +++ b/sbin/iked/radius.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radius.c,v 1.9 2024/08/08 03:58:53 yasuoka Exp $ */ +/* $OpenBSD: radius.c,v 1.10 2024/08/17 03:28:22 yasuoka Exp $ */ /* * Copyright (c) 2024 Internet Initiative Japan Inc. @@ -198,11 +198,8 @@ iked_radius_on_event(int fd, short ev, void *ctx) log_info("%s: received an invalid RADIUS message: " "code %u", __func__, (unsigned)code); } - timer_del(env, &req->rr_timer); - TAILQ_REMOVE(&server->rs_reqs, req, rr_entry); - req->rr_server = NULL; - free(req); radius_delete_packet(pkt); + iked_radius_request_free(env, req); return; } @@ -229,8 +226,12 @@ iked_radius_on_event(int fd, short ev, void *ctx) "state attribute", __func__); goto fail; } - if ((req->rr_state != NULL && - ibuf_set(req->rr_state, 0, attrval, attrlen) != 0) || + if (req->rr_state != NULL && + ibuf_set(req->rr_state, 0, attrval, attrlen) != 0) { + ibuf_free(req->rr_state); + req->rr_state = NULL; + } + if (req->rr_state == NULL && (req->rr_state = ibuf_new(attrval, attrlen)) == NULL) { log_info("%s: ibuf_new() failed: %s", __func__, strerror(errno)); @@ -321,6 +322,7 @@ iked_radius_on_event(int fd, short ev, void *ctx) radius_delete_packet(pkt); ikev2_send_ike_e(env, req->rr_sa, e, IKEV2_PAYLOAD_EAP, IKEV2_EXCHANGE_IKE_AUTH, 1); + ibuf_free(e); /* keep request for challenge state and config parameters */ req->rr_reqid = -1; /* release reqid */ return; diff --git a/share/man/man4/sti.4 b/share/man/man4/sti.4 index cdea9899a..50518184d 100644 --- a/share/man/man4/sti.4 +++ b/share/man/man4/sti.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sti.4,v 1.25 2014/03/19 12:57:51 jmc Exp $ +.\" $OpenBSD: sti.4,v 1.26 2024/08/17 08:41:25 miod Exp $ .\" .\" Copyright (c) 2001 Michael Shalayeff .\" All rights reserved. @@ -24,7 +24,7 @@ .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF .\" THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 19 2014 $ +.Dd $Mdocdate: August 17 2024 $ .Dt STI 4 .Os .Sh NAME @@ -65,7 +65,7 @@ The following models are supported .\" .It "Visualize 24" Ta "24" Ta "16" Ta "y" Ta "GSC" .\" .It "Visualize 48" Ta "24" Ta "16" Ta "y" Ta "GSC" .\" .It "Visualize 48XP" Ta "24" Ta "16" Ta "y" Ta "GSC" -.It "Visualize FXE" Ta "24" Ta "24" Ta "y" Ta "PCI 32/66" +.It "Visualize FXe" Ta "24" Ta "24" Ta "y" Ta "PCI 32/66" .It "Visualize FX2" Ta "24" Ta "24" Ta "y" Ta "PCI 64/66" .It "Visualize FX4/FX6" Ta "24" Ta "32" Ta "y" Ta "PCI 64/66" .\" .It "Visualize FX5pro" Ta "24" Ta "64" Ta "y" Ta "PCI 64/66" @@ -232,18 +232,18 @@ due to rearchitecture for performance. .Nm process_mgr function added. .El -.It 8.0a +.It 8.10 PCXL2 and PCXU dual .Nm PCI EPROM map mode, implemented on .Nm Visualize EG . -.It 8.0b +.It 8.11 Support for HP-UX non-implicit locking DMA, implemented on .Nm Visualize FXE . -.It 8.0c +.It 8.12 .Nm sti_util function added (flashing under HP-UX and other sideband traffic). -.It 8.0d +.It 8.13 Colour frame buffer support. .El .Sh SEE ALSO diff --git a/share/man/man4/tty.4 b/share/man/man4/tty.4 index 4215da9b5..a47a26e32 100644 --- a/share/man/man4/tty.4 +++ b/share/man/man4/tty.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tty.4,v 1.55 2022/02/18 23:17:15 jsg Exp $ +.\" $OpenBSD: tty.4,v 1.56 2024/08/16 16:10:27 florian Exp $ .\" $NetBSD: tty.4,v 1.4 1996/03/19 04:26:01 paulus Exp $ .\" .\" Copyright (c) 1991, 1992, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)tty.4 8.3 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: February 18 2022 $ +.Dd $Mdocdate: August 16 2024 $ .Dt TTY 4 .Os .Sh NAME @@ -61,8 +61,6 @@ These special terminal devices are called and provide the mechanism necessary to give users the same interface to the system when logging in over a network (using .Xr ssh 1 -or -.Xr telnet 1 for example). Even in these cases the details of how the terminal file was opened and set up is already handled by special software diff --git a/sys/dev/i2c/icc.c b/sys/dev/i2c/icc.c index 14dfc81cd..1ce60ee50 100644 --- a/sys/dev/i2c/icc.c +++ b/sys/dev/i2c/icc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icc.c,v 1.1 2022/11/11 15:25:13 matthieu Exp $ */ +/* $OpenBSD: icc.c,v 1.2 2024/08/17 15:10:00 deraadt Exp $ */ /* * Copyright (c) 2021 Anton Lindqvist @@ -48,6 +48,7 @@ const struct cfattach icc_ca = { sizeof(struct icc_softc), icc_match, icc_attach, + icc_detach }; int diff --git a/sys/dev/ic/dwiic.c b/sys/dev/ic/dwiic.c index 0f562bb5e..091e38ffb 100644 --- a/sys/dev/ic/dwiic.c +++ b/sys/dev/ic/dwiic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwiic.c,v 1.15 2023/08/29 12:09:40 kettenis Exp $ */ +/* $OpenBSD: dwiic.c,v 1.21 2024/08/17 02:35:00 deraadt Exp $ */ /* * Synopsys DesignWare I2C controller * @@ -21,14 +21,6 @@ #include #include -#ifdef __HAVE_ACPI -#include -#include -#include -#include -#include -#endif - #include #include @@ -41,34 +33,50 @@ int dwiic_activate(struct device *self, int act) { struct dwiic_softc *sc = (struct dwiic_softc *)self; + int rv; switch (act) { case DVACT_SUSPEND: + rv = config_activate_children(self, act); /* disable controller */ dwiic_enable(sc, 0); /* disable interrupts */ dwiic_write(sc, DW_IC_INTR_MASK, 0); dwiic_read(sc, DW_IC_CLR_INTR); - -#if notyet - /* power down the controller */ - dwiic_acpi_power(sc, 0); -#endif break; - case DVACT_WAKEUP: -#if notyet - /* power up the controller */ - dwiic_acpi_power(sc, 1); -#endif - dwiic_init(sc); + case DVACT_RESUME: + /* if it became enabled for some reason, force it down */ + dwiic_enable(sc, 0); + dwiic_write(sc, DW_IC_INTR_MASK, 0); + dwiic_read(sc, DW_IC_CLR_INTR); + + /* write standard-mode SCL timing parameters */ + dwiic_write(sc, DW_IC_SS_SCL_HCNT, sc->ss_hcnt); + dwiic_write(sc, DW_IC_SS_SCL_LCNT, sc->ss_lcnt); + + /* and fast-mode SCL timing parameters */ + dwiic_write(sc, DW_IC_FS_SCL_HCNT, sc->fs_hcnt); + dwiic_write(sc, DW_IC_FS_SCL_LCNT, sc->fs_lcnt); + + /* SDA hold time */ + dwiic_write(sc, DW_IC_SDA_HOLD, sc->sda_hold_time); + + dwiic_write(sc, DW_IC_TX_TL, sc->tx_fifo_depth / 2); + dwiic_write(sc, DW_IC_RX_TL, 0); + + /* configure as i2c master with fast speed */ + sc->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | + DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; + dwiic_write(sc, DW_IC_CON, sc->master_cfg); + rv = config_activate_children(self, act); + break; + default: + rv = config_activate_children(self, act); break; } - - config_activate_children(self, act); - - return 0; + return rv; } int @@ -489,32 +497,32 @@ dwiic_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, const void *cmdbuf, uint32_t dwiic_read_clear_intrbits(struct dwiic_softc *sc) { - uint32_t stat; + uint32_t stat; - stat = dwiic_read(sc, DW_IC_INTR_STAT); + stat = dwiic_read(sc, DW_IC_INTR_STAT); - if (stat & DW_IC_INTR_RX_UNDER) - dwiic_read(sc, DW_IC_CLR_RX_UNDER); - if (stat & DW_IC_INTR_RX_OVER) - dwiic_read(sc, DW_IC_CLR_RX_OVER); - if (stat & DW_IC_INTR_TX_OVER) - dwiic_read(sc, DW_IC_CLR_TX_OVER); - if (stat & DW_IC_INTR_RD_REQ) - dwiic_read(sc, DW_IC_CLR_RD_REQ); - if (stat & DW_IC_INTR_TX_ABRT) - dwiic_read(sc, DW_IC_CLR_TX_ABRT); - if (stat & DW_IC_INTR_RX_DONE) - dwiic_read(sc, DW_IC_CLR_RX_DONE); - if (stat & DW_IC_INTR_ACTIVITY) - dwiic_read(sc, DW_IC_CLR_ACTIVITY); - if (stat & DW_IC_INTR_STOP_DET) - dwiic_read(sc, DW_IC_CLR_STOP_DET); - if (stat & DW_IC_INTR_START_DET) - dwiic_read(sc, DW_IC_CLR_START_DET); - if (stat & DW_IC_INTR_GEN_CALL) - dwiic_read(sc, DW_IC_CLR_GEN_CALL); + if (stat & DW_IC_INTR_RX_UNDER) + dwiic_read(sc, DW_IC_CLR_RX_UNDER); + if (stat & DW_IC_INTR_RX_OVER) + dwiic_read(sc, DW_IC_CLR_RX_OVER); + if (stat & DW_IC_INTR_TX_OVER) + dwiic_read(sc, DW_IC_CLR_TX_OVER); + if (stat & DW_IC_INTR_RD_REQ) + dwiic_read(sc, DW_IC_CLR_RD_REQ); + if (stat & DW_IC_INTR_TX_ABRT) + dwiic_read(sc, DW_IC_CLR_TX_ABRT); + if (stat & DW_IC_INTR_RX_DONE) + dwiic_read(sc, DW_IC_CLR_RX_DONE); + if (stat & DW_IC_INTR_ACTIVITY) + dwiic_read(sc, DW_IC_CLR_ACTIVITY); + if (stat & DW_IC_INTR_STOP_DET) + dwiic_read(sc, DW_IC_CLR_STOP_DET); + if (stat & DW_IC_INTR_START_DET) + dwiic_read(sc, DW_IC_CLR_START_DET); + if (stat & DW_IC_INTR_GEN_CALL) + dwiic_read(sc, DW_IC_CLR_GEN_CALL); - return stat; + return stat; } int diff --git a/sys/dev/ic/qwx.c b/sys/dev/ic/qwx.c index 41b5be9bb..860f215ba 100644 --- a/sys/dev/ic/qwx.c +++ b/sys/dev/ic/qwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qwx.c,v 1.63 2024/06/11 10:06:35 stsp Exp $ */ +/* $OpenBSD: qwx.c,v 1.64 2024/08/17 08:12:46 stsp Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -19836,10 +19836,7 @@ qwx_core_qmi_firmware_ready(struct qwx_softc *sc) goto err_core_stop; } -#if 0 /* TODO: Is this in the right spot for OpenBSD? */ sc->ops.irq_enable(sc); -#endif - #if 0 mutex_unlock(&ab->core_lock); #endif @@ -25390,9 +25387,6 @@ qwx_run(struct qwx_softc *sc) return ret; } - /* Enable "ext" IRQs for datapath. */ - sc->ops.irq_enable(sc); - return 0; } diff --git a/sys/dev/ic/sti.c b/sys/dev/ic/sti.c index 30b673da4..2b5e342da 100644 --- a/sys/dev/ic/sti.c +++ b/sys/dev/ic/sti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sti.c,v 1.83 2022/07/15 19:29:27 deraadt Exp $ */ +/* $OpenBSD: sti.c,v 1.84 2024/08/17 08:45:22 miod Exp $ */ /* * Copyright (c) 2000-2003 Michael Shalayeff @@ -110,6 +110,7 @@ void sti_describe_screen(struct sti_softc *, struct sti_screen *); void sti_end_attach_screen(struct sti_softc *, struct sti_screen *, int); int sti_fetchfonts(struct sti_screen *, struct sti_inqconfout *, u_int32_t, u_int); +int32_t sti_gvid(void *, uint32_t, uint32_t *); void sti_region_setup(struct sti_screen *); int sti_rom_setup(struct sti_rom *, bus_space_tag_t, bus_space_tag_t, bus_space_handle_t, bus_addr_t *, u_int); @@ -122,6 +123,10 @@ void ngle_elk_setupfb(struct sti_screen *); void ngle_timber_setupfb(struct sti_screen *); int ngle_putcmap(struct sti_screen *, u_int, u_int); +/* + * Helper macros to control whether the STI ROM is accessible on PCI + * devices. + */ #if NSTI_PCI > 0 #define STI_ENABLE_ROM(sc) \ do { \ @@ -301,6 +306,15 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt, dd->dd_pacode[0xf]); #endif + /* + * Take note that it will be necessary to enable the PCI ROM around + * some sti function calls if the MMAP (multiple map) bit is set in + * the bus support flags, which means the PCI ROM is only available + * through the PCI expansion ROM space and never through regular + * PCI BARs. + */ + rom->rom_enable = dd->dd_bussup & STI_BUSSUPPORT_ROMMAP; + /* * Figure out how much bytes we need for the STI code. * Note there could be fewer than STI_END entries pointer @@ -337,9 +351,8 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt, u_int32_t addr, eaddr; for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4; - addr < eaddr; addr += 4 ) + addr < eaddr; addr += 4) *p++ = bus_space_read_4(memt, romh, addr) & 0xff; - } else /* STI_DEVTYPE4 */ bus_space_read_raw_region_4(memt, romh, dd->dd_pacode[STI_BEGIN], rom->rom_code, size); @@ -371,18 +384,10 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt, (rom->rom_devtype == STI_DEVTYPE1? 4 : 1))) rom->init = (sti_init_t)O(STI_INIT_GRAPH); - rom->mgmt = (sti_mgmt_t)O(STI_STATE_MGMT); rom->unpmv = (sti_unpmv_t)O(STI_FONT_UNPMV); rom->blkmv = (sti_blkmv_t)O(STI_BLOCK_MOVE); - rom->test = (sti_test_t)O(STI_SELF_TEST); - rom->exhdl = (sti_exhdl_t)O(STI_EXCEP_HDLR); rom->inqconf = (sti_inqconf_t)O(STI_INQ_CONF); rom->scment = (sti_scment_t)O(STI_SCM_ENT); - rom->dmac = (sti_dmac_t)O(STI_DMA_CTRL); - rom->flowc = (sti_flowc_t)O(STI_FLOW_CTRL); - rom->utiming = (sti_utiming_t)O(STI_UTIMING); - rom->pmgr = (sti_pmgr_t)O(STI_PROC_MGR); - rom->util = (sti_util_t)O(STI_UTIL); #undef O @@ -502,6 +507,42 @@ sti_region_setup(struct sti_screen *scr) #endif } +/* + * ``gvid'' callback routine. + * + * The FireGL-UX board is using this interface, and will revert to direct + * PDC calls if no gvid callback is set. + * Unfortunately, under OpenBSD it is not possible to invoke PDC directly + * from its physical address once the MMU is turned on, and no documentation + * for the gvid interface (or for the particular PDC_PCI subroutines used + * by the FireGL-UX rom) has been found. + */ +int32_t +sti_gvid(void *v, uint32_t cmd, uint32_t *params) +{ + struct sti_screen *scr = v; + struct sti_rom *rom = scr->scr_rom; + + /* paranoia */ + if (cmd != 0x000c0003) + return -1; + + switch (params[0]) { + case 4: + /* register read */ + params[2] = + bus_space_read_4(rom->memt, rom->regh[2], params[1]); + return 0; + case 5: + /* register write */ + bus_space_write_4(rom->memt, rom->regh[2], params[1], + params[2]); + return 0; + default: + return -1; + } +} + int sti_screen_setup(struct sti_screen *scr, int flags) { @@ -510,8 +551,8 @@ sti_screen_setup(struct sti_screen *scr, int flags) bus_space_handle_t romh = rom->romh; struct sti_dd *dd = &rom->rom_dd; struct sti_cfg *cc = &scr->scr_cfg; - struct sti_inqconfout cfg; - struct sti_einqconfout ecfg; + struct sti_inqconfout inq; + struct sti_einqconfout einq; int error, i; int geometry_kluge = 0; u_int fontindex = 0; @@ -522,7 +563,7 @@ sti_screen_setup(struct sti_screen *scr, int flags) if (dd->dd_stimemreq) { scr->scr_ecfg.addr = - malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT); + malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT | M_ZERO); if (!scr->scr_ecfg.addr) { printf("cannot allocate %d bytes for STI\n", dd->dd_stimemreq); @@ -530,6 +571,12 @@ sti_screen_setup(struct sti_screen *scr, int flags) } } + if (dd->dd_ebussup & STI_EBUSSUPPORT_GVID) { + scr->scr_ecfg.future.g.gvid_cmd_arg = scr; + scr->scr_ecfg.future.g.gvid_cmd = + (int32_t (*)(void *, ...))sti_gvid; + } + sti_region_setup(scr); if ((error = sti_init(scr, 0))) { @@ -537,10 +584,10 @@ sti_screen_setup(struct sti_screen *scr, int flags) goto fail; } - bzero(&cfg, sizeof(cfg)); - bzero(&ecfg, sizeof(ecfg)); - cfg.ext = &ecfg; - if ((error = sti_inqcfg(scr, &cfg))) { + bzero(&inq, sizeof(inq)); + bzero(&einq, sizeof(einq)); + inq.ext = &einq; + if ((error = sti_inqcfg(scr, &inq))) { printf(": error %d inquiring config\n", error); goto fail; } @@ -550,25 +597,24 @@ sti_screen_setup(struct sti_screen *scr, int flags) * similar to the displayable area size, at least in m68k mode. * Attempt to detect this and adjust here. */ - if (cfg.owidth == cfg.width && - cfg.oheight == cfg.height) + if (inq.owidth == inq.width && inq.oheight == inq.height) geometry_kluge = 1; if (geometry_kluge) { - scr->scr_cfg.oscr_width = cfg.owidth = - cfg.fbwidth - cfg.width; - scr->scr_cfg.oscr_height = cfg.oheight = - cfg.fbheight - cfg.height; + scr->scr_cfg.oscr_width = inq.owidth = + inq.fbwidth - inq.width; + scr->scr_cfg.oscr_height = inq.oheight = + inq.fbheight - inq.height; } /* * Save a few fields for sti_describe_screen() later */ - scr->fbheight = cfg.fbheight; - scr->fbwidth = cfg.fbwidth; - scr->oheight = cfg.oheight; - scr->owidth = cfg.owidth; - bcopy(cfg.name, scr->name, sizeof(scr->name)); + scr->fbheight = inq.fbheight; + scr->fbwidth = inq.fbwidth; + scr->oheight = inq.oheight; + scr->owidth = inq.owidth; + bcopy(inq.name, scr->name, sizeof(scr->name)); if ((error = sti_init(scr, STI_TEXTMODE | flags))) { printf(": can not initialize (%d)\n", error); @@ -576,12 +622,12 @@ sti_screen_setup(struct sti_screen *scr, int flags) } #ifdef STIDEBUG printf("conf: bpp=%d planes=%d attr=%b\n" - "crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", cfg.bpp, - cfg.planes, cfg.attributes, STI_INQCONF_BITS, - ecfg.crt_config[0], ecfg.crt_config[1], ecfg.crt_config[2], - ecfg.crt_hw[0], ecfg.crt_hw[1], ecfg.crt_hw[2]); + "crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", inq.bpp, + inq.planes, inq.attributes, STI_INQCONF_BITS, + einq.crt_config[0], einq.crt_config[1], einq.crt_config[2], + einq.crt_hw[0], einq.crt_hw[1], einq.crt_hw[2]); #endif - scr->scr_bpp = cfg.bppu; + scr->scr_bpp = inq.bppu; /* * Although scr->scr_ecfg.current_monitor is not filled by @@ -618,7 +664,7 @@ sti_screen_setup(struct sti_screen *scr, int flags) #endif } - if ((error = sti_fetchfonts(scr, &cfg, dd->dd_fntaddr, fontindex))) { + if ((error = sti_fetchfonts(scr, &inq, dd->dd_fntaddr, fontindex))) { printf(": cannot fetch fonts (%d)\n", error); goto fail; } @@ -631,8 +677,8 @@ sti_screen_setup(struct sti_screen *scr, int flags) */ strlcpy(scr->scr_wsd.name, "std", sizeof(scr->scr_wsd.name)); - scr->scr_wsd.ncols = cfg.width / scr->scr_curfont.width; - scr->scr_wsd.nrows = cfg.height / scr->scr_curfont.height; + scr->scr_wsd.ncols = inq.width / scr->scr_curfont.width; + scr->scr_wsd.nrows = inq.height / scr->scr_curfont.height; scr->scr_wsd.textops = &sti_emulops; scr->scr_wsd.fontwidth = scr->scr_curfont.width; scr->scr_wsd.fontheight = scr->scr_curfont.height; @@ -699,9 +745,10 @@ sti_screen_setup(struct sti_screen *scr, int flags) case STI_DD_3X2V: case STI_DD_DUAL_CRX: case STI_DD_HCRX: - case STI_DD_LEGO: case STI_DD_SUMMIT: case STI_DD_PINNACLE: + case STI_DD_LEGO: + case STI_DD_FIREGL: default: scr->setupfb = NULL; scr->putcmap = @@ -713,7 +760,11 @@ sti_screen_setup(struct sti_screen *scr, int flags) return (0); fail: - /* XXX free resources */ + /* free resources */ + if (scr->scr_romfont != NULL) { + free(scr->scr_romfont, M_DEVBUF, 0); + scr->scr_romfont = NULL; + } if (scr->scr_ecfg.addr != NULL) { free(scr->scr_ecfg.addr, M_DEVBUF, 0); scr->scr_ecfg.addr = NULL; @@ -809,7 +860,7 @@ sti_rom_size(bus_space_tag_t memt, bus_space_handle_t romh) } int -sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *cfg, +sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *inq, u_int32_t baseaddr, u_int fontindex) { struct sti_rom *rom = scr->scr_rom; @@ -901,16 +952,16 @@ rescan: * display all the characters there in order to display them * faster with blkmv operations rather than unpmv later on. */ - if (size <= cfg->fbheight * - (cfg->fbwidth - cfg->width - cfg->owidth)) { + if (size <= inq->fbheight * + (inq->fbwidth - inq->width - inq->owidth)) { bzero(&a, sizeof(a)); a.flags.flags = STI_UNPMVF_WAIT; a.in.fg_colour = STI_COLOUR_WHITE; a.in.bg_colour = STI_COLOUR_BLACK; a.in.font_addr = scr->scr_romfont; - scr->scr_fontmaxcol = cfg->fbheight / fp->height; - scr->scr_fontbase = cfg->width + cfg->owidth; + scr->scr_fontmaxcol = inq->fbheight / fp->height; + scr->scr_fontbase = inq->width + inq->owidth; for (uc = fp->first; uc <= fp->last; uc++) { a.in.x = ((uc - fp->first) / scr->scr_fontmaxcol) * fp->width + scr->scr_fontbase; @@ -969,7 +1020,15 @@ sti_init(struct sti_screen *scr, int mode) printf("sti_init,%p(%x, %p, %p, %p)\n", rom->init, a.flags.flags, &a.in, &a.out, &scr->scr_cfg); #endif + /* + * Make the ROM visible during initialization, some devices + * look for various data into their ROM image. + */ + if (rom->rom_enable) + STI_ENABLE_ROM(rom->rom_softc); (*rom->init)(&a.flags, &a.in, &a.out, &scr->scr_cfg); + if (rom->rom_enable) + STI_DISABLE_ROM(rom->rom_softc); if (a.out.text_planes != a.in.text_planes) return (-1); /* not colliding with sti errno values */ return (a.out.errno); diff --git a/sys/dev/ic/stireg.h b/sys/dev/ic/stireg.h index a0c5bf5e7..46282c720 100644 --- a/sys/dev/ic/stireg.h +++ b/sys/dev/ic/stireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $ */ +/* $OpenBSD: stireg.h,v 1.15 2024/08/17 08:45:22 miod Exp $ */ /* * Copyright (c) 2000 Michael Shalayeff @@ -29,8 +29,6 @@ #ifndef _IC_STIREG_H_ #define _IC_STIREG_H_ -/* #define STIDEBUG */ - #define STI_REGION_MAX 8 #define STI_MONITOR_MAX 256 #define STI_DEVNAME_LEN 32 @@ -134,6 +132,7 @@ struct sti_dd { #define STI_DD_SUMMIT 0x2FC1066B /* Visualize FX2, FX4, FX6 */ #define STI_DD_PINNACLE 0x35ACDA16 /* Visualize FXe */ #define STI_DD_LEGO 0x35ACDA30 /* Visualize FX5, FX10 */ +#define STI_DD_FIREGL 0x3BA8F544 /* FireGL-UX */ u_int32_t dd_fntaddr; /* 0x10 font start address */ u_int32_t dd_maxst; /* 0x14 max state storage */ u_int32_t dd_romend; /* 0x18 rom last address */ @@ -157,6 +156,7 @@ struct sti_dd { u_int8_t dd_ebussup; /* 0x37 extended bus support */ #define STI_EBUSSUPPORT_DMA 0x01 /* supports dma */ #define STI_EBUSSUPPORT_PIOLOCK 0x02 /* no implicit locking for dma */ +#define STI_EBUSSUPPORT_GVID 0x04 /* requires gvid callback */ u_int8_t dd_altcodet; /* 0x38 alternate code type */ #define STI_ALTCODE_UNKNOWN 0x00 #define STI_ALTCODE_PA64 0x01 /* alt code is in pa64 */ @@ -228,7 +228,15 @@ typedef struct sti_ecfg { u_int16_t power; /* power dissipation Watts */ u_int32_t freq_ref; u_int32_t *addr; /* memory block of size dd_stimemreq */ - void *future; + union { + struct { + int32_t (*gvid_cmd)(void *, ...); + void *gvid_cmd_arg; + u_int32_t pci_id; + void *future; + } g; + void *future; + } future; } __packed *sti_ecfg_t; typedef struct sti_cfg { diff --git a/sys/dev/ic/stivar.h b/sys/dev/ic/stivar.h index e694d4c5c..117383116 100644 --- a/sys/dev/ic/stivar.h +++ b/sys/dev/ic/stivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stivar.h,v 1.28 2024/05/29 00:48:15 jsg Exp $ */ +/* $OpenBSD: stivar.h,v 1.29 2024/08/17 08:45:22 miod Exp $ */ /* * Copyright (c) 2000-2003 Michael Shalayeff @@ -47,22 +47,16 @@ struct sti_rom { struct sti_dd rom_dd; /* in word format */ u_int8_t *rom_code; + int rom_enable; + /* * ROM-provided function pointers */ sti_init_t init; - sti_mgmt_t mgmt; sti_unpmv_t unpmv; sti_blkmv_t blkmv; - sti_test_t test; - sti_exhdl_t exhdl; sti_inqconf_t inqconf; sti_scment_t scment; - sti_dmac_t dmac; - sti_flowc_t flowc; - sti_utiming_t utiming; - sti_pmgr_t pmgr; - sti_util_t util; }; /* diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h index 38a424f16..92ad570c2 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h @@ -1487,9 +1487,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); +void amdgpu_choose_low_power_state(struct amdgpu_device *adev); #else static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; } +static inline void amdgpu_choose_low_power_state(struct amdgpu_device *adev) { } #endif #if defined(CONFIG_DRM_AMD_DC) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c index f2124826d..ddf9850f6 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c @@ -1519,6 +1519,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) if (adev->asic_type < CHIP_RAVEN) return false; +#ifdef __linux__ /* * If ACPI_FADT_LOW_POWER_S0 is not set in the FADT, it is generally * risky to do any special firmware-related preparations for entering @@ -1531,6 +1532,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) "To use suspend-to-idle change the sleep mode in BIOS setup.\n"); return false; } +#endif #if !IS_ENABLED(CONFIG_AMD_PMC) dev_err_once(adev->dev, @@ -1541,4 +1543,19 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) #endif /* CONFIG_AMD_PMC */ } +/** + * amdgpu_choose_low_power_state + * + * @adev: amdgpu_device_pointer + * + * Choose the target low power state for the GPU + */ +void amdgpu_choose_low_power_state(struct amdgpu_device *adev) +{ + if (amdgpu_acpi_is_s0ix_active(adev)) + adev->in_s0ix = true; + else if (amdgpu_acpi_is_s3_active(adev)) + adev->in_s3 = true; +} + #endif /* CONFIG_SUSPEND */ diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c index 948b0fe07..2c2bb6035 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c @@ -4221,13 +4221,15 @@ int amdgpu_device_prepare(struct drm_device *dev) struct amdgpu_device *adev = drm_to_adev(dev); int i, r; + amdgpu_choose_low_power_state(adev); + if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) return 0; /* Evict the majority of BOs before starting suspend sequence */ r = amdgpu_device_evict_resources(adev); if (r) - return r; + goto unprepare; flush_delayed_work(&adev->gfx.gfx_off_delay_work); @@ -4238,10 +4240,15 @@ int amdgpu_device_prepare(struct drm_device *dev) continue; r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev); if (r) - return r; + goto unprepare; } return 0; + +unprepare: + adev->in_s0ix = adev->in_s3 = false; + + return r; } /** diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c index f955c84b6..941f9f245 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c @@ -2383,8 +2383,6 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work) } } -#ifdef notyet - static int amdgpu_pmops_prepare(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2477,6 +2475,8 @@ static int amdgpu_pmops_freeze(struct device *dev) return 0; } +#ifdef notyet + static int amdgpu_pmops_thaw(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2491,6 +2491,8 @@ static int amdgpu_pmops_poweroff(struct device *dev) return amdgpu_device_suspend(drm_dev, true); } +#endif + static int amdgpu_pmops_restore(struct device *dev) { struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2498,6 +2500,8 @@ static int amdgpu_pmops_restore(struct device *dev) return amdgpu_device_resume(drm_dev, true); } +#ifdef notyet + static int amdgpu_runtime_idle_check_display(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); @@ -3496,6 +3500,8 @@ amdgpu_attachhook(struct device *self) struct drm_gem_object *obj; struct amdgpu_bo *rbo; + dev_set_drvdata(self, dev); + r = amdgpu_driver_load_kms(adev, adev->flags); if (r) goto out; @@ -3671,15 +3677,23 @@ amdgpu_activate(struct device *self, int act) switch (act) { case DVACT_QUIESCE: rv = config_activate_children(self, act); - amdgpu_device_prepare(dev); - amdgpu_device_suspend(dev, true); + amdgpu_pmops_prepare(self); + if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4) + amdgpu_pmops_freeze(self); + else + amdgpu_pmops_suspend(self); break; case DVACT_SUSPEND: + if (!acpi_softc || acpi_softc->sc_state != ACPI_STATE_S4) + amdgpu_pmops_suspend_noirq(self); break; case DVACT_RESUME: break; case DVACT_WAKEUP: - amdgpu_device_resume(dev, true); + if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4) + amdgpu_pmops_restore(self); + else + amdgpu_pmops_resume(self); rv = config_activate_children(self, act); break; } diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 6c0d74a47..efd5695a5 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -1550,10 +1550,16 @@ drm_activate(struct device *self, int act) switch (act) { case DVACT_QUIESCE: #ifdef CONFIG_ACPI - if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S3) - pm_suspend_target_state = PM_SUSPEND_MEM; - else - pm_suspend_target_state = PM_SUSPEND_TO_IDLE; + if (acpi_softc) { + switch (acpi_softc->sc_state) { + case ACPI_STATE_S0: + pm_suspend_target_state = PM_SUSPEND_TO_IDLE; + break; + case ACPI_STATE_S3: + pm_suspend_target_state = PM_SUSPEND_MEM; + break; + } + } #else pm_suspend_target_state = PM_SUSPEND_TO_IDLE; #endif diff --git a/sys/dev/pci/drm/include/generated/autoconf.h b/sys/dev/pci/drm/include/generated/autoconf.h index 9c8565e78..0c3150cf7 100644 --- a/sys/dev/pci/drm/include/generated/autoconf.h +++ b/sys/dev/pci/drm/include/generated/autoconf.h @@ -36,6 +36,7 @@ #if NACPI > 0 #define CONFIG_ACPI 1 #define CONFIG_ACPI_SLEEP 1 +#define CONFIG_AMD_PMC 1 #endif #endif diff --git a/sys/dev/pci/drm/include/linux/pci.h b/sys/dev/pci/drm/include/linux/pci.h index f0b8e4984..c499772b8 100644 --- a/sys/dev/pci/drm/include/linux/pci.h +++ b/sys/dev/pci/drm/include/linux/pci.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.h,v 1.16 2024/01/16 23:38:13 jsg Exp $ */ +/* $OpenBSD: pci.h,v 1.17 2024/08/16 10:46:46 kettenis Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -524,4 +524,10 @@ pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev) #define PCI_CLASS_ACCELERATOR_PROCESSING \ (PCI_CLASS_ACCELERATOR << 8) +static inline int +pci_device_is_present(struct pci_dev *pdev) +{ + return 1; +} + #endif /* _LINUX_PCI_H_ */ diff --git a/sys/dev/pci/drm/include/linux/pm_runtime.h b/sys/dev/pci/drm/include/linux/pm_runtime.h index 70f839dd1..5a5abf1de 100644 --- a/sys/dev/pci/drm/include/linux/pm_runtime.h +++ b/sys/dev/pci/drm/include/linux/pm_runtime.h @@ -80,4 +80,10 @@ pm_runtime_get_if_active(struct device *dev, bool x) return -EINVAL; } +static inline int +pm_runtime_suspended(struct device *dev) +{ + return 0; +} + #endif diff --git a/sys/dev/pci/dwiic_pci.c b/sys/dev/pci/dwiic_pci.c index 4ef8e8f37..c93649f96 100644 --- a/sys/dev/pci/dwiic_pci.c +++ b/sys/dev/pci/dwiic_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwiic_pci.c,v 1.27 2024/05/24 06:02:53 jsg Exp $ */ +/* $OpenBSD: dwiic_pci.c,v 1.30 2024/08/17 02:31:15 deraadt Exp $ */ /* * Synopsys DesignWare I2C controller * PCI attachment @@ -293,15 +293,14 @@ dwiic_pci_activate(struct device *self, int act) struct dwiic_softc *sc = (struct dwiic_softc *)self; switch (act) { - case DVACT_WAKEUP: + case DVACT_RESUME: + DELAY(10000); /* 10 msec */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPSS_RESETS, (LPSS_RESETS_I2C | LPSS_RESETS_IDMA)); + DELAY(10000); /* 10 msec */ break; } - - dwiic_activate(self, act); - - return 0; + return dwiic_activate(self, act); } void diff --git a/sys/dev/pci/sti_pci.c b/sys/dev/pci/sti_pci.c index cd51403de..10e243b88 100644 --- a/sys/dev/pci/sti_pci.c +++ b/sys/dev/pci/sti_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sti_pci.c,v 1.13 2023/04/13 15:07:43 miod Exp $ */ +/* $OpenBSD: sti_pci.c,v 1.14 2024/08/17 08:45:22 miod Exp $ */ /* * Copyright (c) 2006, 2007, 2023 Miodrag Vallat. @@ -52,6 +52,9 @@ const struct pci_matchid sti_pci_devices[] = { { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4 }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6 }, { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE }, +#ifdef notyet + { PCI_VENDOR_IBM, PCI_PRODUCT_IBM_FIREGL2 } +#endif }; int sti_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int); @@ -267,6 +270,15 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa) bus_space_read_region_1(pa->pa_memt, romh, offs, region_bars, STI_REGION_MAX); for (i = 0; i < STI_REGION_MAX; i++) { + /* + * Region 0 is supposed to always be the ROM. FireGL-UX + * ROM agrees so well that it will report the expansion + * ROM BAR rather than any regular BAR. + * We'll address this later after remapping the ROM. + */ + if (i == 0 && region_bars[i] == PCI_ROM_REG) + continue; + rc = sti_readbar(sc, pa, i, region_bars[i]); if (rc != 0) goto unmap_disable_return; @@ -297,6 +309,16 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa) goto disable_return; } + /* + * Now set up region 0 if we had skipped it earlier. + */ + + if (region_bars[0] == PCI_ROM_REG) { + sc->bases[0] = + (bus_addr_t)bus_space_vaddr(pa->pa_memt, spc->sc_romh) - + (offs - ctx.romoffs); + } + sti_pci_disable_rom(sc); return 0; diff --git a/sys/dev/pci/xhci_pci.c b/sys/dev/pci/xhci_pci.c index 5409588f3..e906f16c8 100644 --- a/sys/dev/pci/xhci_pci.c +++ b/sys/dev/pci/xhci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci_pci.c,v 1.13 2024/05/24 06:02:58 jsg Exp $ */ +/* $OpenBSD: xhci_pci.c,v 1.14 2024/08/17 01:55:03 jsg Exp $ */ /* * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -151,6 +151,11 @@ xhci_pci_attach(struct device *parent, struct device *self, void *aux) PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1400) pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED; break; + case PCI_VENDOR_AMD: + if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_1 || + PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_2) + psc->sc.sc_flags |= XHCI_NOCSS; + break; } /* Map and establish the interrupt. */ diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index e6168ca38..490131401 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.45 2024/08/01 11:13:19 sf Exp $ */ +/* $OpenBSD: if_vio.c,v 1.46 2024/08/16 13:02:44 jan Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -1133,9 +1133,6 @@ vio_rx_offload(struct mbuf *m, struct virtio_net_hdr *hdr) ether_extract_headers(m, &ext); - if (ext.ip4) - SET(m->m_pkthdr.csum_flags, M_IPV4_CSUM_IN_OK); - if (ext.tcp) { SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK); if (ISSET(hdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 75792693b..d7a1fc0c9 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.133 2024/08/15 17:17:05 kettenis Exp $ */ +/* $OpenBSD: xhci.c,v 1.134 2024/08/17 01:55:03 jsg Exp $ */ /* * Copyright (c) 2014-2015 Martin Pieuchot @@ -626,24 +626,25 @@ xhci_suspend(struct xhci_softc *sc) * will prevent the SoC from reaching its lowest idle state. * So save the state here. */ + if ((sc->sc_flags & XHCI_NOCSS) == 0) { + XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */ + hcr = XOREAD4(sc, XHCI_USBSTS); + for (i = 0; i < 100; i++) { + usb_delay_ms(&sc->sc_bus, 1); + hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS; + if (!hcr) + break; + } - XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */ - hcr = XOREAD4(sc, XHCI_USBSTS); - for (i = 0; i < 100; i++) { - usb_delay_ms(&sc->sc_bus, 1); - hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS; - if (!hcr) - break; + if (hcr) { + printf("%s: save state timeout\n", DEVNAME(sc)); + xhci_reset(sc); + return; + } + + sc->sc_saved_state = 1; } - if (hcr) { - printf("%s: save state timeout\n", DEVNAME(sc)); - xhci_reset(sc); - return; - } - - sc->sc_saved_state = 1; - /* Disable interrupts. */ XRWRITE4(sc, XHCI_IMOD(0), 0); XRWRITE4(sc, XHCI_IMAN(0), 0); diff --git a/sys/dev/usb/xhcivar.h b/sys/dev/usb/xhcivar.h index cf1e86feb..884cd5b73 100644 --- a/sys/dev/usb/xhcivar.h +++ b/sys/dev/usb/xhcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xhcivar.h,v 1.15 2024/08/15 17:17:05 kettenis Exp $ */ +/* $OpenBSD: xhcivar.h,v 1.16 2024/08/17 01:55:03 jsg Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -121,6 +121,9 @@ struct xhci_softc { char sc_vendor[16]; /* Vendor string for root hub */ int sc_id_vendor; /* Vendor ID for root hub */ + + int sc_flags; +#define XHCI_NOCSS 0x01 }; int xhci_init(struct xhci_softc *); diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c index f48345329..3176c6e6f 100644 --- a/sys/dev/wscons/wsmux.c +++ b/sys/dev/wscons/wsmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmux.c,v 1.58 2024/05/29 06:39:13 jsg Exp $ */ +/* $OpenBSD: wsmux.c,v 1.59 2024/08/16 12:22:17 miod Exp $ */ /* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */ /* @@ -143,7 +143,7 @@ wsmux_getmux(int n) struct wsmux_softc **new, **old; int i; - if (n >= WSMUX_MAXDEV) + if (n < 0 || n >= WSMUX_MAXDEV) return (NULL); /* Make sure there is room for mux n in the table */ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index a1d145632..fb611534b 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.231 2024/08/11 15:10:53 mvs Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.232 2024/08/16 16:19:03 mpi Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -432,7 +432,7 @@ proc_free(struct proc *p) { crfree(p->p_ucred); pool_put(&proc_pool, p); - nthreads--; + atomic_dec_int(&nthreads); } /* @@ -471,9 +471,7 @@ reaper(void *arg) if (p->p_flag & P_THREAD) { /* Just a thread */ - KERNEL_LOCK(); proc_free(p); - KERNEL_UNLOCK(); } else { struct process *pr = p->p_p; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index d801b2c8e..72b3ad157 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.262 2024/08/11 15:10:53 mvs Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.263 2024/08/16 16:19:03 mpi Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -65,7 +65,7 @@ #include int nprocesses = 1; /* process 0 */ -int nthreads = 1; /* proc 0 */ +int nthreads = 1; /* [a] proc 0 */ struct forkstat forkstat; void fork_return(void *); @@ -307,6 +307,8 @@ struct timeval fork_tfmrate = { 10, 0 }; int fork_check_maxthread(uid_t uid) { + int val; + /* * Although process entries are dynamically created, we still keep * a global limit on the maximum number we will create. We reserve @@ -316,14 +318,15 @@ fork_check_maxthread(uid_t uid) * the variable nthreads is the current number of procs, maxthread is * the limit. */ - if ((nthreads >= maxthread - 5 && uid != 0) || nthreads >= maxthread) { + val = atomic_inc_int_nv(&nthreads); + if ((val > maxthread - 5 && uid != 0) || val > maxthread) { static struct timeval lasttfm; if (ratecheck(&lasttfm, &fork_tfmrate)) tablefull("thread"); + atomic_dec_int(&nthreads); return EAGAIN; } - nthreads++; return 0; } @@ -369,7 +372,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg, if (ratecheck(&lasttfm, &fork_tfmrate)) tablefull("process"); - nthreads--; + atomic_dec_int(&nthreads); return EAGAIN; } nprocesses++; @@ -382,7 +385,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg, if (uid != 0 && count > lim_cur(RLIMIT_NPROC)) { (void)chgproccnt(uid, -1); nprocesses--; - nthreads--; + atomic_dec_int(&nthreads); return EAGAIN; } @@ -390,7 +393,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg, if (uaddr == 0) { (void)chgproccnt(uid, -1); nprocesses--; - nthreads--; + atomic_dec_int(&nthreads); return (ENOMEM); } @@ -547,7 +550,7 @@ thread_fork(struct proc *curp, void *stack, void *tcb, pid_t *tidptr, uaddr = uvm_uarea_alloc(); if (uaddr == 0) { - nthreads--; + atomic_dec_int(&nthreads); return ENOMEM; } diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 1c314806b..4e7a54d23 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.67 2024/08/14 17:52:47 mvs Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.68 2024/08/16 09:20:34 mvs Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -237,14 +237,18 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, protocol = name[1]; for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_protocol == protocol && pr->pr_sysctl) { - size_t savelen = *oldlenp; + size_t savelen; int error; - if ((error = sysctl_vslock(oldp, savelen))) - return (error); + if ((pr->pr_flags & PR_MPSYSCTL) == 0) { + savelen = *oldlenp; + if ((error = sysctl_vslock(oldp, savelen))) + return (error); + } error = (*pr->pr_sysctl)(name + 2, namelen - 2, oldp, oldlenp, newp, newlen); - sysctl_vsunlock(oldp, savelen); + if ((pr->pr_flags & PR_MPSYSCTL) == 0) + sysctl_vsunlock(oldp, savelen); return (error); } diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 6c8d82c2e..ce2131c25 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppp_tty.c,v 1.54 2022/01/02 22:36:04 jsg Exp $ */ +/* $OpenBSD: ppp_tty.c,v 1.55 2024/08/17 09:52:11 denis Exp $ */ /* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */ /* @@ -371,6 +371,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag) bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN); m0->m_data += PPP_HDRLEN; m0->m_len -= PPP_HDRLEN; + m0->m_pkthdr.ph_rtableid = sc->sc_if.if_rdomain; return sc->sc_if.if_output(&sc->sc_if, m0, &dst, NULL); } diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 579522f60..a279775fd 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.107 2024/07/26 14:38:20 bluhm Exp $ */ +/* $OpenBSD: in_proto.c,v 1.108 2024/08/16 09:20:35 mvs Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -354,7 +354,7 @@ const struct protosw inetsw[] = { .pr_type = SOCK_RAW, .pr_domain = &inetdomain, .pr_protocol = IPPROTO_DIVERT, - .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL, .pr_ctloutput = rip_ctloutput, .pr_usrreqs = &divert_usrreqs, .pr_init = divert_init, diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index a78f5e0fb..164d76e45 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -41,17 +41,22 @@ #include +/* + * Locks used to protect data: + * a atomic + */ + struct inpcbtable divbtable; struct cpumem *divcounters; #ifndef DIVERT_SENDSPACE #define DIVERT_SENDSPACE (65536 + 100) #endif -u_int divert_sendspace = DIVERT_SENDSPACE; +u_int divert_sendspace = DIVERT_SENDSPACE; /* [a] */ #ifndef DIVERT_RECVSPACE #define DIVERT_RECVSPACE (65536 + 100) #endif -u_int divert_recvspace = DIVERT_RECVSPACE; +u_int divert_recvspace = DIVERT_RECVSPACE; /* [a] */ #ifndef DIVERTHASHSIZE #define DIVERTHASHSIZE 128 @@ -271,7 +276,8 @@ divert_attach(struct socket *so, int proto, int wait) if (error) return error; - error = soreserve(so, divert_sendspace, divert_recvspace); + error = soreserve(so, atomic_load_int(&divert_sendspace), + atomic_load_int(&divert_recvspace)); if (error) return error; @@ -346,8 +352,6 @@ int divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - int error; - /* All sysctl names at this level are terminal. */ if (namelen != 1) return (ENOTDIR); @@ -356,12 +360,9 @@ divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case DIVERTCTL_STATS: return (divert_sysctl_divstat(oldp, oldlenp, newp)); default: - NET_LOCK(); - error = sysctl_bounded_arr(divertctl_vars, - nitems(divertctl_vars), name, namelen, oldp, oldlenp, newp, - newlen); - NET_UNLOCK(); - return (error); + return (sysctl_bounded_arr(divertctl_vars, + nitems(divertctl_vars), name, namelen, oldp, oldlenp, + newp, newlen)); } /* NOTREACHED */ } diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 2d7343a52..d35cff479 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.117 2024/07/26 14:38:20 bluhm Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.118 2024/08/16 09:20:35 mvs Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -289,7 +289,7 @@ const struct protosw inet6sw[] = { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_DIVERT, - .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &divert6_usrreqs, .pr_init = divert6_init, diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 06111f6d3..dc815d5f8 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -44,17 +44,22 @@ #include +/* + * Locks used to protect data: + * a atomic + */ + struct inpcbtable divb6table; struct cpumem *div6counters; #ifndef DIVERT_SENDSPACE #define DIVERT_SENDSPACE (65536 + 100) #endif -u_int divert6_sendspace = DIVERT_SENDSPACE; +u_int divert6_sendspace = DIVERT_SENDSPACE; /* [a] */ #ifndef DIVERT_RECVSPACE #define DIVERT_RECVSPACE (65536 + 100) #endif -u_int divert6_recvspace = DIVERT_RECVSPACE; +u_int divert6_recvspace = DIVERT_RECVSPACE; /* [a] */ #ifndef DIVERTHASHSIZE #define DIVERTHASHSIZE 128 @@ -279,7 +284,8 @@ divert6_attach(struct socket *so, int proto, int wait) if (error) return (error); - error = soreserve(so, divert6_sendspace, divert6_recvspace); + error = soreserve(so, atomic_load_int(&divert6_sendspace), + atomic_load_int(&divert6_recvspace)); if (error) return (error); @@ -322,8 +328,6 @@ int divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - int error; - /* All sysctl names at this level are terminal. */ if (namelen != 1) return (ENOTDIR); @@ -332,12 +336,9 @@ divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, case DIVERT6CTL_STATS: return (divert6_sysctl_div6stat(oldp, oldlenp, newp)); default: - NET_LOCK(); - error = sysctl_bounded_arr(divert6ctl_vars, + return (sysctl_bounded_arr(divert6ctl_vars, nitems(divert6ctl_vars), name, namelen, oldp, oldlenp, - newp, newlen); - NET_UNLOCK(); - return (error); + newp, newlen)); } /* NOTREACHED */ } diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index b03d4a5f4..74e7fed74 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.126 2024/05/01 13:15:59 jsg Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.127 2024/08/17 07:02:13 jsg Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -1038,12 +1038,12 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) return 0; else if (error != 0) - goto nfsmout; + return error; fhp = &nfh.fh_generic; if (nfsm_srvmtofh2(&info, fhp) != 0) - goto nfsmout; + return error; if (nfsm_srvnamesiz(&info, &len) != 0) - goto nfsmout; + return error; if (error) { if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) return 0; @@ -1325,12 +1325,12 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) return 0; else if (error != 0) - goto nfsmout; + return error; fhp = &nfh.fh_generic; if (nfsm_srvmtofh2(&info, fhp) != 0) - goto nfsmout; + return error; if (nfsm_srvnamesiz(&info, &len) != 0) - goto nfsmout; + return error; if (error) { if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) return 0; @@ -1598,12 +1598,12 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) return 0; else if (error != 0) - goto nfsmout; + return error; ffhp = &fnfh.fh_generic; if (nfsm_srvmtofh2(&info, ffhp) != 0) - goto nfsmout; + return error; if (nfsm_srvnamesiz(&info, &len) != 0) - goto nfsmout; + return error; if (error) { if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) return 0; @@ -1757,12 +1757,6 @@ out1: nfsmout: if (fdirp) vrele(fdirp); - if (tdirp) - vrele(tdirp); - if (tond.ni_cnd.cn_nameiop) { - vrele(tond.ni_startdir); - pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf); - } if (fromnd.ni_cnd.cn_nameiop) { if (fromnd.ni_startdir) vrele(fromnd.ni_startdir); @@ -1928,12 +1922,12 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) return 0; else if (error != 0) - goto nfsmout; + return error; fhp = &nfh.fh_generic; if (nfsm_srvmtofh2(&info, fhp) != 0) - goto nfsmout; + return error; if (nfsm_srvnamesiz(&info, &len) != 0) - goto nfsmout; + return error; if (error) { if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) return 0; @@ -2088,12 +2082,12 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0) return 0; else if (error != 0) - goto nfsmout; + return error; fhp = &nfh.fh_generic; if (nfsm_srvmtofh2(&info, fhp) != 0) - goto nfsmout; + return error; if (nfsm_srvnamesiz(&info, &len) != 0) - goto nfsmout; + return error; if (error) { if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0) return 0; diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 9d5a0f370..22364cf72 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.67 2024/07/12 19:50:35 bluhm Exp $ */ +/* $OpenBSD: protosw.h,v 1.68 2024/08/16 09:20:35 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -131,6 +131,7 @@ struct protosw { #define PR_SPLICE 0x0040 /* socket splicing is possible */ #define PR_MPINPUT 0x0080 /* input runs with shared netlock */ #define PR_MPSOCKET 0x0100 /* socket uses shared netlock */ +#define PR_MPSYSCTL 0x0200 /* mp-safe sysctl(2) handler */ /* * The arguments to usrreq are: diff --git a/usr.bin/login/login.1 b/usr.bin/login/login.1 index 6fc7cce10..0605869a1 100644 --- a/usr.bin/login/login.1 +++ b/usr.bin/login/login.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: login.1,v 1.33 2020/02/08 01:09:58 jsg Exp $ +.\" $OpenBSD: login.1,v 1.34 2024/08/16 16:11:06 florian Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)login.1 8.2 (Berkeley) 5/5/94 .\" -.Dd $Mdocdate: February 8 2020 $ +.Dd $Mdocdate: August 16 2024 $ .Dt LOGIN 1 .Os .Sh NAME @@ -228,7 +228,6 @@ makes login quieter .Xr chpass 1 , .Xr passwd 1 , .Xr su 1 , -.Xr telnet 1 , .Xr readpassphrase 3 , .Xr setusercontext 3 , .Xr fbtab 5 , diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c index f55eabcad..c407170cc 100644 --- a/usr.bin/rpcinfo/rpcinfo.c +++ b/usr.bin/rpcinfo/rpcinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpcinfo.c,v 1.18 2024/08/12 06:19:24 florian Exp $ */ +/* $OpenBSD: rpcinfo.c,v 1.19 2024/08/16 16:00:30 florian Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -50,6 +50,7 @@ #include #include #include +#include #define MAXHOSTLEN 256 @@ -94,6 +95,15 @@ main(int argc, char *argv[]) function = NONE; portnum = 0; errflg = 0; + + if (unveil("/etc/rpc", "r") == -1) + err(1, "unveil /"); + if (unveil(NULL, NULL) == -1) + err(1, "unveil"); + + if (pledge("stdio inet dns rpath", NULL) == -1) + err(1, "pledge"); + while ((c = getopt(argc, argv, "ptubdsn:")) != -1) { switch (c) { diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c index b6d6f17e3..9b4bcfeea 100644 --- a/usr.bin/ssh/servconf.c +++ b/usr.bin/ssh/servconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: servconf.c,v 1.412 2024/07/25 23:44:01 djm Exp $ */ +/* $OpenBSD: servconf.c,v 1.413 2024/08/17 08:23:04 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved @@ -1857,6 +1857,7 @@ process_server_config_line_depth(ServerOptions *options, char *line, xasprintf(&options->subsystem_args[options->num_subsystems], "%s%s%s", arg, *arg2 == '\0' ? "" : " ", arg2); free(arg2); + free(arg); argv_consume(&ac); options->num_subsystems++; break; diff --git a/usr.bin/ssh/ssh-keygen.1 b/usr.bin/ssh/ssh-keygen.1 index df6803fd9..06f0555a4 100644 --- a/usr.bin/ssh/ssh-keygen.1 +++ b/usr.bin/ssh/ssh-keygen.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ssh-keygen.1,v 1.232 2024/06/17 13:50:18 naddy Exp $ +.\" $OpenBSD: ssh-keygen.1,v 1.233 2024/08/17 08:35:04 djm Exp $ .\" .\" Author: Tatu Ylonen .\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -35,7 +35,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 17 2024 $ +.Dd $Mdocdate: August 17 2024 $ .Dt SSH-KEYGEN 1 .Os .Sh NAME @@ -581,7 +581,7 @@ Specifies the type of key to create. The possible values are .Dq ecdsa , .Dq ecdsa-sk , -.Dq ed25519 , +.Dq ed25519 (the default), .Dq ed25519-sk , or .Dq rsa . @@ -594,7 +594,7 @@ The available RSA signature variants are .Dq rsa-sha2-256 , and .Dq rsa-sha2-512 -(the default). +(the default for RSA keys). .It Fl U When used in combination with .Fl s diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c index 64d0d0d75..e2037b2ba 100644 --- a/usr.bin/ssh/sshd.c +++ b/usr.bin/ssh/sshd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshd.c,v 1.609 2024/06/27 23:01:15 djm Exp $ */ +/* $OpenBSD: sshd.c,v 1.610 2024/08/17 08:09:50 djm Exp $ */ /* * Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved. * Copyright (c) 2002 Niels Provos. All rights reserved. @@ -241,7 +241,7 @@ child_register(int pipefd, int sockfd) } else { laddr = get_local_ipaddr(sockfd); raddr = get_peer_ipaddr(sockfd); - xasprintf(&child->id, "connection from %s to %s", laddr, raddr); + xasprintf(&child->id, "connection from %s to %s", raddr, laddr); } free(laddr); free(raddr); diff --git a/usr.sbin/nsd/nsd.8.in b/usr.sbin/nsd/nsd.8.in index d0ea7a2e6..66531b88e 100644 --- a/usr.sbin/nsd/nsd.8.in +++ b/usr.sbin/nsd/nsd.8.in @@ -153,8 +153,7 @@ default is 100. .B \-P\fI pidfile Use the specified .I pidfile -instead of the platform specific default, which is mostly -.IR @pidfile@ . +instead of the platform specific default. If a .B zonesdir: is specified in the config file, this path can be relative to that @@ -214,9 +213,6 @@ SIGUSR1 Dump BIND8\-style statistics into the log. Ignored otherwise. .SH "FILES" .TP -@pidfile@ -the process id of the name server. -.TP @nsdconfigfile@ default .B NSD diff --git a/usr.sbin/nsd/nsd.conf.5.in b/usr.sbin/nsd/nsd.conf.5.in index 357b8df0a..ad0950dce 100644 --- a/usr.sbin/nsd/nsd.conf.5.in +++ b/usr.sbin/nsd/nsd.conf.5.in @@ -40,9 +40,6 @@ zonelistfile: @zonelistfile@ logfile: @logfile@ .RE .RS 5 -pidfile: @pidfile@ -.RE -.RS 5 xfrdfile: @xfrdfile@ .RE .TP @@ -321,8 +318,7 @@ Preferred EDNS buffer size for IPv4. Default 1232. Preferred EDNS buffer size for IPv6. Default 1232. .TP .B pidfile:\fR -Use the pid file instead of the platform specific default, usually -.IR @pidfile@. +Use the pid file instead of the platform specific default. Same as command-line option .BR \-P . With "" there is no pidfile, for some startup management setups, diff --git a/usr.sbin/pppd/chat/chat.c b/usr.sbin/pppd/chat/chat.c index 874452fe6..386404eb5 100644 --- a/usr.sbin/pppd/chat/chat.c +++ b/usr.sbin/pppd/chat/chat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chat.c,v 1.37 2024/08/10 05:32:28 jsg Exp $ */ +/* $OpenBSD: chat.c,v 1.38 2024/08/17 15:42:20 denis Exp $ */ /* * Chat -- a program for automatic session establishment (i.e. dial @@ -172,7 +172,6 @@ int clear_report_next = 0; int say_next = 0, hup_next = 0; -void *dup_mem(void *b, size_t c); void usage(void); void logmsg(const char *fmt, ...); void fatal(int code, const char *fmt, ...); @@ -204,22 +203,6 @@ int vfmtmsg(char *, int, const char *, va_list); /* vsnprintf++ */ int main(int, char *[]); -void * -dup_mem(void *b, size_t c) -{ - void *ans = malloc (c); - if (!ans) - fatal(2, "memory error!"); - - memcpy (ans, b, c); - return ans; -} - -void *copy_of (char *s) -{ - return dup_mem (s, strlen (s) + 1); -} - /* * chat [ -v ] [-T number] [-U number] [ -t timeout ] [ -f chat-file ] \ * [ -r report-file ] \ @@ -257,7 +240,8 @@ main(int argc, char **argv) break; case 'f': - chat_file = strdup(optarg); + if ((chat_file = strdup(optarg)) == NULL) + fatal(2, "memory error!"); break; case 't': @@ -267,7 +251,8 @@ main(int argc, char **argv) case 'r': if (report_fp != NULL) fclose (report_fp); - report_file = copy_of (optarg); + if ((report_file = strdup(optarg)) == NULL) + fatal(2, "memory error!"); report_fp = fopen (report_file, "a"); if (report_fp != NULL) { if (verbose) @@ -278,11 +263,14 @@ main(int argc, char **argv) break; case 'T': - phone_num = strdup(optarg); + if ((phone_num = strdup(optarg)) == NULL) + fatal(2, "memory error!"); break; case 'U': phone_num2 = strdup(optarg); + if ((phone_num2 = strdup(optarg)) == NULL) + fatal(2, "memory error!"); break; case ':': diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index f3e0895c9..8e41f159b 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys-bsd.c,v 1.35 2024/08/10 05:32:28 jsg Exp $ */ +/* $OpenBSD: sys-bsd.c,v 1.36 2024/08/17 09:52:11 denis Exp $ */ /* * sys-bsd.c - System-dependent procedures for setting up @@ -1031,6 +1031,23 @@ cifaddr(int u, u_int32_t o, u_int32_t h) return 1; } +/* + * getrtableid - return routing table id of ppp interface + */ +int +getrtableid(void) +{ + struct ifreq ifr; + int tableid = 0; + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + if (ioctl(sockfd, SIOCGIFRDOMAIN, (caddr_t) &ifr) == 0) + tableid = ifr.ifr_rdomainid; + + return tableid; +} + /* * sifdefaultroute - assign a default route through the address given. */ @@ -1073,6 +1090,7 @@ dodefaultroute(u_int32_t g, int cmd) rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE; rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY; rtmsg.hdr.rtm_version = RTM_VERSION; + rtmsg.hdr.rtm_tableid = getrtableid(); rtmsg.hdr.rtm_seq = ++rtm_seq; rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; rtmsg.dst.sin_len = sizeof(rtmsg.dst); diff --git a/usr.sbin/radiusd/radiusd_eap2mschap.c b/usr.sbin/radiusd/radiusd_eap2mschap.c index 7e38b295c..236f7785c 100644 --- a/usr.sbin/radiusd/radiusd_eap2mschap.c +++ b/usr.sbin/radiusd/radiusd_eap2mschap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_eap2mschap.c,v 1.2 2024/07/17 11:19:27 yasuoka Exp $ */ +/* $OpenBSD: radiusd_eap2mschap.c,v 1.3 2024/08/16 09:52:16 yasuoka Exp $ */ /* * Copyright (c) 2024 Internet Initiative Japan Inc. @@ -74,8 +74,12 @@ main(int argc, char *argv[]) module_start(eap2mschap.base); event_loop(0); + module_destroy(eap2mschap.base); + event_loop(0); + event_base_free(NULL); + exit(EXIT_SUCCESS); } @@ -140,10 +144,14 @@ eap2mschap_stop(void *ctx) evtimer_del(&self->ev_eapt); - RB_FOREACH_SAFE(req, access_reqt, &self->eapt, reqt) + RB_FOREACH_SAFE(req, access_reqt, &self->eapt, reqt) { + RB_REMOVE(access_reqt, &self->eapt, req); access_request_free(req); - TAILQ_FOREACH_SAFE(req, &self->reqq, next, reqt) + } + TAILQ_FOREACH_SAFE(req, &self->reqq, next, reqt) { + TAILQ_REMOVE(&self->reqq, req, next); access_request_free(req); + } } void diff --git a/usr.sbin/radiusd/radiusd_ipcp.c b/usr.sbin/radiusd/radiusd_ipcp.c index 3410aa412..27cd3c4bd 100644 --- a/usr.sbin/radiusd/radiusd_ipcp.c +++ b/usr.sbin/radiusd/radiusd_ipcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_ipcp.c,v 1.9 2024/08/14 04:47:08 yasuoka Exp $ */ +/* $OpenBSD: radiusd_ipcp.c,v 1.12 2024/08/16 09:54:21 yasuoka Exp $ */ /* * Copyright (c) 2024 Internet Initiative Japan Inc. @@ -191,6 +191,7 @@ static void ipcp_put_db(struct module_ipcp *, struct assigned_ipv4 *); static void ipcp_del_db(struct module_ipcp *, struct assigned_ipv4 *); static void ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *, int, struct assigned_ipv4 *); +static void ipcp_update_time(struct module_ipcp *); static void ipcp_on_timer(int, short, void *); static void ipcp_schedule_timer(struct module_ipcp *); static void ipcp_dae_send_disconnect_request(struct assigned_ipv4 *); @@ -252,6 +253,7 @@ main(int argc, char *argv[]) ipcp_fini(&module_ipcp); event_loop(0); + event_base_free(NULL); exit(EXIT_SUCCESS); } @@ -267,6 +269,7 @@ ipcp_init(struct module_ipcp *self) TAILQ_INIT(&self->daes); self->seq = 1; self->no_session_timeout = true; + ipcp_update_time(self); } void @@ -277,6 +280,7 @@ ipcp_start(void *ctx) struct module_ipcp_dae *dae; int sock; + ipcp_update_time(self); if (self->start_wait == 0) self->start_wait = RADIUSD_IPCP_START_WAIT; @@ -322,6 +326,7 @@ ipcp_stop(void *ctx) struct module_ipcp *self = ctx; struct module_ipcp_dae *dae; + ipcp_update_time(self); /* stop the sockets for DAE */ TAILQ_FOREACH(dae, &self->daes, next) { if (dae->sock >= 0) { @@ -341,11 +346,14 @@ ipcp_fini(struct module_ipcp *self) struct user *user, *usert; struct module_ipcp_ctrlconn *ctrl, *ctrlt; struct module_ipcp_dae *dae, *daet; + struct ipcp_address *addr, *addrt; RB_FOREACH_SAFE(assign, assigned_ipv4_tree, &self->ipv4s, assignt) ipcp_ipv4_release(self, assign); - RB_FOREACH_SAFE(user, user_tree, &self->users, usert) + RB_FOREACH_SAFE(user, user_tree, &self->users, usert) { + RB_REMOVE(user_tree, &self->users, user); free(user); + } TAILQ_FOREACH_SAFE(ctrl, &self->ctrls, next, ctrlt) free(ctrl); TAILQ_FOREACH_SAFE(dae, &self->daes, next, daet) { @@ -355,6 +363,8 @@ ipcp_fini(struct module_ipcp *self) } free(dae); } + TAILQ_FOREACH_SAFE(addr, &self->addrs, next, addrt) + free(addr); if (evtimer_pending(&self->ev_timer, NULL)) evtimer_del(&self->ev_timer); module_destroy(self->base); @@ -556,6 +566,7 @@ ipcp_dispatch_control(void *ctx, struct imsg *imsg) struct radiusctl_client *client; const char *cause; + ipcp_update_time(self); datalen = imsg->hdr.len - IMSG_HEADER_SIZE; switch (imsg->hdr.type) { case IMSG_RADIUSD_MODULE_CTRL_UNBIND: @@ -711,7 +722,7 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen, struct user *user = NULL; struct assigned_ipv4 *assigned = NULL, *assign; - clock_gettime(CLOCK_BOOTTIME, &self->uptime); + ipcp_update_time(self); if ((radres = radius_convert_packet(res, reslen)) == NULL) { log_warn("%s: radius_convert_packet() failed", __func__); @@ -1002,7 +1013,7 @@ ipcp_accounting_request(void *ctx, u_int q_id, const u_char *pkt, stat; struct module_ipcp_dae *dae; - clock_gettime(CLOCK_BOOTTIME, &self->uptime); + ipcp_update_time(self); if ((radpkt = radius_convert_packet(pkt, pktlen)) == NULL) { log_warn("%s: radius_convert_packet() failed", __func__); @@ -1466,12 +1477,18 @@ ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *dump, int idx, /*********************************************************************** * Timer ***********************************************************************/ +void +ipcp_update_time(struct module_ipcp *self) +{ + clock_gettime(CLOCK_BOOTTIME, &self->uptime); +} + void ipcp_on_timer(int fd, short ev, void *ctx) { struct module_ipcp *self = ctx; - clock_gettime(CLOCK_BOOTTIME, &self->uptime); + ipcp_update_time(self); ipcp_schedule_timer(self); } @@ -1573,11 +1590,15 @@ ipcp_dae_request_on_timeout(int fd, short ev, void *ctx) { struct assigned_ipv4 *assign = ctx; char buf[80]; + struct radiusctl_client *client; if (assign->dae_ntry >= (int)nitems(dae_request_timeouts)) { log_warnx("No answer for Disconnect-Request seq=%u from %s", assign->seq, print_addr((struct sockaddr *) &assign->dae->nas_addr, buf, sizeof(buf))); + TAILQ_FOREACH(client, &assign->dae_clients, entry) + module_imsg_compose(assign->dae->ipcp->base, IMSG_NG, + client->peerid, 0, -1, NULL, 0); ipcp_dae_reset_request(assign); } else ipcp_dae_send_disconnect_request(assign); @@ -1596,6 +1617,8 @@ ipcp_dae_on_event(int fd, short ev, void *ctx) const char *cause = ""; struct radiusctl_client *client; + ipcp_update_time(self); + if ((ev & EV_READ) == 0) return; @@ -1856,7 +1879,7 @@ radius_error_cause_string(unsigned val) { RADIUS_ERROR_CAUSE_UNSUPPORTED_EXTENSION, "Unsupported Extension" }, { RADIUS_ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE, - "Invalid Attribute Valu" }, + "Invalid Attribute Value" }, { RADIUS_ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED, "Administratively Prohibited" }, { RADIUS_ERROR_CAUSE_REQUEST_NOT_ROUTABLE, @@ -1930,9 +1953,9 @@ parse_addr(const char *str0, int af, struct sockaddr *sa, socklen_t salen) free(str); return (-1); } + free(str); if (salen < ai->ai_addrlen) { freeaddrinfo(ai); - free(str); return (-1); } memcpy(sa, ai->ai_addr, ai->ai_addrlen); diff --git a/usr.sbin/radiusd/radiusd_local.h b/usr.sbin/radiusd/radiusd_local.h index d58c6c7c6..2a04492cc 100644 --- a/usr.sbin/radiusd/radiusd_local.h +++ b/usr.sbin/radiusd/radiusd_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_local.h,v 1.17 2024/08/14 07:04:54 yasuoka Exp $ */ +/* $OpenBSD: radiusd_local.h,v 1.18 2024/08/16 09:45:52 yasuoka Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -138,7 +138,6 @@ struct radius_query { struct radiusd_authentication *authen; RADIUS_PACKET *req; RADIUS_PACKET *res; - int req_modified; char username[256]; /* original username */ TAILQ_ENTRY(radius_query) next; struct radiusd_module_ref *deco; diff --git a/usr.sbin/radiusd/radiusd_radius.c b/usr.sbin/radiusd/radiusd_radius.c index 99a6798fd..5ca35b84b 100644 --- a/usr.sbin/radiusd/radiusd_radius.c +++ b/usr.sbin/radiusd/radiusd_radius.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_radius.c,v 1.21 2024/07/01 03:17:00 yasuoka Exp $ */ +/* $OpenBSD: radiusd_radius.c,v 1.22 2024/08/16 09:52:16 yasuoka Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -139,6 +139,7 @@ main(int argc, char *argv[]) event_loop(0); module_destroy(module_radius.base); + event_base_free(NULL); exit(EXIT_SUCCESS); } diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index 395bc39ef..0583ef953 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.78 2024/05/18 06:45:00 jsg Exp $ */ +/* $OpenBSD: main.c,v 1.79 2024/08/17 20:50:06 mlarkin Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -743,7 +743,7 @@ ctl_convert(const char *srcfile, const char *dstfile, int dsttype, size_t dstsiz int ctl_status(struct parse_result *res, int argc, char *argv[]) { - char ch; + int ch; while ((ch = getopt(argc, argv, "r")) != -1) { switch (ch) {