Supprt FTDI FT232R
The diff below makes the serial interface of the Genio 1200 demo board (FT232R) work. The upper 2 bits encode the fractional component of the FT232R is either 0 or 0.125. uftdi0 at uhub0 port 3 configuration 1 interface 0 "FTDI FT232R USB UART" rev 2.00/6.00 addr 2 ucom0 at uftdi0 portno 1 Tested with cu. ok? Index: sys/dev/usb/uftdi.c === RCS file: /cvs/src/sys/dev/usb/uftdi.c,v retrieving revision 1.77 diff -u -p -u -p -r1.77 uftdi.c --- sys/dev/usb/uftdi.c 9 Apr 2022 20:07:44 - 1.77 +++ sys/dev/usb/uftdi.c 29 Dec 2022 06:40:32 - @@ -97,7 +97,7 @@ void uftdi_read(void *sc, int portno, u_ void uftdi_write(void *sc, int portno, u_char *to, u_char *from, u_int32_t *count); void uftdi_break(void *sc, int portno, int onoff); -intuftdi_8u232am_getrate(speed_t speed, int *rate); +intuftdi_8u232am_getrate(struct uftdi_softc *sc, speed_t speed, int *rate); intuftdi_2232h_getrate(speed_t speed, int *rate); const struct ucom_methods uftdi_methods = { @@ -772,6 +772,9 @@ uftdi_attach(struct device *parent, stru if (uaa->release < 0x0200) { sc->sc_type = UFTDI_TYPE_SIO; sc->sc_hdrlen = 1; + } else if (uaa->release == 0x0600) { + sc->sc_type = UFTDI_TYPE_232R; + sc->sc_hdrlen = 0; } else if (uaa->release == 0x0700 || uaa->release == 0x0800) { sc->sc_type = UFTDI_TYPE_2232H; sc->sc_hdrlen = 0; @@ -1011,8 +1014,9 @@ uftdi_param(void *vsc, int portno, struc } break; + case UFTDI_TYPE_232R: case UFTDI_TYPE_8U232AM: - if (uftdi_8u232am_getrate(t->c_ospeed, ) == -1) + if (uftdi_8u232am_getrate(sc, t->c_ospeed, ) == -1) return (EINVAL); break; case UFTDI_TYPE_2232H: @@ -1131,7 +1135,7 @@ uftdi_break(void *vsc, int portno, int o } int -uftdi_8u232am_getrate(speed_t speed, int *rate) +uftdi_8u232am_getrate(struct uftdi_softc *sc, speed_t speed, int *rate) { /* Table of the nearest even powers-of-2 for values 0..15. */ static const unsigned char roundoff[16] = { @@ -1182,11 +1186,13 @@ uftdi_8u232am_getrate(speed_t speed, int * 0.125. */ result = d >> 4; - if (d & 8) - result |= 0x4000; - else if (d & 4) - result |= 0x8000; - else if (d & 2) + if (sc->sc_type == UFTDI_TYPE_8U232AM) { + if (d & 8) + result |= 0x4000; + else if (d & 4) + result |= 0x8000; + } + if (d & 2) result |= 0xc000; done: Index: sys/dev/usb/uftdireg.h === RCS file: /cvs/src/sys/dev/usb/uftdireg.h,v retrieving revision 1.13 diff -u -p -u -p -r1.13 uftdireg.h --- sys/dev/usb/uftdireg.h 11 Sep 2012 16:04:44 - 1.13 +++ sys/dev/usb/uftdireg.h 29 Dec 2022 06:40:32 - @@ -36,7 +36,8 @@ enum uftdi_type { UFTDI_TYPE_SIO, UFTDI_TYPE_8U232AM, - UFTDI_TYPE_2232H + UFTDI_TYPE_2232H, + UFTDI_TYPE_232R }; /*
Re: clang 15 and zlib
On Wed, 28 Dec 2022, Todd C. Miller wrote: > OK millert@ as well. There is no point in trying to fix this locally > when upstream zlib will be changing it in the near(?) future. He committed to removing the K function declarations when C23 is finalised: https://github.com/madler/zlib/issues/633#issuecomment-1275165338 ETA by the end of next year: https://github.com/madler/zlib/issues/633#issuecomment-1276016034 Otherwise, there's the https://github.com/zlib-ng/zlib-ng fork which has a bit more appetite for change and has already removed them, but that's obviously a bigger discussion. -d
Re: Use `ps_mtx' mutex(9) to protect `ps_ucred' and unlock setuid(2), ...
The latest diff iteration after guenther@'s feedback. - The lock grabbing in ddb(4) is wrong, so don't grab it within db_show_all_procs(). - In the dorefreshcreds() grab the lock only if uc != pr->ps_ucred. Also move crfree() out of the lock. - In the pgsigio() store call CANSIGIO() with the lock held and store result to the local variable. Don't hold the lock when call prsignal() because kernel lock serialize this path. - In the sysctl_file() don't grab the lock the lock if `arg' < 0. Index: sys/kern/kern_acct.c === RCS file: /cvs/src/sys/kern/kern_acct.c,v retrieving revision 1.47 diff -u -p -r1.47 kern_acct.c --- sys/kern/kern_acct.c14 Aug 2022 01:58:27 - 1.47 +++ sys/kern/kern_acct.c26 Dec 2022 16:11:43 - @@ -221,8 +221,10 @@ acct_process(struct proc *p) acct.ac_io = encode_comp_t(r->ru_inblock + r->ru_oublock, 0); /* (6) The UID and GID of the process */ + mtx_enter(>ps_mtx); acct.ac_uid = pr->ps_ucred->cr_ruid; acct.ac_gid = pr->ps_ucred->cr_rgid; + mtx_leave(>ps_mtx); /* (7) The terminal from which the process was started */ if ((pr->ps_flags & PS_CONTROLT) && Index: sys/kern/kern_exec.c === RCS file: /cvs/src/sys/kern/kern_exec.c,v retrieving revision 1.240 diff -u -p -r1.240 kern_exec.c --- sys/kern/kern_exec.c23 Nov 2022 11:00:27 - 1.240 +++ sys/kern/kern_exec.c26 Dec 2022 16:11:43 - @@ -649,9 +649,11 @@ sys_execve(struct proc *p, void *v, regi if (pr->ps_ucred != cred) { struct ucred *ocred; - ocred = pr->ps_ucred; crhold(cred); + mtx_enter(>ps_mtx); + ocred = pr->ps_ucred; pr->ps_ucred = cred; + mtx_leave(>ps_mtx); crfree(ocred); } Index: sys/kern/kern_exit.c === RCS file: /cvs/src/sys/kern/kern_exit.c,v retrieving revision 1.209 diff -u -p -r1.209 kern_exit.c --- sys/kern/kern_exit.c19 Dec 2022 00:22:12 - 1.209 +++ sys/kern/kern_exit.c26 Dec 2022 16:11:43 - @@ -494,7 +494,9 @@ loop: *retval = pr->ps_pid; if (info != NULL) { info->si_pid = pr->ps_pid; + mtx_enter(>ps_mtx); info->si_uid = pr->ps_ucred->cr_uid; + mtx_leave(>ps_mtx); info->si_signo = SIGCHLD; if (pr->ps_xsig == 0) { info->si_code = CLD_EXITED; @@ -531,7 +533,9 @@ loop: *retval = pr->ps_pid; if (info != NULL) { info->si_pid = pr->ps_pid; + mtx_enter(>ps_mtx); info->si_uid = pr->ps_ucred->cr_uid; + mtx_leave(>ps_mtx); info->si_signo = SIGCHLD; info->si_code = CLD_TRAPPED; info->si_status = pr->ps_xsig; @@ -554,7 +558,9 @@ loop: *retval = pr->ps_pid; if (info != 0) { info->si_pid = pr->ps_pid; + mtx_enter(>ps_mtx); info->si_uid = pr->ps_ucred->cr_uid; + mtx_leave(>ps_mtx); info->si_signo = SIGCHLD; info->si_code = CLD_STOPPED; info->si_status = pr->ps_xsig; @@ -573,7 +579,9 @@ loop: *retval = pr->ps_pid; if (info != NULL) { info->si_pid = pr->ps_pid; + mtx_enter(>ps_mtx); info->si_uid = pr->ps_ucred->cr_uid; + mtx_leave(>ps_mtx); info->si_signo = SIGCHLD; info->si_code = CLD_CONTINUED; info->si_status = SIGCONT; Index: sys/kern/kern_ktrace.c === RCS file: /cvs/src/sys/kern/kern_ktrace.c,v retrieving revision 1.109 diff -u -p -r1.109 kern_ktrace.c --- sys/kern/kern_ktrace.c 5 Dec 2022 23:18:37 - 1.109 +++ sys/kern/kern_ktrace.c 26 Dec 2022 16:11:43 - @@ -693,7 +693,12 @@ int ktrcanset(struct proc *callp, struct process *targetpr) { struct ucred *caller = callp->p_ucred; - struct ucred *target = targetpr->ps_ucred; + struct ucred *target; + int ret = 0; + +
Re: [patch(es)] fix a few typos in /src
On Wed, Dec 28, 2022 at 09:35:52PM +, Jason McIntyre wrote: > i've finished with this diff. the usr.sbin parts i didn;t take are > listed below, along with any explanation. I *think* by my count and by watching the logs this is all of the diffs on this thread! Kudos for your steadfast review, thank you very much for your work applying the diff. I'm very appreciative! paultag -- :wq
Re: clang 15 and zlib
OK millert@ as well. There is no point in trying to fix this locally when upstream zlib will be changing it in the near(?) future. - todd
Re: [patch(es)] fix a few typos in /src
On Fri, Dec 23, 2022 at 10:33:43AM -0500, Paul Tagliamonte wrote: i've finished with this diff. the usr.sbin parts i didn;t take are listed below, along with any explanation. jmc Index: usr.sbin/smtpd/crypto.c === RCS file: /cvs/src/usr.sbin/smtpd/crypto.c,v retrieving revision 1.10 diff -u -p -r1.10 crypto.c --- usr.sbin/smtpd/crypto.c 14 Jun 2021 17:58:15 - 1.10 +++ usr.sbin/smtpd/crypto.c 23 Dec 2022 15:20:51 - @@ -375,7 +375,7 @@ main(int argc, char *argv[]) /* uncomment below to provoke integrity check failure */ /* * fpin = fopen("/tmp/passwd.enc", "a"); -* fprintf(fpin, "borken"); +* fprintf(fpin, "broken"); * fclose(fpin); */ fpin = fopen("/tmp/passwd.enc", "r"); i think it was noted already, but "bork" is a thing. i didn;t touch this. Index: usr.sbin/smtpd/mta_session.c === RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v retrieving revision 1.147 diff -u -p -r1.147 mta_session.c --- usr.sbin/smtpd/mta_session.c26 Sep 2022 08:48:52 - 1.147 +++ usr.sbin/smtpd/mta_session.c23 Dec 2022 15:20:51 - @@ -635,7 +635,7 @@ again: else if (s->relay->secret) { log_debug("debug: mta: %p: not using AUTH on non-TLS " "session", s); - mta_error(s, "Refuse to AUTH over unsecure channel"); + mta_error(s, "Refuse to AUTH over insecure channel"); mta_connect(s); } else { mta_enter_state(s, MTA_READY); ho hum. i left this. the sense seems closer to unsecure debt than insecure person. Index: usr.sbin/relayd/relay_http.c === RCS file: /cvs/src/usr.sbin/relayd/relay_http.c,v retrieving revision 1.83 diff -u -p -r1.83 relay_http.c --- usr.sbin/relayd/relay_http.c23 Oct 2021 20:46:18 - 1.83 +++ usr.sbin/relayd/relay_http.c23 Dec 2022 15:20:51 - @@ -281,7 +281,7 @@ relay_read_http(struct bufferevent *bev, } else { SIMPLEQ_REMOVE_HEAD(>hs_methods, hmn_entry); request_method = hmn->hmn_method; - DPRINTF("%s: session %d dequeing %s", __func__, + DPRINTF("%s: session %d dequeuing %s", __func__, con->se_id, relay_httpmethod_byid(request_method)); free(hmn); @@ -335,7 +335,7 @@ relay_read_http(struct bufferevent *bev, goto fail; } hmn->hmn_method = desc->http_method; - DPRINTF("%s: session %d enqueing %s", __func__, + DPRINTF("%s: session %d enqueuing %s", __func__, con->se_id, relay_httpmethod_byid(hmn->hmn_method)); SIMPLEQ_INSERT_TAIL(>hs_methods, hmn, hmn_entry); so "queuing" and "queueing" are both ok. on reflection, i think i will tweak this one. Index: usr.sbin/smtpd/smtpd.c === RCS file: /cvs/src/usr.sbin/smtpd/smtpd.c,v retrieving revision 1.343 diff -u -p -r1.343 smtpd.c --- usr.sbin/smtpd/smtpd.c 18 Feb 2022 16:57:36 - 1.343 +++ usr.sbin/smtpd/smtpd.c 23 Dec 2022 15:20:51 - @@ -1802,7 +1802,7 @@ parent_forward_open(char *username, char } if (!secure_file(fd, pathname, directory, uid, 1)) { - log_warnx("warn: smtpd: %s: unsecure file", pathname); + log_warnx("warn: smtpd: %s: insecure file", pathname); close(fd); return -1; } as above jmc
ESRT support for the amd64 bootloader
Dear Sergii, Sorry for the delay, but I have finally found the time to work on the EFI variable and ESRT support for OpenBSD. As a first step, here is a diff that adds support for copying the ESRT in the bootloader and passing it on to the kernel. I adjusted your diff a bit. It now adds the new config_esrt member at the end of the bios_efiinfo struct and sets a flag to indicate that extra bit of information is present. That makes it possible to load new kernels with the old bootloader and vice versa. patrick@, mlarkin@, yasuoka@ and other devs: ok? Index: arch/amd64/include/biosvar.h === RCS file: /cvs/src/sys/arch/amd64/include/biosvar.h,v retrieving revision 1.29 diff -u -p -r1.29 biosvar.h --- arch/amd64/include/biosvar.h29 Nov 2022 21:41:39 - 1.29 +++ arch/amd64/include/biosvar.h28 Dec 2022 20:03:32 - @@ -218,11 +218,13 @@ typedef struct _bios_efiinfo { uint32_tfb_reserved_mask; uint32_tflags; #define BEI_64BIT 0x0001 /* 64-bit EFI implementation */ +#define BEI_ESRT 0x0002 /* ESRT table */ uint32_tmmap_desc_ver; uint32_tmmap_desc_size; uint32_tmmap_size; uint64_tmmap_start; uint64_tsystem_table; + uint64_tconfig_esrt; } __packed bios_efiinfo_t; #defineBOOTARG_UCODE 12 Index: arch/amd64/stand/efiboot/conf.c === RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/conf.c,v retrieving revision 1.39 diff -u -p -r1.39 conf.c --- arch/amd64/stand/efiboot/conf.c 12 Aug 2022 20:18:58 - 1.39 +++ arch/amd64/stand/efiboot/conf.c 28 Dec 2022 20:03:32 - @@ -40,7 +40,7 @@ #include "efidev.h" #include "efipxe.h" -const char version[] = "3.62"; +const char version[] = "3.63"; #ifdef EFI_DEBUG intdebug = 0; Index: arch/amd64/stand/efiboot/efiboot.c === RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v retrieving revision 1.40 diff -u -p -r1.40 efiboot.c --- arch/amd64/stand/efiboot/efiboot.c 11 Jul 2022 19:45:02 - 1.40 +++ arch/amd64/stand/efiboot/efiboot.c 28 Dec 2022 20:03:32 - @@ -831,6 +831,7 @@ efi_com_putc(dev_t dev, int c) */ static EFI_GUID acpi_guid = ACPI_20_TABLE_GUID; static EFI_GUID smbios_guid = SMBIOS_TABLE_GUID; +static EFI_GUID esrt_guid = EFI_SYSTEM_RESOURCE_TABLE_GUID; static int gopmode = -1; #defineefi_guidcmp(_a, _b) memcmp((_a), (_b), sizeof(EFI_GUID)) @@ -870,6 +871,34 @@ efi_makebootargs(void) >ConfigurationTable[i].VendorGuid) == 0) ei->config_smbios = (uintptr_t) ST->ConfigurationTable[i].VendorTable; + else if (efi_guidcmp(_guid, + >ConfigurationTable[i].VendorGuid) == 0) + ei->config_esrt = (uintptr_t) + ST->ConfigurationTable[i].VendorTable; + } + + /* +* Need to copy ESRT because call to ExitBootServices() frees memory of +* type EfiBootServicesData in which ESRT resides. +*/ + if (ei->config_esrt != 0) { + EFI_SYSTEM_RESOURCE_TABLE *esrt = + (EFI_SYSTEM_RESOURCE_TABLE *)ei->config_esrt; + size_t esrt_size = sizeof(*esrt) + + esrt->FwResourceCount * sizeof(EFI_SYSTEM_RESOURCE_ENTRY); + void *esrt_copy; + + /* +* Using EfiRuntimeServicesData as it maps to BIOS_MAP_RES, +* while EfiLoaderData becomes BIOS_MAP_FREE. +*/ + status = BS->AllocatePool(EfiRuntimeServicesData, + esrt_size, _copy); + if (status == EFI_SUCCESS) { + memcpy(esrt_copy, esrt, esrt_size); + ei->config_esrt = (uintptr_t)esrt_copy; + ei->flags |= BEI_ESRT; + } } /* Index: stand/efi/include/efiapi.h === RCS file: /cvs/src/sys/stand/efi/include/efiapi.h,v retrieving revision 1.3 diff -u -p -r1.3 efiapi.h --- stand/efi/include/efiapi.h 7 Dec 2022 23:04:26 - 1.3 +++ stand/efi/include/efiapi.h 28 Dec 2022 20:03:32 - @@ -871,6 +871,10 @@ typedef struct { { 0x49152e77, 0x1ada, 0x4764,\ { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } } +#define EFI_SYSTEM_RESOURCE_TABLE_GUID \ + { 0xb122a263, 0x3661, 0x4f68,\ +{ 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } } + typedef struct _EFI_CONFIGURATION_TABLE { EFI_GUIDVendorGuid; VOID*VendorTable; @@ -911,5
Re: clang 15 and zlib
On Wed, Dec 28, 2022 at 07:48:29PM +0100, Jeremie Courreges-Anglas wrote: > > To build src cleanly with clang-15 you'd need the diff below. The > alternative would be to patch our three zlib copies and wait for > upstream to fix it. A more comfortable alternative is to just neuter > the warning. -Wno-unknown-warning-option prevents llvm 13 from > complaining that it doesn't know about -Wno-deprecated-non-prototype and > should ease the transition. I took care to only add this workaround on > clang archs, and to respect the COMPILER_VERSION checks where due. Thanks. As already mentioned in another thread, ansifying libz will likely result in more pain when updating since madler has a tendency of touching lots of lines. While I could probably cope with the conflicts, I'd really rather not have additional hurdles when updating zlib. It is unfortunate that this has to touch so many files, but given that the build is organized the way it is, I don't see a better option. Modifying files fully under our control surely is the lesser evil, so ok tb unless someone objects.
clang 15 and zlib
To build src cleanly with clang-15 you'd need the diff below. The alternative would be to patch our three zlib copies and wait for upstream to fix it. A more comfortable alternative is to just neuter the warning. -Wno-unknown-warning-option prevents llvm 13 from complaining that it doesn't know about -Wno-deprecated-non-prototype and should ease the transition. I took care to only add this workaround on clang archs, and to respect the COMPILER_VERSION checks where due. ok? commit b439995c024854e130e7211b1afee5c1e3f0b1cd Author: jca Date: Sat Dec 17 19:30:28 2022 +0100 sys/arch/*/stand: work around clang 15 error in zlib Upstream issue: https://github.com/madler/zlib/issues/633 diff --git a/sys/arch/amd64/stand/Makefile.inc b/sys/arch/amd64/stand/Makefile.inc index 7e45fedcc49..d35dc33cb2d 100644 --- a/sys/arch/amd64/stand/Makefile.inc +++ b/sys/arch/amd64/stand/Makefile.inc @@ -1,6 +1,9 @@ # $OpenBSD: Makefile.inc,v 1.18 2017/07/25 13:32:14 robert Exp $ CFLAGS=${DEBUG} ${COPTS} -Oz -Wall -Werror +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +CFLAGS+= -Wno-deprecated-non-prototype -Wno-unknown-warning-option CFLAGS+= -ffreestanding -fno-stack-protector -DMDRANDOM CPPFLAGS+=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR} SACFLAGS=-D_STANDALONE diff --git a/sys/arch/arm64/stand/efiboot/Makefile b/sys/arch/arm64/stand/efiboot/Makefile index 6cbb987af65..93be268d3bf 100644 --- a/sys/arch/arm64/stand/efiboot/Makefile +++ b/sys/arch/arm64/stand/efiboot/Makefile @@ -53,6 +53,9 @@ COPTS+= -Wno-attributes -Wno-format COPTS+=-ffreestanding -fno-stack-protector COPTS+=-fshort-wchar -fPIC -fno-builtin COPTS+=-Wall -Werror +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +COPTS+=-Wno-deprecated-non-prototype -Wno-unknown-warning-option PROG.elf= ${PROG:S/.EFI/.elf/} CLEANFILES+= ${PROG.elf} ${PROG.elf}.tmp diff --git a/sys/arch/armv7/stand/efiboot/Makefile b/sys/arch/armv7/stand/efiboot/Makefile index d6ffc41bf38..fd78e744cd3 100644 --- a/sys/arch/armv7/stand/efiboot/Makefile +++ b/sys/arch/armv7/stand/efiboot/Makefile @@ -51,6 +51,9 @@ COPTS+= -ffreestanding -fno-stack-protector COPTS+=-fshort-wchar -fPIC -fno-builtin COPTS+=-Wall -Werror COPTS+=-mfloat-abi=soft +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +COPTS+=-Wno-deprecated-non-prototype -Wno-unknown-warning-option PROG.elf= ${PROG:S/.EFI/.elf/} CLEANFILES+= ${PROG.elf} ${PROG.elf}.tmp diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc index cd14f5b8954..ca70fed2124 100644 --- a/sys/arch/i386/stand/Makefile.inc +++ b/sys/arch/i386/stand/Makefile.inc @@ -2,6 +2,9 @@ CFLAGS=${DEBUG} ${COPTS} -Oz -Wall -Werror CFLAGS+= -ffreestanding -fno-stack-protector -DMDRANDOM +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +CFLAGS+= -Wno-deprecated-non-prototype -Wno-unknown-warning-option CPPFLAGS+=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR} SACFLAGS=-D_STANDALONE DEBUGFLAGS= diff --git a/sys/arch/riscv64/stand/efiboot/Makefile b/sys/arch/riscv64/stand/efiboot/Makefile index a9906d58a01..36f84cf29df 100644 --- a/sys/arch/riscv64/stand/efiboot/Makefile +++ b/sys/arch/riscv64/stand/efiboot/Makefile @@ -54,6 +54,9 @@ COPTS+= -Wno-attributes -Wno-format COPTS+=-ffreestanding -fno-stack-protector COPTS+=-fshort-wchar -fPIC -fno-builtin COPTS+=-Wall -Werror +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +COPTS+=-Wno-deprecated-non-prototype -Wno-unknown-warning-option PROG.elf= ${PROG:S/.EFI/.elf/} CLEANFILES+= ${PROG.elf} ${PROG.elf}.tmp commit 57a9510544cc42e91487b43363f5f9ba429829b0 Author: jca Date: Mon Dec 19 18:05:54 2022 +0100 sys: fix clang 15 errors with zlib While here, add -Wno-unknown-warning-option so that it's possible to build kernels with llvm 13 which doesn't understand -Wno-deprecated-non-prototype. Upstream zlib issue: https://github.com/madler/zlib/issues/633 diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64 index d2704424f34..e77c296313f 100644 --- a/sys/arch/amd64/conf/Makefile.amd64 +++ b/sys/arch/amd64/conf/Makefile.amd64 @@ -72,6 +72,9 @@ CMACHFLAGS+= -mno-retpoline NO_INTEGR_AS= -no-integrated-as CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion \ -Wno-unused-but-set-variable -Wno-gnu-folding-constant +# XXX Workaround for zlib + clang 15 +# https://github.com/madler/zlib/issues/633 +CWARNFLAGS+= -Wno-deprecated-non-prototype -Wno-unknown-warning-option .endif DEBUG?=-g diff
crunchgen and llvm 15
At first it looked like a fluke when building a release. What's this "ld -dc" command-line? Well -dc is short for --define-common, an option that has been dropped by upstream llvm(lld). IIUC this ld(1) behavior is somewhat similar to -fno-common for cc(1). base-clang already does -fno-common by default, base-gcc does not. The diff below replaces ld -dc by cc -fno-common, but TBF I'm not sure what we're trying to achieve (avoid?) here. A test (make build + release) on a base-gcc arch would be welcome. commit 6cf10f57e9d6a5c359007e7b75ed737be8954bb4 Author: jca Date: Wed Dec 28 16:36:41 2022 +0100 crunchgen: stop using ld -dc (dropped in lld 15) Instead, use cc -fno-common to prevent base-gcc from using commons. base-clang already does the right thing. diff --git a/usr.sbin/crunchgen/crunchgen.c b/usr.sbin/crunchgen/crunchgen.c index 4526290197e..6350b61195b 100644 --- a/usr.sbin/crunchgen/crunchgen.c +++ b/usr.sbin/crunchgen/crunchgen.c @@ -893,12 +893,13 @@ top_makefile_rules(FILE * outmk) fprintf(outmk, ".include \n"); fprintf(outmk, "CFLAGS+=$(NOPIE_FLAGS)\n"); fprintf(outmk, "CFLAGS+=-Oz\n"); + fprintf(outmk, "CFLAGS+=-fno-common\n"); fprintf(outmk, "CFLAGS+=-fno-stack-protector\n"); fprintf(outmk, "CFLAGS+=-fno-unwind-tables\n"); fprintf(outmk, "CFLAGS+=-fno-asynchronous-unwind-tables\n"); fprintf(outmk, "LDFLAGS+=$(NOPIE_LDFLAGS)\n"); fprintf(outmk, "STRIP?=strip\n"); - fprintf(outmk, "LINK=$(LD) -dc -r ${LDFLAGS}\n"); + fprintf(outmk, "LINK=$(LD) -r ${LDFLAGS}\n"); fprintf(outmk, "LIBS="); for (l = libdirs; l != NULL; l = l->next) fprintf(outmk, " -L%s", l->str); diff --git a/usr.sbin/crunchgen/crunchide.c b/usr.sbin/crunchgen/crunchide.c index 16e032370db..84539fb57be 100644 --- a/usr.sbin/crunchgen/crunchide.c +++ b/usr.sbin/crunchgen/crunchide.c @@ -29,7 +29,7 @@ * crunchide.c - tiptoes through an a.out symbol table, hiding all defined * global symbols. Allows the user to supply a "keep list" of symbols * that are not to be hidden. This program relies on the use of the - * linker's -dc flag to actually put global bss data into the file's + * compiler's -fno-common flag to actually put global bss data into the file's * bss segment (rather than leaving it as undefined "common" data). * * The point of all this is to allow multiple programs to be linked @@ -39,8 +39,8 @@ * small stub routine, called "foostub.c", eg: * int foo_main(int argc, char **argv){ return main(argc, argv); } * like so: - * cc -c foo.c foostub.c - * ld -dc -r foo.o foostub.o -o foo.combined.o + * cc -fno-common -c foo.c foostub.c + * ld -r foo.o foostub.o -o foo.combined.o * crunchide -k _foo_main foo.combined.o * at this point, foo.combined.o can be linked with another program * and invoked with "foo_main(argc, argv)". foo's main() and any -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
[patch] arp.c spaces nested between tabs
Hello, tech@! Minor patch for `arp(8)`. It uses some spaces between two tabs that are hard to notice. I have a syntax highlighting rule that shows such spaces[1] so I saw it while reviewing the arp.c source. I've learned my lesson trying to patch the monorepo across folder lines, so here's a patch for only just arp.c, and a list of files that match a grep[2] attached for someone else who feels the urge to be told off on the list -- I've done exactly zero work to figure out if there's any false positives (spoiler, there are just from scanning some of them) due to filetype[3] or source that's not `style(9)` formatted yet; but I'll let someone else take that windmill on if they're so inclined. I have become disinclined :) Plus, I fear if I send another large diff after going through all these cases, jmc@ won't have any free time this holiday season[4], and we can't have that. ``` Index: arp.c === RCS file: /cvs/src/usr.sbin/arp/arp.c,v retrieving revision 1.88 diff -u -p -r1.88 arp.c --- arp.c 16 Sep 2019 20:49:28 - 1.88 +++ arp.c 28 Dec 2022 04:49:15 - @@ -418,7 +418,7 @@ tryagain: if (sdl->sdl_family == AF_LINK && rtm->rtm_flags & RTF_LLINFO) { if (rtm->rtm_flags & RTF_LOCAL) return (0); - if (!(rtm->rtm_flags & RTF_GATEWAY)) + if (!(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) { case IFT_ETHER: case IFT_FDDI: ``` paultag [1]: from my ~/.exrc for vim: highlight NestedSpace ctermbg=red ctermfg=white guibg=red match NestedSpace /\t \+\t/ [2]: {openbsd monks avert your eyes: gnu grep and bash w/ 'shopt -s extglob'}: $ grep -P '\t +\t' !(gnu|sys) -ril [3]: you can never be too sure; perhaps there's some whitespace (the language) source in-tree https://en.wikipedia.org/wiki/Whitespace_(programming_language) [4]: if someone with eyes on jmc@ could give him some cookies as a thanks for his hard work, the universe would be very thankful. -- :wq bin/ed/ed.h bin/ed/io.c bin/ed/main.c bin/csh/proc.c distrib/notes/alpha/hardware etc/etc.powerpc64/MAKEDEV etc/etc.powerpc64/MAKEDEV.md games/hack/hack.end.c games/hack/hack.shk.c games/bs/bs.c games/atc/update.c games/phantasia/phantstruct.h games/cribbage/cribcur.h games/backgammon/backgammon/move.c games/canfield/canfield/canfield.c include/rpc/auth_unix.h include/protocols/talkd.h include/Makefile include/resolv.h lib/libkeynote/keynote-ver.l lib/libkeynote/keynote-verify.c lib/libkeynote/keynote.l lib/libkeynote/keynote.y lib/libpcap/grammar.y lib/libpcap/optimize.c lib/libfido2/src/u2f.c lib/libcurses/tinfo/MKfallback.sh lib/libform/form.h lib/libsndio/sio_aucat.c lib/csu/hppa/md_init.h lib/libcrypto/engine/eng_cnf.c lib/libcrypto/sha/asm/sha1-586.pl lib/libcrypto/modes/gcm128.c lib/libcrypto/modes/cfb128.c lib/libcrypto/objects/objects.txt lib/libcrypto/perlasm/x86_64-xlate.pl lib/libcrypto/x509/x509_pmaps.c lib/libcrypto/x509/x509.h lib/libcrypto/rsa/rsa_lib.c lib/libcrypto/whrlpool/wp_dgst.c lib/libcrypto/util/mkstack.pl lib/libcrypto/aes/asm/bsaes-x86_64.pl lib/libm/src/e_log.c lib/libm/src/e_fmod.c lib/libm/src/e_rem_pio2f.c lib/libm/src/e_cosh.c lib/libm/src/e_rem_pio2.c lib/libm/src/e_lgammaf_r.c lib/libm/src/s_log1pf.c lib/libm/src/s_expm1f.c lib/libm/src/e_atan2f.c lib/libm/src/s_log1p.c lib/libm/src/e_sinh.c lib/libm/src/s_erf.c lib/libm/src/e_jnf.c lib/libm/src/e_logf.c lib/libm/src/k_rem_pio2.c lib/libm/src/e_atan2.c lib/libm/src/e_remainderf.c lib/libm/src/k_rem_pio2f.c lib/libm/src/s_expm1.c lib/libm/src/e_sqrt.c lib/libm/src/e_jn.c lib/libm/src/e_fmodf.c lib/libm/src/k_cos.c lib/libm/src/e_lgamma_r.c lib/libm/src/k_tan.c lib/libm/src/e_expf.c lib/libm/src/e_atan2l.c lib/libm/src/k_sin.c lib/libc/db/btree/bt_split.c lib/libc/db/hash/hash.h lib/libc/gdtoa/ldtoa.c lib/libc/arch/powerpc/string/memmove.S lib/libc/arch/amd64/string/ffs.S lib/libc/arch/powerpc64/string/memmove.S lib/libc/arch/i386/string/ffs.S lib/libc/stdlib/merge.c lib/libc/stdlib/malloc.c lib/libc/stdlib/getopt_long.3 lib/libc/time/localtime.c lib/libc/stdio/fvwrite.c lib/libc/stdio/vfwscanf.c lib/libmenu/eti.h lib/libssl/d1_both.c lib/libssl/ssl3.h lib/libssl/tls1.h libexec/ld.so/aarch64/SYS.h libexec/ld.so/riscv64/SYS.h libexec/tradcpp/array.h libexec/login_ldap/aldap.h libexec/spamd/grey.c regress/lib/libm/msun/ctrig_test.c regress/lib/libm/msun/invctrig_test.c regress/lib/libc/popen/popen.c regress/lib/libc/arch/alpha/divremtest/divremtest.c regress/sys/kern/unveil/syscalls.c regress/usr.bin/ssh/unittests/misc/test_strdelim.c regress/usr.bin/tsort/tsort-check regress/usr.bin/openssl/appstest.sh regress/usr.sbin/pkg_add/Makefile regress/bin/ksh/bksl-nl.t regress/bin/ksh/th sbin/dhcpleased/parse.y sbin/ipsecctl/parse.y
Re: iostat(8): implement periodic display with setitimer(2)
On Wed, 28 Dec 2022 11:15:50 -0500, Scott Cheloha wrote: > Neither are arbitrary. > > The current maximum of one hundred million seconds is based on the old > nanosleep(2) limit prior to the 6.5 release. It was a documented > limit; see the manpage from the 6.4 release: > > http://man.openbsd.org/OpenBSD-6.4/nanosleep.2 > > setitimer(2) accepts intervals up to UINT_MAX seconds. This is not > documented yet, but I have a rewrite for getitimer.2 in the works. > The kernel enforces it in itimerfix(): I see. OK millert@ - todd
Re: iostat(8): implement periodic display with setitimer(2)
On Wed, Dec 28, 2022 at 08:23:57AM -0700, Todd C. Miller wrote: > On Wed, 28 Dec 2022 06:51:52 -0600, Scott Cheloha wrote: > > > On Sat, Dec 10, 2022 at 08:09:15AM -0600, Scott Cheloha wrote: > > > As with e.g. kstat(1), implementing a periodic display with > > > nanosleep(2) causes the display interval to drift. Doing it with > > > setitimer(2) prevents drift. > > > > > > ok? > > Looks fine to me. I don't see a reason to change the max interval > though--both values appear arbitrary. Neither are arbitrary. The current maximum of one hundred million seconds is based on the old nanosleep(2) limit prior to the 6.5 release. It was a documented limit; see the manpage from the 6.4 release: http://man.openbsd.org/OpenBSD-6.4/nanosleep.2 setitimer(2) accepts intervals up to UINT_MAX seconds. This is not documented yet, but I have a rewrite for getitimer.2 in the works. The kernel enforces it in itimerfix(): https://github.com/openbsd/src/blob/2b46a8cbba384f799321fc554d4d1c95563ea0a2/sys/kern/kern_time.c#L711
Re: iostat(8): implement periodic display with setitimer(2)
On Wed, 28 Dec 2022 06:51:52 -0600, Scott Cheloha wrote: > On Sat, Dec 10, 2022 at 08:09:15AM -0600, Scott Cheloha wrote: > > As with e.g. kstat(1), implementing a periodic display with > > nanosleep(2) causes the display interval to drift. Doing it with > > setitimer(2) prevents drift. > > > > ok? Looks fine to me. I don't see a reason to change the max interval though--both values appear arbitrary. - todd
Re: systat(1): vmstat: use actual elapsed time in dinfo()
On Tue, 13 Dec 2022 11:20:46 -0600, Scott Cheloha wrote: > In systat(1)'s vmstat view, dinfo() uses the global "naptime" as an > elapsed time when computing rates. > > The problem is that naptime isn't the actual elapsed time. For > example, if you force a view update by hitting the spacebar, the > actual elapsed time is obviously not naptime. > > The fix is easy. showkre() calls dinfo(), and showkre() has the real > elapsed time (etime), so just pass that as argument to dinfo(). OK millert@ - todd
Re: iostat(8): implement periodic display with setitimer(2)
On Sat, Dec 10, 2022 at 08:09:15AM -0600, Scott Cheloha wrote: > As with e.g. kstat(1), implementing a periodic display with > nanosleep(2) causes the display interval to drift. Doing it with > setitimer(2) prevents drift. > > ok? Two week ping. Index: iostat.c === RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v retrieving revision 1.45 diff -u -p -r1.45 iostat.c --- iostat.c4 Dec 2022 23:50:51 - 1.45 +++ iostat.c28 Dec 2022 12:50:46 - @@ -68,10 +68,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -85,7 +87,8 @@ extern intdk_ndrive; kvm_t *kd; char *nlistf, *memf; -inthz, reps, interval; +inthz, reps; +time_t interval; static int todo = 0; volatile sig_atomic_t wantheader; @@ -100,6 +103,7 @@ volatile sig_atomic_t wantheader; static void cpustats(void); static void disk_stats(double); static void disk_stats2(double); +static void sigalarm(int); static void sigheader(int); static void header(void); static void usage(void); @@ -113,9 +117,10 @@ int dkinit(int); int main(int argc, char *argv[]) { + struct itimerval itv; const char *errstr; + sigset_t empty; int ch, hdrcnt; - struct timespec ts; while ((ch = getopt(argc, argv, "Cc:dDIM:N:Tw:")) != -1) switch(ch) { @@ -146,7 +151,7 @@ main(int argc, char *argv[]) todo |= SHOW_TTY; break; case 'w': - interval = strtonum(optarg, 1, 1, ); + interval = strtonum(optarg, 1, UINT_MAX, ); if (errstr) errx(1, "wait is %s", errstr); break; @@ -169,12 +174,20 @@ main(int argc, char *argv[]) dkreadstats(); selectdrives(argv); - ts.tv_sec = interval; - ts.tv_nsec = 0; - /* print a new header on sigcont */ signal(SIGCONT, sigheader); + if (interval != 0) { + if (signal(SIGALRM, sigalarm) == SIG_ERR) + err(1, "signal"); + sigemptyset(); + itv.it_value.tv_sec = interval; + itv.it_value.tv_usec = 0; + itv.it_interval = itv.it_value; + if (setitimer(ITIMER_REAL, , NULL) == -1) + err(1, "setitimer"); + } + for (hdrcnt = 1;;) { if (!--hdrcnt || wantheader) { header(); @@ -188,7 +201,7 @@ main(int argc, char *argv[]) if (reps >= 0 && --reps <= 0) break; - nanosleep(, NULL); + sigsuspend(); dkreadstats(); if (last.dk_ndrive != cur.dk_ndrive) wantheader = 1; @@ -196,6 +209,11 @@ main(int argc, char *argv[]) exit(0); } +static void +sigalarm(int signo) +{ +} + /*ARGSUSED*/ static void sigheader(int signo) @@ -421,7 +439,7 @@ selectdrives(char *argv[]) errx(1, "invalid interval or drive name: %s", *argv); } if (*argv) { - interval = strtonum(*argv, 1, 1, ); + interval = strtonum(*argv, 1, UINT_MAX, ); if (errstr) errx(1, "interval is %s", errstr); if (*++argv) {
Re: systat(1): vmstat: use actual elapsed time in dinfo()
On Tue, Dec 13, 2022 at 11:20:46AM -0600, Scott Cheloha wrote: > In systat(1)'s vmstat view, dinfo() uses the global "naptime" as an > elapsed time when computing rates. > > The problem is that naptime isn't the actual elapsed time. For > example, if you force a view update by hitting the spacebar, the > actual elapsed time is obviously not naptime. > > The fix is easy. showkre() calls dinfo(), and showkre() has the real > elapsed time (etime), so just pass that as argument to dinfo(). > > ok? Ping. Index: vmstat.c === RCS file: /cvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.95 diff -u -p -r1.95 vmstat.c --- vmstat.c4 Dec 2022 18:01:57 - 1.95 +++ vmstat.c28 Dec 2022 12:47:02 - @@ -84,7 +84,7 @@ staticenum state { BOOT, TIME, RUN } st static void allocinfo(struct Info *); static void copyinfo(struct Info *, struct Info *); static float cputime(int); -static void dinfo(int, int); +static void dinfo(int, int, double); static void getinfo(struct Info *); void putint(int, int, int, int); void putintmk(int, int, int, int); @@ -443,7 +443,7 @@ showkre(void) mvprintw(DISKROW, DISKCOL + 5 + c, " %*s", l, dr_name[i]); c += 1 + l; - dinfo(i, c); + dinfo(i, c, etime); } /* and pad the DRIVESPACE */ l = DRIVESPACE - c; @@ -666,11 +666,9 @@ copyinfo(struct Info *from, struct Info } static void -dinfo(int dn, int c) +dinfo(int dn, int c, double etime) { - double words, atime, etime; - - etime = naptime; + double words, atime; c += DISKCOL;
Re: rpki-client: small geofeed parsing bug
On Thu, Dec 22, 2022 at 11:26:30AM +0100, Theo Buehler wrote: > If the line contains no location info and a comma in a comment, what > follows the comma will be interpreted as location info. Actually ignore > what's in comments by adjusting the line length. It's probably better to remove any whitespace before the comment marker as well. That would be this diff. Not sure if we should remove trailing whitespace unconditionally, probably not. Index: geofeed.c === RCS file: /cvs/src/usr.sbin/rpki-client/geofeed.c,v retrieving revision 1.8 diff -u -p -r1.8 geofeed.c --- geofeed.c 14 Dec 2022 10:45:34 - 1.8 +++ geofeed.c 22 Dec 2022 10:40:06 - @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include @@ -192,14 +193,19 @@ geofeed_parse(X509 **x509, const char *f goto out; } - /* Skip empty lines or commented lines. */ - if (linelen == 0 || line[0] == '#') - continue; - - /* zap comments */ + /* Zap comments and whitespace before them. */ delim = memchr(line, '#', linelen); - if (delim != NULL) + if (delim != NULL) { + while (delim > line && + isspace((unsigned char)delim[-1])) + delim--; *delim = '\0'; + linelen = delim - line; + } + + /* Skip empty lines. */ + if (linelen == 0) + continue; /* Split prefix and location info */ delim = memchr(line, ',', linelen);