From 38dbdec4129eedf906b21dd4513ae7bb2a6091b3 Mon Sep 17 00:00:00 2001 From: purplerain Date: Fri, 22 Dec 2023 02:30:11 +0000 Subject: [PATCH] sync with OpenBSD -current --- lib/libcrypto/evp/evp_enc.c | 6 +- lib/libcrypto/man/ASN1_STRING_TABLE_get.3 | 8 +- lib/libcrypto/man/EVP_PKCS82PKEY.3 | 7 +- lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 | 19 +--- lib/libcrypto/man/EVP_PKEY_asn1_new.3 | 56 ++--------- lib/libcrypto/man/EVP_PKEY_set1_RSA.3 | 10 +- sbin/dump/dumprmt.c | 4 +- sbin/dump/itime.c | 8 +- share/man/man4/ugold.4 | 5 +- share/man/man9/Makefile | 5 +- share/man/man9/strnstr.9 | 90 ++++++++++++++++++ sys/conf/files | 3 +- .../pci/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 6 -- sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c | 2 - .../pci/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 15 --- sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c | 3 +- sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c | 28 ++++++ .../amd/display/modules/power/power_helpers.c | 2 + sys/dev/pci/drm/i915/display/intel_fb.c | 16 +++- sys/dev/usb/ugold.c | 10 +- sys/kern/makesyscalls.sh | 95 ++++++++----------- sys/kern/syscalls.master | 4 +- sys/lib/libkern/libkern.h | 3 +- sys/lib/libkern/strnstr.c | 62 ++++++++++++ usr.bin/cu/cu.c | 4 +- usr.sbin/snmpd/application.c | 4 +- usr.sbin/snmpd/application_agentx.c | 9 +- usr.sbin/snmpd/application_blocklist.c | 10 +- usr.sbin/snmpd/application_internal.c | 10 +- usr.sbin/snmpd/ax.c | 3 +- usr.sbin/snmpd/ax.h | 5 +- usr.sbin/snmpd/log.c | 4 +- usr.sbin/snmpd/mib.h | 8 +- usr.sbin/snmpd/parse.y | 31 +++--- usr.sbin/snmpd/proc.c | 6 +- usr.sbin/snmpd/smi.c | 35 +++---- usr.sbin/snmpd/smi.h | 8 +- usr.sbin/snmpd/snmp.h | 3 +- usr.sbin/snmpd/snmpd.c | 19 +--- usr.sbin/snmpd/snmpd.h | 24 ++--- usr.sbin/snmpd/snmpe.c | 22 ++--- usr.sbin/snmpd/snmpe.h | 5 +- usr.sbin/snmpd/trap.c | 23 ++--- usr.sbin/snmpd/traphandler.c | 19 ++-- usr.sbin/snmpd/usm.c | 32 +++---- usr.sbin/snmpd/util.c | 12 +-- 46 files changed, 425 insertions(+), 338 deletions(-) create mode 100644 share/man/man9/strnstr.9 create mode 100644 sys/lib/libkern/strnstr.c diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c index df3ede34a..d8c01cdc4 100644 --- a/lib/libcrypto/evp/evp_enc.c +++ b/lib/libcrypto/evp/evp_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_enc.c,v 1.73 2023/12/20 14:15:19 tb Exp $ */ +/* $OpenBSD: evp_enc.c,v 1.74 2023/12/21 20:50:43 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -601,7 +601,7 @@ EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) keylen, NULL); if (c->key_len == keylen) return 1; - if ((keylen > 0) && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { + if (keylen > 0 && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { c->key_len = keylen; return 1; } @@ -654,7 +654,7 @@ EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) { - if ((in == NULL) || (in->cipher == NULL)) { + if (in == NULL || in->cipher == NULL) { EVPerror(EVP_R_INPUT_NOT_INITIALIZED); return 0; } diff --git a/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 b/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 index d3b025470..2bf8831c1 100644 --- a/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 +++ b/lib/libcrypto/man/ASN1_STRING_TABLE_get.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_STRING_TABLE_get.3,v 1.3 2023/12/16 19:14:56 tb Exp $ +.\" $OpenBSD: ASN1_STRING_TABLE_get.3,v 1.4 2023/12/21 21:23:37 tb Exp $ .\" checked up to: .\" OpenSSL ASN1_STRING_TABLE_add.pod 7b608d08 Jul 27 01:18:50 2017 +0800 .\" @@ -16,10 +16,14 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 16 2023 $ +.Dd $Mdocdate: December 21 2023 $ .Dt ASN1_STRING_TABLE_GET 3 .Os .Sh NAME +.\" .Nm ASN1_STRING_TABLE_add0 and +.\" .Nm ASN1_STRING_TABLE_cleanup are intentionally undocumented +.\" because they will be removed in the next major bump +.\" .Dv STABLE_FLAGS_MALLOC is intentionally undocumented because it is unused .Nm ASN1_STRING_TABLE_get .Nd retrieve an entry from the global ASN.1 string table .Sh SYNOPSIS diff --git a/lib/libcrypto/man/EVP_PKCS82PKEY.3 b/lib/libcrypto/man/EVP_PKCS82PKEY.3 index 5fed846fe..0f6667388 100644 --- a/lib/libcrypto/man/EVP_PKCS82PKEY.3 +++ b/lib/libcrypto/man/EVP_PKCS82PKEY.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.1 2021/10/25 13:48:12 schwarze Exp $ +.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.2 2023/12/21 21:32:01 tb Exp $ .\" .\" Copyright (c) 2021 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 25 2021 $ +.Dd $Mdocdate: December 21 2023 $ .Dt EVP_PKCS82PKEY 3 .Os .Sh NAME @@ -40,8 +40,6 @@ structure representing the private key contained in .Fa pkey . .Pp Supported algorithms include DH, DSA, EC, GOST2001, and RSA. -Application programs can add additional algorithms using -.Xr EVP_PKEY_asn1_add0 3 . .Sh RETURN VALUES These functions return a newly allocated object or .Dv NULL @@ -51,7 +49,6 @@ or .Fa pkey is unsupported or if memory allocation, decoding, or encoding fails. .Sh SEE ALSO -.Xr EVP_PKEY_asn1_add0 3 , .Xr EVP_PKEY_base_id 3 , .Xr EVP_PKEY_new 3 , .Xr PKCS8_pkey_set0 3 , diff --git a/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 b/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 index 9f272a242..85a6471ae 100644 --- a/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 +++ b/lib/libcrypto/man/EVP_PKEY_asn1_get_count.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.7 2023/09/13 13:55:50 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.8 2023/12/21 21:32:01 tb Exp $ .\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 13 2023 $ +.Dd $Mdocdate: December 21 2023 $ .Dt EVP_PKEY_ASN1_GET_COUNT 3 .Os .Sh NAME @@ -111,7 +111,6 @@ .Sh DESCRIPTION .Fn EVP_PKEY_asn1_get_count returns the number of public key ASN.1 methods available. -It includes standard methods and any methods added by the application. .Pp .Fn EVP_PKEY_asn1_get0 returns the public key ASN.1 method @@ -185,8 +184,6 @@ object and will never be returned from .Fn EVP_PKEY_asn1_find or .Fn EVP_PKEY_asn1_find_str . -It is either an alias built into the library, or it was created with -.Xr EVP_PKEY_asn1_add_alias 3 . .It Dv ASN1_PKEY_DYNAMIC This .Fa ameth @@ -218,18 +215,6 @@ objects with In particular, this is used for .Dv EVP_PKEY_RSA . .El -.Pp -.Fn EVP_PKEY_asn1_get_count , -.Fn EVP_PKEY_asn1_get0 , -.Fn EVP_PKEY_asn1_find -and -.Fn EVP_PKEY_asn1_find_str -are not thread safe, but as long as all -.Vt EVP_PKEY_ASN1_METHOD -objects are added before the application gets threaded, using them is -safe. -See -.Xr EVP_PKEY_asn1_add0 3 . .Sh RETURN VALUES .Fn EVP_PKEY_asn1_get_count returns the number of available public key methods. diff --git a/lib/libcrypto/man/EVP_PKEY_asn1_new.3 b/lib/libcrypto/man/EVP_PKEY_asn1_new.3 index 82a109c57..cd6a71690 100644 --- a/lib/libcrypto/man/EVP_PKEY_asn1_new.3 +++ b/lib/libcrypto/man/EVP_PKEY_asn1_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.10 2023/09/13 14:18:21 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_asn1_new.3,v 1.11 2023/12/21 21:32:01 tb Exp $ .\" selective merge up to: .\" OpenSSL man3/EVP_PKEY_ASN1_METHOD b0004708 Nov 1 00:45:24 2017 +0800 .\" @@ -67,15 +67,16 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 13 2023 $ +.Dd $Mdocdate: December 21 2023 $ .Dt EVP_PKEY_ASN1_NEW 3 .Os .Sh NAME +.\" .Nm EVP_PKEY_asn1_add0 and +.\" .Nm EVP_PKEY_asn1_add_alias are intentionally undocumented +.\" because they will be removed in the next major bump .Nm EVP_PKEY_asn1_new , .Nm EVP_PKEY_asn1_copy , .Nm EVP_PKEY_asn1_free , -.Nm EVP_PKEY_asn1_add0 , -.Nm EVP_PKEY_asn1_add_alias , .Nm EVP_PKEY_asn1_set_public , .Nm EVP_PKEY_asn1_set_private , .Nm EVP_PKEY_asn1_set_param , @@ -104,15 +105,6 @@ .Fo EVP_PKEY_asn1_free .Fa "EVP_PKEY_ASN1_METHOD *ameth" .Fc -.Ft int -.Fo EVP_PKEY_asn1_add0 -.Fa "const EVP_PKEY_ASN1_METHOD *ameth" -.Fc -.Ft int -.Fo EVP_PKEY_asn1_add_alias -.Fa "int to" -.Fa "int from" -.Fc .Ft void .Fo EVP_PKEY_asn1_set_public .Fa "EVP_PKEY_ASN1_METHOD *ameth" @@ -179,13 +171,10 @@ is a structure which holds a set of ASN.1 conversion, printing and information methods for a specific public key algorithm. .Pp -There are two places where the +The built-in .Vt EVP_PKEY_ASN1_METHOD -objects are stored: one is a built-in array representing the standard -methods for different algorithms, and the other one is a stack of -user-defined application-specific methods, which can be manipulated by -using -.Fn EVP_PKEY_asn1_add0 . +objects are stored in a table containing the standard +methods for different algorithms. .Ss Methods The methods are the underlying implementations of a particular public key algorithm present by the @@ -467,28 +456,6 @@ is .Dv NULL of not marked as dynamically allocated, no action occurs. .Pp -.Fn EVP_PKEY_asn1_add0 -adds -.Fa ameth -to the user defined stack of methods unless another -.Vt EVP_PKEY_ASN1_METHOD -with the same NID is already there. -This function is not thread safe, it is recommended to only use this when -initializing the application. -.Pp -.Fn EVP_PKEY_asn1_add_alias -creates an alias with the NID -.Fa to -for the -.Vt EVP_PKEY_ASN1_METHOD -with NID -.Fa from -unless another -.Vt EVP_PKEY_ASN1_METHOD -with the same NID is already added. -This function is not thread safe, it's recommended to only use this when -initializing the application. -.Pp .Fn EVP_PKEY_asn1_set_public , .Fn EVP_PKEY_asn1_set_private , .Fn EVP_PKEY_asn1_set_param , @@ -509,11 +476,6 @@ returns a pointer to the new object or .Dv NULL if memory allocation fails. -.Pp -.Fn EVP_PKEY_asn1_add0 -and -.Fn EVP_PKEY_asn1_add_alias -return 0 on error or 1 on success. .Sh SEE ALSO .Xr EVP_PKEY_asn1_get_count 3 , .Xr EVP_PKEY_new 3 , @@ -522,8 +484,6 @@ return 0 on error or 1 on success. .Fn EVP_PKEY_asn1_new , .Fn EVP_PKEY_asn1_copy , .Fn EVP_PKEY_asn1_free , -.Fn EVP_PKEY_asn1_add0 , -.Fn EVP_PKEY_asn1_add_alias , .Fn EVP_PKEY_asn1_set_public , .Fn EVP_PKEY_asn1_set_private , .Fn EVP_PKEY_asn1_set_param , diff --git a/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 b/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 index 4a382e115..4825b6056 100644 --- a/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 +++ b/lib/libcrypto/man/EVP_PKEY_set1_RSA.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.20 2023/08/27 13:08:15 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_set1_RSA.3,v 1.21 2023/12/21 21:32:01 tb Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 27 2023 $ +.Dd $Mdocdate: December 21 2023 $ .Dt EVP_PKEY_SET1_RSA 3 .Os .Sh NAME @@ -314,9 +314,6 @@ according to the following table: .It Dv EVP_PKEY_RSA_PSS Ta = Dv NID_rsassaPss Ta RSA-PSS .El .Pp -Application programs can support additional key types by calling -.Xr EVP_PKEY_asn1_add0 3 . -.Pp .Fn EVP_PKEY_id returns the actual OID associated with .Fa pkey . @@ -334,9 +331,6 @@ The following deprecated aliases are still supported: .It Dv EVP_PKEY_RSA2 Ta = Dv NID_rsa Ta RSA .El .Pp -Application programs can support additional alternative OIDs by calling -.Xr EVP_PKEY_asn1_add_alias 3 . -.Pp Most applications wishing to know a key type will simply call .Fn EVP_PKEY_base_id and will not care about the actual type, diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 28bd7115d..4bd2171de 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumprmt.c,v 1.32 2023/03/08 04:43:06 guenther Exp $ */ +/* $OpenBSD: dumprmt.c,v 1.33 2023/12/21 08:01:21 otto Exp $ */ /* $NetBSD: dumprmt.c,v 1.17 1997/06/05 16:10:47 mrg Exp $ */ /*- @@ -90,7 +90,7 @@ rmthost(char *host) if (rmtpeer) strlcpy(rmtpeer, host, len); else - rmtpeer = host; + return (0); signal(SIGPIPE, rmtconnaborted); rmtgetconn(); if (rmtape < 0) diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index 0cd11f181..4498d91b1 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.25 2021/01/21 00:16:36 mortimer Exp $ */ +/* $OpenBSD: itime.c,v 1.26 2023/12/21 08:01:21 otto Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -99,6 +99,8 @@ readdumptimes(FILE *df) for (;;) { dtwalk = calloc(1, sizeof(struct dumptime)); + if (dtwalk == NULL) + quit("allocation failed"); if (getrecord(df, &(dtwalk->dt_value)) < 0) { free(dtwalk); break; @@ -114,6 +116,8 @@ readdumptimes(FILE *df) * record that we may have to add to the ddate structure */ ddatev = calloc((unsigned) (nddates + 1), sizeof(struct dumpdates *)); + if (ddatev == NULL) + quit("allocation failed"); dtwalk = dthead; for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next) ddatev[i] = &dtwalk->dt_value; @@ -192,6 +196,8 @@ putdumptime(void) * Enough room has been allocated. */ dtwalk = ddatev[nddates] = calloc(1, sizeof(struct dumpdates)); + if (dtwalk == NULL) + quit("allocation failed"); nddates += 1; found: (void) strlcpy(dtwalk->dd_name, fname, sizeof(dtwalk->dd_name)); diff --git a/share/man/man4/ugold.4 b/share/man/man4/ugold.4 index 43df0892d..abf6b6875 100644 --- a/share/man/man4/ugold.4 +++ b/share/man/man4/ugold.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ugold.4,v 1.9 2023/12/08 06:33:48 miod Exp $ +.\" $OpenBSD: ugold.4,v 1.10 2023/12/21 19:40:47 miod Exp $ .\" .\" Copyright (c) 2013 Takayoshi SASANO .\" Copyright (c) 2013 Martin Pieuchot @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 8 2023 $ +.Dd $Mdocdate: December 21 2023 $ .Dt UGOLD 4 .Os .Sh NAME @@ -39,6 +39,7 @@ driver: .It Li "RDing TEMPer2_V4.1" Ta "2 Temperature (internal/external)" .It Li "RDing TEMPerGold_V3.1" Ta "1 Temperature" .It Li "RDing TEMPerGold_V3.4" Ta "1 Temperature" +.It Li "RDing TEMPerGold_V3.5" Ta "1 Temperature" .It Li "RDing TEMPerHum1V1.0" Ta "1 Temperature and 1 Humidity" .It Li "RDing TEMPerHum1V1.2" Ta "1 Temperature and 1 Humidity" .It Li "RDing TEMPerHUM_V3.9" Ta "1 Temperature and 1 Humidity" diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index f67508224..c990a8ae7 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.308 2022/11/05 19:29:45 cheloha Exp $ +# $OpenBSD: Makefile,v 1.309 2023/12/21 02:57:14 jsg Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -39,7 +39,8 @@ MAN= aml_evalnode.9 atomic_add_int.9 atomic_cas_uint.9 \ sensor_attach.9 sigio_init.9 \ SMR_LIST_INIT.9 SMR_PTR_GET.9 smr_call.9 \ spl.9 srp_enter.9 srpl_rc_init.9 startuphook_establish.9 socreate.9 \ - sosplice.9 stoeplitz_to_key.9 strcmp.9 style.9 syscall.9 sysctl_int.9 \ + sosplice.9 stoeplitz_to_key.9 strcmp.9 strnstr.9 \ + style.9 syscall.9 sysctl_int.9 \ task_add.9 tc_init.9 tfind.9 thread_fork.9 \ timeout.9 tsleep.9 tvtohz.9 \ uiomove.9 \ diff --git a/share/man/man9/strnstr.9 b/share/man/man9/strnstr.9 new file mode 100644 index 000000000..70cbd6594 --- /dev/null +++ b/share/man/man9/strnstr.9 @@ -0,0 +1,90 @@ +.\" $OpenBSD: strnstr.9,v 1.1 2023/12/21 02:57:14 jsg Exp $ +.\" +.\" Copyright (c) 2001 Mike Barcroft +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd $Mdocdate: December 21 2023 $ +.Dt STRNSTR 9 +.Os +.Sh NAME +.Nm strnstr +.Nd locate a substring in a string +.Sh SYNOPSIS +.In lib/libkern/libkern.h +.Ft char * +.Fn strnstr "const char *big" "const char *little" "size_t len" +.Sh DESCRIPTION +The +.Fn strnstr +function +locates the first occurrence of the null-terminated string +.Fa little +in the string +.Fa big , +where not more than +.Fa len +characters are searched. +Characters that appear after a +.Ql \e0 +character are not searched. +.Sh RETURN VALUES +If +.Fa little +is an empty string, +.Fa big +is returned; +if +.Fa little +occurs nowhere in +.Fa big , +.Dv NULL +is returned; +otherwise a pointer to the first character of the first occurrence of +.Fa little +is returned. +.Sh EXAMPLES +The following sets the pointer +.Va ptr +to +.Dv NULL , +because only the first 4 characters of +.Va largestring +are searched: +.Bd -literal -offset indent +const char *largestring = "Foo Bar Baz"; +const char *smallstring = "Bar"; +char *ptr; + +ptr = strnstr(largestring, smallstring, 4); +.Ed +.Sh SEE ALSO +.Xr memchr 9 diff --git a/sys/conf/files b/sys/conf/files index 57a6f6a9b..b05d6bc6a 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.726 2023/11/21 14:00:13 bluhm Exp $ +# $OpenBSD: files,v 1.727 2023/12/21 02:57:14 jsg Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -1075,6 +1075,7 @@ file lib/libkern/arch/${MACHINE_ARCH}/strlen.S | lib/libkern/strlen.c file lib/libkern/arch/${MACHINE_ARCH}/strncmp.S | lib/libkern/strncmp.c file lib/libkern/arch/${MACHINE_ARCH}/strncpy.S | lib/libkern/strncpy.c file lib/libkern/arch/${MACHINE_ARCH}/strnlen.S | lib/libkern/strnlen.c +file lib/libkern/arch/${MACHINE_ARCH}/strnstr.S | lib/libkern/strnstr.c file lib/libkern/arch/${MACHINE_ARCH}/scanc.S | lib/libkern/scanc.c file lib/libkern/arch/${MACHINE_ARCH}/skpc.S | lib/libkern/skpc.c file lib/libkern/arch/${MACHINE_ARCH}/htonl.S | lib/libkern/htonl.c diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_fru_eeprom.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_fru_eeprom.c index 5192ac4ff..e32515087 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_fru_eeprom.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_fru_eeprom.c @@ -53,7 +53,6 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev) */ switch (adev->asic_type) { case CHIP_VEGA20: -#ifdef notyet /* D161 and D163 are the VG20 server SKUs */ if (strnstr(atom_ctx->vbios_version, "D161", sizeof(atom_ctx->vbios_version)) || @@ -61,13 +60,11 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev) sizeof(atom_ctx->vbios_version))) return true; else -#endif return false; case CHIP_ALDEBARAN: /* All Aldebaran SKUs have the FRU */ return true; case CHIP_SIENNA_CICHLID: -#ifdef notyet if (strnstr(atom_ctx->vbios_version, "D603", sizeof(atom_ctx->vbios_version))) { if (strnstr(atom_ctx->vbios_version, "D603GLXE", @@ -78,9 +75,6 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev) } else { return false; } -#else - return false; -#endif default: return false; } diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c index fe48628a0..7a301dd9f 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c @@ -2327,13 +2327,11 @@ static void amdgpu_ras_get_quirks(struct amdgpu_device *adev) if (!ctx) return; -#ifdef notyet if (strnstr(ctx->vbios_version, "D16406", sizeof(ctx->vbios_version)) || strnstr(ctx->vbios_version, "D36002", sizeof(ctx->vbios_version))) adev->ras_hw_enabled |= (1 << AMDGPU_RAS_BLOCK__GFX); -#endif } /* diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras_eeprom.c index 444799557..e96713553 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras_eeprom.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras_eeprom.c @@ -149,44 +149,29 @@ static bool __get_eeprom_i2c_addr(struct amdgpu_device *adev, /* VEGA20 and ARCTURUS */ if (adev->asic_type == CHIP_VEGA20) control->i2c_address = EEPROM_I2C_MADDR_0; -#ifdef notyet else if (strnstr(atom_ctx->vbios_version, "D342", sizeof(atom_ctx->vbios_version))) control->i2c_address = EEPROM_I2C_MADDR_0; else control->i2c_address = EEPROM_I2C_MADDR_4; -#else - STUB(); - control->i2c_address = EEPROM_I2C_MADDR_4; -#endif return true; case IP_VERSION(11, 0, 7): control->i2c_address = EEPROM_I2C_MADDR_0; return true; case IP_VERSION(13, 0, 2): -#ifdef notyet if (strnstr(atom_ctx->vbios_version, "D673", sizeof(atom_ctx->vbios_version))) control->i2c_address = EEPROM_I2C_MADDR_4; else control->i2c_address = EEPROM_I2C_MADDR_0; -#else - STUB(); - control->i2c_address = EEPROM_I2C_MADDR_0; -#endif return true; case IP_VERSION(13, 0, 0): -#ifdef notyet if (strnstr(atom_ctx->vbios_pn, "D707", sizeof(atom_ctx->vbios_pn))) control->i2c_address = EEPROM_I2C_MADDR_0; else control->i2c_address = EEPROM_I2C_MADDR_4; -#else - STUB(); - control->i2c_address = EEPROM_I2C_MADDR_4; -#endif return true; case IP_VERSION(13, 0, 6): case IP_VERSION(13, 0, 10): diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c index 7faa4182c..383be40de 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -631,13 +631,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry) if (!entry->bo) return; + + entry->bo->vm_bo = NULL; shadow = amdgpu_bo_shadowed(entry->bo); if (shadow) { ttm_bo_set_bulk_move(&shadow->tbo, NULL); amdgpu_bo_unref(&shadow); } ttm_bo_set_bulk_move(&entry->bo->tbo, NULL); - entry->bo->vm_bo = NULL; spin_lock(&entry->vm->status_lock); list_del(&entry->vm_status); diff --git a/sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c b/sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c index 93bdd2ce8..5dfd1e1a3 100644 --- a/sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c +++ b/sys/dev/pci/drm/amd/amdgpu/sdma_v5_2.c @@ -1690,6 +1690,32 @@ static void sdma_v5_2_get_clockgating_state(void *handle, u64 *flags) *flags |= AMD_CG_SUPPORT_SDMA_LS; } +static void sdma_v5_2_ring_begin_use(struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + + /* SDMA 5.2.3 (RMB) FW doesn't seem to properly + * disallow GFXOFF in some cases leading to + * hangs in SDMA. Disallow GFXOFF while SDMA is active. + * We can probably just limit this to 5.2.3, + * but it shouldn't hurt for other parts since + * this GFXOFF will be disallowed anyway when SDMA is + * active, this just makes it explicit. + */ + amdgpu_gfx_off_ctrl(adev, false); +} + +static void sdma_v5_2_ring_end_use(struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + + /* SDMA 5.2.3 (RMB) FW doesn't seem to properly + * disallow GFXOFF in some cases leading to + * hangs in SDMA. Allow GFXOFF when SDMA is complete. + */ + amdgpu_gfx_off_ctrl(adev, true); +} + const struct amd_ip_funcs sdma_v5_2_ip_funcs = { .name = "sdma_v5_2", .early_init = sdma_v5_2_early_init, @@ -1738,6 +1764,8 @@ static const struct amdgpu_ring_funcs sdma_v5_2_ring_funcs = { .test_ib = sdma_v5_2_ring_test_ib, .insert_nop = sdma_v5_2_ring_insert_nop, .pad_ib = sdma_v5_2_ring_pad_ib, + .begin_use = sdma_v5_2_ring_begin_use, + .end_use = sdma_v5_2_ring_end_use, .emit_wreg = sdma_v5_2_ring_emit_wreg, .emit_reg_wait = sdma_v5_2_ring_emit_reg_wait, .emit_reg_write_reg_wait = sdma_v5_2_ring_emit_reg_write_reg_wait, diff --git a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c index 9edd39322..67287ad07 100644 --- a/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c +++ b/sys/dev/pci/drm/amd/display/modules/power/power_helpers.c @@ -816,6 +816,8 @@ bool is_psr_su_specific_panel(struct dc_link *link) ((dpcd_caps->sink_dev_id_str[1] == 0x08 && dpcd_caps->sink_dev_id_str[0] == 0x08) || (dpcd_caps->sink_dev_id_str[1] == 0x08 && dpcd_caps->sink_dev_id_str[0] == 0x07))) isPSRSUSupported = false; + else if (dpcd_caps->sink_dev_id_str[1] == 0x08 && dpcd_caps->sink_dev_id_str[0] == 0x03) + isPSRSUSupported = false; else if (dpcd_caps->psr_info.force_psrsu_cap == 0x1) isPSRSUSupported = true; } diff --git a/sys/dev/pci/drm/i915/display/intel_fb.c b/sys/dev/pci/drm/i915/display/intel_fb.c index 3afd29063..8605bbfa6 100644 --- a/sys/dev/pci/drm/i915/display/intel_fb.c +++ b/sys/dev/pci/drm/i915/display/intel_fb.c @@ -1441,8 +1441,20 @@ static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_p size += remap_info->size; } else { - unsigned int dst_stride = plane_view_dst_stride_tiles(fb, color_plane, - remap_info->width); + unsigned int dst_stride; + + /* + * The hardware automagically calculates the CCS AUX surface + * stride from the main surface stride so can't really remap a + * smaller subset (unless we'd remap in whole AUX page units). + */ + if (intel_fb_needs_pot_stride_remap(fb) && + intel_fb_is_ccs_modifier(fb->base.modifier)) + dst_stride = remap_info->src_stride; + else + dst_stride = remap_info->width; + + dst_stride = plane_view_dst_stride_tiles(fb, color_plane, dst_stride); assign_chk_ovf(i915, remap_info->dst_stride, dst_stride); color_plane_info->mapping_stride = dst_stride * diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index 7f7dfad21..c761e5a9f 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugold.c,v 1.26 2023/12/10 19:03:37 miod Exp $ */ +/* $OpenBSD: ugold.c,v 1.27 2023/12/21 19:40:47 miod Exp $ */ /* * Copyright (c) 2013 Takayoshi SASANO @@ -498,8 +498,14 @@ ugold_si700x_type(struct ugold_softc *sc) /* TEMPerGold prefix */ if (sc->sc_model_len >= 11 && memcmp(sc->sc_model, "TEMPerGold_", 11) == 0) { + /* + * All V3.something models ought to work, but better be + * safe than sorry, and TEMPerHum models have been known + * to use slightly different sensors between models. + */ if (memcmp(sc->sc_model + 11, "V3.1 ", 16 - 11) == 0 || - memcmp(sc->sc_model + 11, "V3.4 ", 16 - 11) == 0) { + memcmp(sc->sc_model + 11, "V3.4 ", 16 - 11) == 0 || + memcmp(sc->sc_model + 11, "V3.5 ", 16 - 11) == 0) { sc->sc_type = UGOLD_TYPE_GOLD; sc->sc_num_sensors = 1; descr = "gold (temperature only)"; diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index 078ca3c6e..bedc95666 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,5 +1,5 @@ #! /bin/sh - -# $OpenBSD: makesyscalls.sh,v 1.20 2023/04/07 09:43:38 tb Exp $ +# $OpenBSD: makesyscalls.sh,v 1.21 2023/12/21 19:34:07 miod Exp $ # $NetBSD: makesyscalls.sh,v 1.26 1998/01/09 06:17:51 thorpej Exp $ # # Copyright (c) 1994,1996 Christopher G. Demetriou @@ -296,10 +296,6 @@ function parseline() { # arguments, they must still have arguments specified for # the remaining argument "positions," because of the way the # kernel system call argument handling works. - # - # Indirect system calls, e.g. syscall(), are exceptions to this - # rule, since they are handled entirely by machine-dependent code - # and do not need argument structures built. isvarargs = 0; while (f <= end) { @@ -326,59 +322,50 @@ function parseline() { } # must see another argument after varargs notice. if (isvarargs) { - if (argc == varargc && $2 != "INDIR") + if (argc == varargc) parserr($f, "argument definition") } else varargc = argc; } function putent(nodefs, compatwrap) { - # output syscall declaration for switch table. INDIR functions - # get none, since they always have sys_nosys() for their table - # entries. - if (nodefs != "INDIR") { - prototype = "(struct proc *, void *, register_t *)" - if (compatwrap == "") - printf("int\t%s%s;\n", funcname, - prototype) > sysprotos - else - printf("int\t%s_%s%s;\n", compatwrap, funcname, - prototype) > sysprotos - } + # output syscall declaration for switch table. + prototype = "(struct proc *, void *, register_t *)" + if (compatwrap == "") + printf("int\t%s%s;\n", funcname, + prototype) > sysprotos + else + printf("int\t%s_%s%s;\n", compatwrap, funcname, + prototype) > sysprotos # output syscall switch entry - if (nodefs == "INDIR") { - printf("\t{ 0, 0, %s,\n\t sys_nosys },\t\t\t/* %d = %s (indir) */\n", \ - sycall_flags, syscall, funcalias) > sysent - } else { -# printf("\t{ { %d", argc) > sysent -# for (i = 1; i <= argc; i++) { -# if (i == 5) # wrap the line -# printf(",\n\t ") > sysent -# else -# printf(", ") > sysent -# printf("s(%s)", argtypenospc[i]) > sysent -# } - printf("\t{ %d, ", argc) > sysent - if (argc == 0) - printf("0") > sysent - else if (compatwrap == "") - printf("s(struct %s_args)", funcname) > sysent - else - printf("s(struct %s_%s_args)", compatwrap, - funcname) > sysent - if (compatwrap == "") - wfn = sprintf("%s", funcname); - else - wfn = sprintf("%s(%s)", compatwrap, funcname); - printf(", %s,\n\t %s },", sycall_flags, wfn) > sysent - for (i = 0; i < (33 - length(wfn)) / 8; i++) - printf("\t") > sysent - if (compatwrap == "") - printf("/* %d = %s */\n", syscall, funcalias) > sysent - else - printf("/* %d = %s %s */\n", syscall, compatwrap, - funcalias) > sysent - } +# printf("\t{ { %d", argc) > sysent +# for (i = 1; i <= argc; i++) { +# if (i == 5) # wrap the line +# printf(",\n\t ") > sysent +# else +# printf(", ") > sysent +# printf("s(%s)", argtypenospc[i]) > sysent +# } + printf("\t{ %d, ", argc) > sysent + if (argc == 0) + printf("0") > sysent + else if (compatwrap == "") + printf("s(struct %s_args)", funcname) > sysent + else + printf("s(struct %s_%s_args)", compatwrap, + funcname) > sysent + if (compatwrap == "") + wfn = sprintf("%s", funcname); + else + wfn = sprintf("%s(%s)", compatwrap, funcname); + printf(", %s,\n\t %s },", sycall_flags, wfn) > sysent + for (i = 0; i < (33 - length(wfn)) / 8; i++) + printf("\t") > sysent + if (compatwrap == "") + printf("/* %d = %s */\n", syscall, funcalias) > sysent + else + printf("/* %d = %s %s */\n", syscall, compatwrap, + funcalias) > sysent # output syscall name for names table if (compatwrap == "") @@ -389,7 +376,7 @@ function putent(nodefs, compatwrap) { funcalias, syscall, compatwrap, funcalias) > sysnames # output syscall number of header, if appropriate - if (nodefs == "" || nodefs == "NOARGS" || nodefs == "INDIR") { + if (nodefs == "" || nodefs == "NOARGS") { # output a prototype, to be used to generate lint stubs in # libc. printf("/* syscall: \"%s\" ret: \"%s\" args:", funcalias, @@ -410,7 +397,7 @@ function putent(nodefs, compatwrap) { compatwrap, funcalias) > sysnumhdr # output syscall argument structure, if it has arguments - if (argc != 0 && nodefs != "NOARGS" && nodefs != "INDIR") { + if (argc != 0 && nodefs != "NOARGS") { if (compatwrap == "") printf("\nstruct %s_args {\n", funcname) > sysarghdr else @@ -428,7 +415,7 @@ $2 == "STD" { syscall++ next } -$2 == "NODEF" || $2 == "NOARGS" || $2 == "INDIR" { +$2 == "NODEF" || $2 == "NOARGS" { parseline() putent($2, "") syscall++ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 3770653f7..c30a0f92e 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.255 2023/12/19 06:58:36 deraadt Exp $ +; $OpenBSD: syscalls.master,v 1.256 2023/12/21 19:34:07 miod Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -12,8 +12,6 @@ ; compatibility options defined in syscalls.conf ; ; types: -; INDIR included, but don't define the syscall args structure, -; and allow it to be "really" varargs ; NOARGS included, but don't define the syscall args structure ; NODEF included, but don't define the syscall number ; NOLOCK don't acquire the kernel lock when calling this syscall diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index 597219a58..fb5d691f6 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libkern.h,v 1.36 2020/02/26 14:23:15 visa Exp $ */ +/* $OpenBSD: libkern.h,v 1.37 2023/12/21 02:57:14 jsg Exp $ */ /* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */ /*- @@ -167,5 +167,6 @@ size_t getsn(char *, size_t) char *strchr(const char *, int); char *strrchr(const char *, int); int timingsafe_bcmp(const void *, const void *, size_t); +char *strnstr(const char *, const char *, size_t); #endif /* __LIBKERN_H__ */ diff --git a/sys/lib/libkern/strnstr.c b/sys/lib/libkern/strnstr.c new file mode 100644 index 000000000..abba78e6e --- /dev/null +++ b/sys/lib/libkern/strnstr.c @@ -0,0 +1,62 @@ +/* $OpenBSD: strnstr.c,v 1.1 2023/12/21 02:57:14 jsg Exp $ */ + +/*- + * Copyright (c) 2001 Mike Barcroft + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* + * Find the first occurrence of find in s, where the search is limited to the + * first slen characters of s. + */ +char * +strnstr(const char *s, const char *find, size_t slen) +{ + char c, sc; + size_t len; + + if ((c = *find++) != '\0') { + len = strlen(find); + do { + do { + if (slen-- < 1 || (sc = *s++) == '\0') + return (NULL); + } while (sc != c); + if (len > slen) + return (NULL); + } while (strncmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index 25d742371..b6e7a4769 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.29 2023/10/02 14:48:11 krw Exp $ */ +/* $OpenBSD: cu.c,v 1.30 2023/12/21 11:25:38 jca Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott @@ -507,7 +507,7 @@ find_ucom(const char *usbid, char *names) if (names == NULL) return NULL; - /* names is a comma separated list of "ucom-". */ + /* names is a comma separated list of "ucom:". */ cua = NULL; for (ucom = strsep(&names, ","); ucom; ucom = strsep(&names, ",")) { if (*ucom == '\0' || strncasecmp(ucom, "ucom", 4)) diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 912336fe3..849311482 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application.c,v 1.40 2023/11/16 14:35:25 martijn Exp $ */ +/* $OpenBSD: application.c,v 1.41 2023/12/21 12:43:30 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -17,7 +17,9 @@ */ #include +#include #include +#include #include #include diff --git a/usr.sbin/snmpd/application_agentx.c b/usr.sbin/snmpd/application_agentx.c index d196f5ebd..ddecb8d9b 100644 --- a/usr.sbin/snmpd/application_agentx.c +++ b/usr.sbin/snmpd/application_agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application_agentx.c,v 1.14 2023/11/06 11:04:41 martijn Exp $ */ +/* $OpenBSD: application_agentx.c,v 1.15 2023/12/21 12:43:30 martijn Exp $ */ /* * Copyright (c) 2022 Martijn van Duren * @@ -18,15 +18,16 @@ #include #include #include -#include -#include +#include #include +#include #include #include #include -#include +#include #include +#include #include #include diff --git a/usr.sbin/snmpd/application_blocklist.c b/usr.sbin/snmpd/application_blocklist.c index e3bb1b94c..354908d50 100644 --- a/usr.sbin/snmpd/application_blocklist.c +++ b/usr.sbin/snmpd/application_blocklist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application_blocklist.c,v 1.1 2022/06/30 11:28:36 martijn Exp $ */ +/* $OpenBSD: application_blocklist.c,v 1.2 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2022 Martijn van Duren @@ -16,10 +16,16 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include + +#include + +#include +#include #include #include "application.h" +#include "log.h" #include "snmpd.h" struct appl_varbind *appl_blocklist_response(size_t); diff --git a/usr.sbin/snmpd/application_internal.c b/usr.sbin/snmpd/application_internal.c index a9c637b23..9d9166cbe 100644 --- a/usr.sbin/snmpd/application_internal.c +++ b/usr.sbin/snmpd/application_internal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application_internal.c,v 1.10 2023/12/18 09:42:57 martijn Exp $ */ +/* $OpenBSD: application_internal.c,v 1.11 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2023 Martijn van Duren @@ -17,17 +17,21 @@ */ #include +#include +#include + +#include #include -#include +#include #include #include -#include #include "application.h" #include "log.h" #include "mib.h" #include "smi.h" +#include "snmp.h" #include "snmpd.h" struct appl_internal_object { diff --git a/usr.sbin/snmpd/ax.c b/usr.sbin/snmpd/ax.c index a5c4c1930..4a2509a2f 100644 --- a/usr.sbin/snmpd/ax.c +++ b/usr.sbin/snmpd/ax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ax.c,v 1.3 2023/10/24 08:54:52 martijn Exp $ */ +/* $OpenBSD: ax.c,v 1.4 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren * @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "ax.h" diff --git a/usr.sbin/snmpd/ax.h b/usr.sbin/snmpd/ax.h index 550197838..36006221a 100644 --- a/usr.sbin/snmpd/ax.h +++ b/usr.sbin/snmpd/ax.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ax.h,v 1.2 2023/10/24 08:54:52 martijn Exp $ */ +/* $OpenBSD: ax.h,v 1.3 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren * @@ -15,6 +15,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + +#include #include #define AX_PDU_FLAG_INSTANCE_REGISTRATION (1 << 0) diff --git a/usr.sbin/snmpd/log.c b/usr.sbin/snmpd/log.c index 6ad48d805..2bbae66c8 100644 --- a/usr.sbin/snmpd/log.c +++ b/usr.sbin/snmpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.16 2017/03/21 12:06:56 bluhm Exp $ */ +/* $OpenBSD: log.c,v 1.17 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include #include diff --git a/usr.sbin/snmpd/mib.h b/usr.sbin/snmpd/mib.h index f154099dd..06774a908 100644 --- a/usr.sbin/snmpd/mib.h +++ b/usr.sbin/snmpd/mib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.h,v 1.42 2023/11/08 19:43:29 martijn Exp $ */ +/* $OpenBSD: mib.h,v 1.43 2023/12/21 13:54:05 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -19,6 +19,10 @@ #ifndef SNMPD_MIB_H #define SNMPD_MIB_H +#define MIBDECL(...) { { MIB_##__VA_ARGS__ }, \ + (sizeof((uint32_t []) { MIB_##__VA_ARGS__ }) / sizeof(uint32_t))}, #__VA_ARGS__ +#define MIBEND { { 0 } }, NULL + /* * Adding new MIBs: * - add the OID definitions below @@ -1395,6 +1399,4 @@ { MIBEND } \ } - void mib_init(void); - #endif /* SNMPD_MIB_H */ diff --git a/usr.sbin/snmpd/parse.y b/usr.sbin/snmpd/parse.y index 7d001774e..ab78c2bde 100644 --- a/usr.sbin/snmpd/parse.y +++ b/usr.sbin/snmpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.85 2023/12/18 16:58:26 martijn Exp $ */ +/* $OpenBSD: parse.y,v 1.86 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -23,40 +23,41 @@ */ %{ -#include -#include #include #include -#include +#include +#include +#include +#include #include -#include -#include - #include +#include + #include +#include #include -#include #include #include -#include #include #include #include -#include -#include -#include -#include #include #include -#include +#include +#include +#include +#include #include +#include #include "application.h" -#include "snmpd.h" +#include "log.h" #include "mib.h" +#include "snmpd.h" +#include "snmp.h" TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); static struct file { diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c index fe596ff64..94a78a9a7 100644 --- a/usr.sbin/snmpd/proc.c +++ b/usr.sbin/snmpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.28 2023/02/15 20:44:01 tobhe Exp $ */ +/* $OpenBSD: proc.c,v 1.29 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -17,14 +17,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include #include #include #include #include #include +#include #include #include #include @@ -34,6 +33,7 @@ #include #include +#include "log.h" #include "snmpd.h" void proc_exec(struct privsep *, struct privsep_proc *, unsigned int, int, diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c index ceeb8db6b..cdd3044c4 100644 --- a/usr.sbin/snmpd/smi.c +++ b/usr.sbin/snmpd/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.38 2023/11/12 20:14:39 martijn Exp $ */ +/* $OpenBSD: smi.c,v 1.39 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -16,37 +16,26 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include -#include -#include #include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include #include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include #include -#include "snmpd.h" +#include "log.h" #include "mib.h" -#include "application.h" +#include "smi.h" +#include "snmp.h" +#include "snmpd.h" struct oid { struct ber_oid o_id; diff --git a/usr.sbin/snmpd/smi.h b/usr.sbin/snmpd/smi.h index 980dd7da1..c6e31c0cc 100644 --- a/usr.sbin/snmpd/smi.h +++ b/usr.sbin/snmpd/smi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.h,v 1.3 2023/11/08 20:02:52 martijn Exp $ */ +/* $OpenBSD: smi.h,v 1.4 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -16,8 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include +#include + +struct ber_element; +struct ber_oid; char *smi_oid2string(struct ber_oid *, char *, size_t, size_t); u_long smi_getticks(void); diff --git a/usr.sbin/snmpd/snmp.h b/usr.sbin/snmpd/snmp.h index 939654561..c0a9a0cf4 100644 --- a/usr.sbin/snmpd/snmp.h +++ b/usr.sbin/snmpd/snmp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmp.h,v 1.19 2022/06/30 09:42:19 martijn Exp $ */ +/* $OpenBSD: snmp.h,v 1.20 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -20,7 +20,6 @@ #define SNMPD_SNMP_H #include -#include /* * SNMP IMSG interface diff --git a/usr.sbin/snmpd/snmpd.c b/usr.sbin/snmpd/snmpd.c index 08696024d..689a2a331 100644 --- a/usr.sbin/snmpd/snmpd.c +++ b/usr.sbin/snmpd/snmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.c,v 1.48 2022/10/06 14:41:08 martijn Exp $ */ +/* $OpenBSD: snmpd.c,v 1.49 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -17,29 +17,20 @@ */ #include -#include -#include #include -#include - -#include #include -#include -#include -#include -#include #include #include -#include +#include #include +#include +#include #include #include -#include -#include +#include "log.h" #include "snmpd.h" -#include "mib.h" __dead void usage(void); diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h index a141a23ce..fc0a67a97 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.114 2023/11/13 15:05:14 martijn Exp $ */ +/* $OpenBSD: snmpd.h,v 1.116 2023/12/21 13:54:05 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -20,24 +20,22 @@ #ifndef SNMPD_H #define SNMPD_H +#include +#include +#include #include +#include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include +#include +#include #include +#include +#include -#include "log.h" -#include "smi.h" #include "snmp.h" #ifndef nitems @@ -176,10 +174,6 @@ struct privsep_fd { #define OID(...) (struct ber_oid){ { __VA_ARGS__ }, \ (sizeof((uint32_t []) { __VA_ARGS__ }) / sizeof(uint32_t)) } -#define MIBDECL(...) { { MIB_##__VA_ARGS__ }, \ - (sizeof((uint32_t []) { MIB_##__VA_ARGS__ }) / sizeof(uint32_t))}, #__VA_ARGS__ -#define MIB(...) { { MIB_##__VA_ARGS__ } }, NULL -#define MIBEND { { 0 } }, NULL /* * daemon structures diff --git a/usr.sbin/snmpd/snmpe.c b/usr.sbin/snmpd/snmpe.c index 121692985..73e25ba32 100644 --- a/usr.sbin/snmpd/snmpe.c +++ b/usr.sbin/snmpd/snmpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpe.c,v 1.92 2023/11/20 10:32:45 martijn Exp $ */ +/* $OpenBSD: snmpe.c,v 1.93 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -18,27 +18,27 @@ */ #include -#include -#include #include -#include +#include #include +#include -#include #include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include +#include #include -#include #include "application.h" +#include "log.h" #include "snmpd.h" #include "snmpe.h" #include "mib.h" diff --git a/usr.sbin/snmpd/snmpe.h b/usr.sbin/snmpd/snmpe.h index 265a7a1a3..af3db3b0a 100644 --- a/usr.sbin/snmpd/snmpe.h +++ b/usr.sbin/snmpd/snmpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpe.h,v 1.2 2022/01/19 10:36:35 martijn Exp $ */ +/* $OpenBSD: snmpe.h,v 1.3 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -16,9 +16,12 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include "snmp.h" struct snmp_message; +struct ber_element; void snmpe_send(struct snmp_message *, enum snmp_pdutype, int32_t, int32_t, uint32_t, struct ber_element *); diff --git a/usr.sbin/snmpd/trap.c b/usr.sbin/snmpd/trap.c index 043799a39..94fe4a7b8 100644 --- a/usr.sbin/snmpd/trap.c +++ b/usr.sbin/snmpd/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.40 2023/12/12 20:18:39 martijn Exp $ */ +/* $OpenBSD: trap.c,v 1.41 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2008 Reyk Floeter @@ -17,27 +17,18 @@ */ #include -#include -#include #include -#include -#include - -#include -#include -#include +#include +#include #include -#include -#include -#include -#include #include -#include -#include -#include "snmpd.h" +#include "log.h" #include "mib.h" +#include "smi.h" +#include "snmp.h" +#include "snmpd.h" void trap_init(void) diff --git a/usr.sbin/snmpd/traphandler.c b/usr.sbin/snmpd/traphandler.c index c9affe0af..c22ea1363 100644 --- a/usr.sbin/snmpd/traphandler.c +++ b/usr.sbin/snmpd/traphandler.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traphandler.c,v 1.24 2022/12/28 21:30:19 jmc Exp $ */ +/* $OpenBSD: traphandler.c,v 1.25 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2014 Bret Stephen Lambert @@ -18,30 +18,25 @@ #include #include -#include -#include -#include +#include #include -#include -#include -#include - #include #include -#include -#include #include #include +#include #include #include #include +#include #include #include -#include +#include "log.h" +#include "smi.h" +#include "snmp.h" #include "snmpd.h" -#include "mib.h" int traphandler_priv_recvmsg(struct privsep_proc *, struct imsg *); int traphandler_fork_handler(struct privsep_proc *, struct imsg *); diff --git a/usr.sbin/snmpd/usm.c b/usr.sbin/snmpd/usm.c index 1e37dcb8c..215388254 100644 --- a/usr.sbin/snmpd/usm.c +++ b/usr.sbin/snmpd/usm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usm.c,v 1.28 2023/11/08 20:09:18 martijn Exp $ */ +/* $OpenBSD: usm.c,v 1.29 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2012 GeNUA mbH @@ -18,30 +18,24 @@ #include #include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif #include #include +#ifdef DEBUG +#include +#endif +#include +#include +#include +#include +#include + #include "application.h" -#include "snmpd.h" +#include "log.h" #include "mib.h" +#include "snmp.h" +#include "snmpd.h" SLIST_HEAD(, usmuser) usmuserlist; diff --git a/usr.sbin/snmpd/util.c b/usr.sbin/snmpd/util.c index d4b970908..46f2dda4c 100644 --- a/usr.sbin/snmpd/util.c +++ b/usr.sbin/snmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.13 2022/10/06 14:41:08 martijn Exp $ */ +/* $OpenBSD: util.c,v 1.14 2023/12/21 12:43:31 martijn Exp $ */ /* * Copyright (c) 2014 Bret Stephen Lambert * @@ -15,21 +15,17 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include #include -#include +#include -#include #include -#include #include +#include #include +#include #include -#include -#include "snmp.h" #include "snmpd.h" ssize_t