openbsd
2 years agothe debug "name" parameter to uvm_map_immutable() is no longer needed
deraadt [Fri, 21 Oct 2022 19:13:31 +0000 (19:13 +0000)]
the debug "name" parameter to uvm_map_immutable() is no longer needed

2 years agoRemove vestigial bits of 32-bit binaries support; drop the `64' suffix in
miod [Fri, 21 Oct 2022 18:55:42 +0000 (18:55 +0000)]
Remove vestigial bits of 32-bit binaries support; drop the `64' suffix in
struct names when the matching `32' flavour got removed.

Joint work with cheloha@, all bugs mine.

2 years agoconstify quirks table
kn [Fri, 21 Oct 2022 18:29:37 +0000 (18:29 +0000)]
constify quirks table

Not that big now, but quirks are likely to grow in the feature and there is
no reason to keep them writable.

OK and tested by mglocker

2 years agostatic binaries self-mprotect their relro in crt0. mimmutable() also works
deraadt [Fri, 21 Oct 2022 18:14:09 +0000 (18:14 +0000)]
static binaries self-mprotect their relro in crt0.  mimmutable() also works
here.
ok kettenis

2 years agosigaltstack() was adapted to work on mimmutable regions (an unfortunate
deraadt [Fri, 21 Oct 2022 18:11:55 +0000 (18:11 +0000)]
sigaltstack() was adapted to work on mimmutable regions (an unfortunate
compromise...), but it means the stack can be marked immutable again.
ok kettenis

2 years agoautomatically mark immutable certain regions in program&ld.so LOADs.
deraadt [Fri, 21 Oct 2022 18:10:52 +0000 (18:10 +0000)]
automatically mark immutable certain regions in program&ld.so LOADs.
The large commented block in elf_load_psection explains the sitaution.
ok kettenis.

2 years agoconstify global identity tables
kn [Fri, 21 Oct 2022 17:45:40 +0000 (17:45 +0000)]
constify global identity tables

ah{c,d}_find_pci_device() already return their members as const.

OK krw

2 years agoAdd extra NULL check after ssl3_setup_read_buffer()
tb [Fri, 21 Oct 2022 15:48:14 +0000 (15:48 +0000)]
Add extra NULL check after ssl3_setup_read_buffer()

While ssl3_setup_read_buffer() success alone is enough to imply that
the read bufer is non-NULL, several static analyzers fail to recognize
that and throw fits about possible NULL accesses.

CID 331010

Fix from and ok jsing

2 years agotlsexttest.c: make various static structs const
tb [Fri, 21 Oct 2022 14:58:53 +0000 (14:58 +0000)]
tlsexttest.c: make various static structs const

2 years agoquic tlsext tests: use byte vector in place of string
tb [Fri, 21 Oct 2022 14:55:54 +0000 (14:55 +0000)]
quic tlsext tests: use byte vector in place of string

While this doesn't actually change anything, it should appease Coverity.

CID 358678
CID 358679

2 years agoGrab the non-exclusive net lock to read-only traverse the interface list
kn [Fri, 21 Oct 2022 14:20:03 +0000 (14:20 +0000)]
Grab the non-exclusive net lock to read-only traverse the interface list

Destroying lo(4) interfaces checks for other interfaces in the same
rdomain(4) first which does not modify anything, so allow other readers.

All interface ioctl(2)s currently run with the kernel lock held, so this
should not make a real difference...

OK mvs

2 years agoAdd EVP_chacha20_poly1305()
tb [Fri, 21 Oct 2022 13:39:35 +0000 (13:39 +0000)]
Add EVP_chacha20_poly1305()

Omission reported by jca.

ok jca jsing

2 years agosync
sthen [Fri, 21 Oct 2022 12:40:21 +0000 (12:40 +0000)]
sync

2 years agoFix synopsis, -n does not require an interface; OK jmc
kn [Fri, 21 Oct 2022 12:04:51 +0000 (12:04 +0000)]
Fix synopsis, -n does not require an interface; OK jmc

2 years agoDocument contents of acpicpu's dmesg lines
guenther [Fri, 21 Oct 2022 04:02:16 +0000 (04:02 +0000)]
Document contents of acpicpu's dmesg lines

formating help from jcw@ and schwarze@
ok mlarkin@

2 years agoAdd the hooks to disable and enable GPIO interrupts. Should fix potential
kettenis [Thu, 20 Oct 2022 20:40:57 +0000 (20:40 +0000)]
Add the hooks to disable and enable GPIO interrupts.  Should fix potential
interrupt storms related to level-triggered interrupts.

ok mglocker@

2 years agoAdd RK3568 support.
kettenis [Thu, 20 Oct 2022 20:35:57 +0000 (20:35 +0000)]
Add RK3568 support.

ok jmatthew@

2 years agoadd zap-to-char and zap-up-to-char; bind zap-to-char to M-z.
op [Thu, 20 Oct 2022 18:59:24 +0000 (18:59 +0000)]
add zap-to-char and zap-up-to-char; bind zap-to-char to M-z.

ok florian@

2 years agoDon't attempt to use EFI runtime services on UEFI versions before 2.1.
kettenis [Thu, 20 Oct 2022 18:43:35 +0000 (18:43 +0000)]
Don't attempt to use EFI runtime services on UEFI versions before 2.1.
The Dell Precision T1600 has a UEFI 2.0 implementation where calling
GetTime() accesses memory that isn't covered by a runtime mapping.
And frankly UEFI 2.0 is so ancient that we don't really want to use it
anyway.

This also adds the check to the arm64 version even though UEFI versions
before 2.4 don't have arm64 support.  But for now I want to keep amd64
and arm64 code as similar as possible.

ok kn@

2 years agoConstify global product table
kn [Thu, 20 Oct 2022 16:08:13 +0000 (16:08 +0000)]
Constify global product table

Looking for .rodata candidates in /bsd .data symbols, this one popped up:
ffffffff82281b70 l     O .data  0000000000001688 asmc_prods

OK jung

2 years agoSync sys libz with base
tb [Thu, 20 Oct 2022 15:36:47 +0000 (15:36 +0000)]
Sync sys libz with base

2 years agoUpdate base libz to 1.2.13
tb [Thu, 20 Oct 2022 15:35:31 +0000 (15:35 +0000)]
Update base libz to 1.2.13

This update contains a few bugfixes (some of which we have already
backported to 1.2.12) and a ton of cosmetic changes. The relevant
bits of the ChangeLog are:

- Repair prototypes and exporting of new CRC functions
- Have infback() deliver all of the available output up to any error
- Fix a bug when getting a gzip header extra field with inflate()
- Fix bug in block type selection when Z_FIXED used
- Tighten deflateBound bounds
- Remove deleted assembler code references
- Various portability and appearance improvements

Tested on amd64 and arm64 by me and on sparc64 by kn.

2 years agoInitial parsing of the NewSessionTicket message
tb [Thu, 20 Oct 2022 15:26:25 +0000 (15:26 +0000)]
Initial parsing of the NewSessionTicket message

TLSv1.3 introduces a New Session Ticket post-handshake handshake message
that allows a unique association between a ticket value and a pre-shared
key derived from the resumption master secret. Servers may send this
message arbitrarily often at any time after receiving the client's
Finished message.

Implement tls13_new_session_ticket_recv() which parses the contents of
the NewSessionTicket message into a fresh session derived from the
current session so as to avoid modifying sessions that are already in
the session cache.

This uses tls13_new_session_ticket_recv() in tls13_phh_received_cb().
We currently rely on the general rate limiting of 100 PHH messages per
connection and hour to avoid problems from connecting to a misbehaving
or malicious server.

ok jsing

2 years agoProvide TLS13_MAX_TICKET_LIFETIME #define
tb [Thu, 20 Oct 2022 15:23:43 +0000 (15:23 +0000)]
Provide TLS13_MAX_TICKET_LIFETIME #define

TLSv1.3 servers must not indicate a lifetime longer than 7 days and
clients must not cache sessions for longer than 7 days. Encode this
in a macro internal to tls13_lib.c for now.

ok jsing

2 years agoProvide ssl_session_dup()
tb [Thu, 20 Oct 2022 15:22:51 +0000 (15:22 +0000)]
Provide ssl_session_dup()

SSL_SESSION_dup() is a currently essentially unused public OpenSSL 1.1.1
API. Add a version that does not duplicate the secrets for internal use.
If the public API should be needed, we can easily make it a wrapper.

ok jsing

2 years agoClean up resumption master secret in SSL_SESSION_free()
tb [Thu, 20 Oct 2022 15:21:22 +0000 (15:21 +0000)]
Clean up resumption master secret in SSL_SESSION_free()

ok jsing

2 years agoExtend SSL_SESSION struct for TLSv1.3 PSK
tb [Thu, 20 Oct 2022 15:20:27 +0000 (15:20 +0000)]
Extend SSL_SESSION struct for TLSv1.3 PSK

Add members necessary to store the "ticket_age_add" value and the
resumption master secret needed in the TLSv1.3 version of session
resumption.

ok jsing

2 years agoAnnotate misuse of EVP_Digest()
tb [Thu, 20 Oct 2022 15:18:54 +0000 (15:18 +0000)]
Annotate misuse of EVP_Digest()

The session_id member of SSL_SESSION has 32 bytes for historical
reasons.  This precisely accommodates a SHA-256 and is currently
computed using this hash.  If the hash function is ever changed,
this will likely overflow.  This should be fixed in code.  Leave
it at an XXX comment for now.

Pointed out by jsing

2 years agoAccess to `u_flags' should be serialized by the `vmobjlock'.
mpi [Thu, 20 Oct 2022 13:31:52 +0000 (13:31 +0000)]
Access to `u_flags' should be serialized by the `vmobjlock'.

This complete previous fix from gnezdo@.  The uvm_vnp_sync() still
requires some love and isn't addressed by this diff.

Document which lock is protecting vnode variables.

ok gnezdo@

2 years agoRemove the single part string for DS1339, since that is only required on
mglocker [Thu, 20 Oct 2022 10:35:35 +0000 (10:35 +0000)]
Remove the single part string for DS1339, since that is only required on
sparc64 because OpenFirmware doesn't support the <vendor>,<part> compatible
pattern.  We don't expect this chip to turn up on sparc64.

Suggested and ok kettenis@

2 years agoampintc(4) is specifically for GIC v1/v2
jsg [Thu, 20 Oct 2022 08:52:22 +0000 (08:52 +0000)]
ampintc(4) is specifically for GIC v1/v2

2 years agoadd manual page for Arm GIC v3/v4 driver
jsg [Thu, 20 Oct 2022 08:45:39 +0000 (08:45 +0000)]
add manual page for Arm GIC v3/v4 driver

2 years agoremove file no longer present in unbound 1.17.0
sthen [Thu, 20 Oct 2022 08:28:00 +0000 (08:28 +0000)]
remove file no longer present in unbound 1.17.0

2 years agomerge unbound 1.17.0
sthen [Thu, 20 Oct 2022 08:26:14 +0000 (08:26 +0000)]
merge unbound 1.17.0

2 years agoimport unbound 1.17.0, ok florian
sthen [Thu, 20 Oct 2022 08:25:16 +0000 (08:25 +0000)]
import unbound 1.17.0, ok florian

2 years agoLink rust-openssl to regress
tb [Thu, 20 Oct 2022 07:38:05 +0000 (07:38 +0000)]
Link rust-openssl to regress

2 years agoProvide a harness driving rust-openssl's regress tests
tb [Thu, 20 Oct 2022 07:33:14 +0000 (07:33 +0000)]
Provide a harness driving rust-openssl's regress tests

rust-openssl is an integral part of the Rust ecosystem and more than a
dozen ports, including lang/rust itself, depend on it. We need to ensure
that it keeps working with LibreSSL.

If the rust and rust-openssl-tests packages are installed, create a cargo
workspace under obj/ that compiles and runs the rust-openssl regress tests
much like what is done for the openssl-ruby tests. This expands our regress
coverage: for instance, this would have caught the broken ASN.1 indefinite
length encoding caused by asn1/tasn_enc.c r1.25.

Positive feedback beck jsing semarie
Testing and ok anton

2 years agoDisplay the correct recipient in a Received: header with one recipient.
millert [Thu, 20 Oct 2022 01:16:04 +0000 (01:16 +0000)]
Display the correct recipient in a Received: header with one recipient.
If multiple recipients are specified but only one is valid, use the
first entry in the recipient list for the Received: header, not the
value from the last "RCPT TO:" command (which could be invalid).
From Chris Waddey

2 years agoExclude /tmp/*.shm files from /tmp cleaning in daily(8); removing them
sthen [Wed, 19 Oct 2022 21:23:31 +0000 (21:23 +0000)]
Exclude /tmp/*.shm files from /tmp cleaning in daily(8); removing them
interferes with programs using shm_open(3) which uses them as backing
files.

Problem pointed out by jeremy@ in relation to PostgreSQL.
Suggestion/ok tb@.

2 years agoDrop support for $rcexec; people should now use the rc_exec function.
ajacoutot [Wed, 19 Oct 2022 21:04:45 +0000 (21:04 +0000)]
Drop support for $rcexec; people should now use the rc_exec function.

prodded by jsg@

2 years agoRemove unused setfd member from struct audio_hw_if
kn [Wed, 19 Oct 2022 19:59:06 +0000 (19:59 +0000)]
Remove unused setfd member from struct audio_hw_if

All consumers now use C99 struct init and none of them sets `.setfd'.

OK ratchov miod

2 years agoUse C99 struct init for struct audio_hw_if
kn [Wed, 19 Oct 2022 19:14:16 +0000 (19:14 +0000)]
Use C99 struct init for struct audio_hw_if

This audio(9) struct will lose a member, but drivers init their struct quite
inconsistently, most pre-C99 style.

Use C99 style everywhere, to get rid of all annoying differences and allow
for easy member removals/additions:
- don't change current order of members
- no explicit NULL members
- no comments or blank lines
- trailing comma in last member line

GENERIC.MP builds fine with this on arm64, amd64, i386 and sparc64.

macppc and alpha build-tested by miod
OK ratchov miod

2 years agoReplace "newfs/fsck_ext2fs" with "newfs/msdos -t ext2fs", constify
kn [Wed, 19 Oct 2022 19:08:25 +0000 (19:08 +0000)]
Replace "newfs/fsck_ext2fs" with "newfs/msdos -t ext2fs", constify

OK miod

2 years agoDocument sigaltstack restrictions on OpenBSD.
deraadt [Wed, 19 Oct 2022 18:29:36 +0000 (18:29 +0000)]
Document sigaltstack restrictions on OpenBSD.
mandoc suggestions & help from jmc

2 years agoRemove audio(9) setfd() stub
kn [Wed, 19 Oct 2022 15:34:02 +0000 (15:34 +0000)]
Remove audio(9) setfd() stub

necsb(4/luna88k) is the only driver that "implements" it... through EIO.

Remove it so setfd can be removed from struct audio_hw_if.

Prodded by ratchov
OK aoyama

2 years agoConstify global tables only used in lookups, OK ratchov
kn [Wed, 19 Oct 2022 09:11:26 +0000 (09:11 +0000)]
Constify global tables only used in lookups, OK ratchov

2 years agoGet rid of useless/confusing subshell
kn [Wed, 19 Oct 2022 08:24:14 +0000 (08:24 +0000)]
Get rid of useless/confusing subshell

Other function, same stuff like r1.1210 except here there `>/dev/null 2>&1'
hammer is required to silence the ls(1) test.

The make_dev() call is no longer silenced now but does not print on stdout
anyway;  if making the device fails we'd like to know.

Otherwise if probing the disk fails it continues to be silenced.

(cvs diff -w -U1)
|@@ -2311,3 +2311,2 @@ is_rootdisk() {
|
|- (
|  make_dev $_d
|@@ -2322,6 +2321,6 @@ is_rootdisk() {
|  umount /mnt
|- fi
|+ fi >/dev/null 2>&1
|  rm -f /dev/{r,}$_d?
|+
|  return $_rc
|- ) >/dev/null 2>&1
| }

OK halex

2 years agoConstify audio_hw_if struct
kn [Wed, 19 Oct 2022 07:59:26 +0000 (07:59 +0000)]
Constify audio_hw_if struct

The only driver with a non-const audio(9) struct.

OK gnezdo

2 years agoConstify string tables
kn [Wed, 19 Oct 2022 07:57:49 +0000 (07:57 +0000)]
Constify string tables

Each only used one for a printf() call in *_attach().
Seen while tweaking their *_hw_if struct.

OK gnezdo ratchov

2 years agoAdd support for the DS1339 RTC, like found on the PiJuice.
mglocker [Tue, 18 Oct 2022 16:07:59 +0000 (16:07 +0000)]
Add support for the DS1339 RTC, like found on the PiJuice.

From Michal Mynar -- Thanks!

ok deraadt@

2 years agoNo longer match on "apple,cluster-cpufreq" compatible string.
kettenis [Tue, 18 Oct 2022 15:12:13 +0000 (15:12 +0000)]
No longer match on "apple,cluster-cpufreq" compatible string.

ok miod@, kn@

2 years agoRemove references to four definitions that tb@ deleted in x509.h rev. 1.89
schwarze [Tue, 18 Oct 2022 14:55:19 +0000 (14:55 +0000)]
Remove references to four definitions that tb@ deleted in x509.h rev. 1.89
on Jan 10, 2022: X509_EX_V_INIT X509_EX_V_NETSCAPE_HACK
X509_EXT_PACK_STRING X509_EXT_PACK_UNKNOWN.

Mark BN_set_params and BN_get_params as deprecated, unused,
and intentionally undocumented.

2 years agoCopy port to proxyport since the sting may point into memory that is
claudio [Tue, 18 Oct 2022 14:03:39 +0000 (14:03 +0000)]
Copy port to proxyport since the sting may point into memory that is
freed.

Should fix https://github.com/rpki-client/rpki-client-portable/issues/74
Reported by Ben Castricum
OK tb@

2 years agoSwitch from up/down time to time of last change.
claudio [Tue, 18 Oct 2022 12:28:36 +0000 (12:28 +0000)]
Switch from up/down time to time of last change.

Having metrics depend on session state makes reporting more complex.
This now reports the number of seconds a session was up or down.
OK tb@

2 years agoInitalize last_updown in init_peer() so that it is reported correctly
claudio [Tue, 18 Oct 2022 12:24:51 +0000 (12:24 +0000)]
Initalize last_updown in init_peer() so that it is reported correctly
for peers that never managed to establish a connection.
OK tb@

2 years agoAdd definitions for runtime services related to EFI variables and system
kettenis [Tue, 18 Oct 2022 10:17:56 +0000 (10:17 +0000)]
Add definitions for runtime services related to EFI variables and system
reset.

ok krw@

2 years agoFix some spelling errors
job [Tue, 18 Oct 2022 09:30:29 +0000 (09:30 +0000)]
Fix some spelling errors

Thanks Marco D'Itri for spotting them

OK claudio@

2 years agoRemove unused AUDIO_PROP_{MMAP,INDEPENDENT}
kn [Tue, 18 Oct 2022 08:22:18 +0000 (08:22 +0000)]
Remove unused AUDIO_PROP_{MMAP,INDEPENDENT}

AUDIO_PROP_FULLDUPLEX is the only audio(9) in use, the other two died with
commit 1cf2860827c8ca659d8097d8da94a5ae5b888c53
Author: ratchov <ratchov@openbsd.org>
Date:   Thu Jun 25 06:43:45 2015 +0000

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.

but remained defined and set in drivers.

and the following merely moved them when they were dead code already:

commit 9215aa3dfad387bca877a805534df6dcfe8722eb
Author: ratchov <ratchov@openbsd.org>
Date:   Wed Aug 31 07:22:43 2016 +0000

    Delete unused ioctls and associated macros. Move macros that are still
    used internally by low-level drivers from sys/audioio.h to
    dev/audio_if.h instead of deleting them.

None of this is used in base or ports;  codesearch.debian.net only shows
AUDIO_PROP_{CAPTURE,PLAYBACK} in firefox-esr, mozjs and cubeb.

ratchov points out that audio_if.h and audioio.h are private interfaces
and the codesearch shows SunOS and NetBSD bits (#ifdef'd out on OpenBSD).

OK ratchov

2 years agoDocument and report mpii(4) RAID 1E as such
kn [Tue, 18 Oct 2022 07:04:20 +0000 (07:04 +0000)]
Document and report mpii(4) RAID 1E as such

At least the built-in controller on sparc64 T4-2 machines supports 1E from
which OpenBSD boots just fine, but bioctl(8) reports it as RAID 10:

mpii0 at pci15 dev 0 function 0 "Symbios Logic SAS2008" rev 0x03: msi
mpii0: Solana On-Board, firmware 9.0.0.0 IR, MPI 2.0
scsibus1 at mpii0: 834 targets
sd0 at scsibus1 targ 0 lun 0: <LSI, Logical Volume, 3000> naa.600508e0000000006cd1dcd59022a30a
sd0: 713824MB, 512 bytes/sector, 1461911552 sectors
root on sd0a (efde5b2c6ab7b8ac.a) swap on sd0b dump on sd0b

# bioctl mpii0
Volume      Status               Size Device
    mpii0 0 Online       748498714112 sd0     RAID10
  0 Online       500107861504 0:2.0   noencl <ATA CT500MX500SSD1>
  1 Online       500107861504 0:1.0   noencl <ATA CT500MX500SSD1>
  2 Online       500107861504 0:0.0   noencl <ATA CT500MX500SSD1>

mpii(4) simply munged 1E into 10.
Report it as 0x1E just like softraid(4) RAID 1C is 0x1C internally:

# ./obj/bioctl mpii0 | grep RAID
    mpii0 0 Online       748498714112 sd0     RAID1E

OK jsing

2 years agoHoist common Volume, Status, Size and Device columns in format strings
kn [Tue, 18 Oct 2022 06:56:42 +0000 (06:56 +0000)]
Hoist common Volume, Status, Size and Device columns in format strings

Only the RAID level itself with level specific values in the end differs.

OK jsing

2 years agoImplement uncached mappings on the StarFive JH7100 SoC, where the hardware
kettenis [Mon, 17 Oct 2022 19:51:54 +0000 (19:51 +0000)]
Implement uncached mappings on the StarFive JH7100 SoC, where the hardware
provides allows bypassing the L2 cache by using a physical address alias.

ok miod@

2 years agoConvert more drivers to use todr_attach(). The quality of the RTC is
kettenis [Mon, 17 Oct 2022 19:09:46 +0000 (19:09 +0000)]
Convert more drivers to use todr_attach().  The quality of the RTC is
set such that "discrete" RTC chips are preferred over RTCs integrated on
a SoC.

ok deraadt@, miod@

2 years agoStore errors that result from leaf certificate verification.
jsing [Mon, 17 Oct 2022 18:56:54 +0000 (18:56 +0000)]
Store errors that result from leaf certificate verification.

In the case that a verification callback is installed that tells the
verifier to continue when a certificate is invalid (e.g. expired),
any error resulting from the leaf certificate verification is not stored
and made available post verification, resulting in an incorrect error being
returned.

Also perform leaf certificate verification prior to adding the chain, which
avoids a potential memory leak (as noted by tb@).

Issue reported by Ilya Shipitsin, who encountered haproxy regress failures.

ok tb@

2 years agoFix "map" OpenFirmware call. It does not return a value according to the
kettenis [Mon, 17 Oct 2022 18:55:20 +0000 (18:55 +0000)]
Fix "map" OpenFirmware call.  It does not return a value according to the
IEEE 1275 specification.  This should fix booting on machines that would
fail with something like:

OF_map_phys(3fe44000,8192,fed58000,-1) failed
no space for symbol table
Program terminated

Based on a diff provided by Harald Gutch (hgutch@netbsd).  Also see
NetBSD PR#56829.

There were (and still are) some questions about whether this diff breaks
the blade1.5k. However the failure in question might have been hardware
related and subsequent testing of the equivalent kernel diff (which
was just committed) was successful.  So committing this in the hope it
sticks to ease testing.

ok miod@

2 years agoFix "map" OpenFirmware call. It does not return a value according to the
kettenis [Mon, 17 Oct 2022 18:49:06 +0000 (18:49 +0000)]
Fix "map" OpenFirmware call.  It does not return a value according to the
IEEE 1275 specification.

Based on a diff provided by Harald Gutch (hgutch@netbsd).  Also see
NetBSD PR#56829.

ok miod@

2 years agoRevise expire callback regress to use chains with expired certificates.
jsing [Mon, 17 Oct 2022 18:44:36 +0000 (18:44 +0000)]
Revise expire callback regress to use chains with expired certificates.

Rather than using X509_STORE_CTX_set_time() (which is resulting all
certificates in the chain being treated as expired), use chains that have
an expired leaf or expired intermediate. This triggers a different code
path, which is currently mishandled (and hence failing).

Also ensure that the resulting error and error depth match what we expect
them to be.

2 years agoEnsure that verification results in the expected error and error depth.
jsing [Mon, 17 Oct 2022 18:36:52 +0000 (18:36 +0000)]
Ensure that verification results in the expected error and error depth.

Improve verification regress and ensure that the legacy or modern
verification completes with the expected error and error depth.

2 years agoAvoid potential divide by zero in BIO_dump_indent_cb()
jsing [Mon, 17 Oct 2022 18:26:41 +0000 (18:26 +0000)]
Avoid potential divide by zero in BIO_dump_indent_cb()

Passing an indent value of 67 results in DUMP_WIDTH_LESS_IDENT returning a
value of zero, which is promptly used for division. Likewise, passing a
value larger than 67 results in a negative value being returned.

Prevent this by limiting indent to 64 (which matches OpenSSL's current
behaviour), as well as ensuring that dump_width is > 0.

Should fix oss-fuzz #52464 and #52467.

ok miod@ tb@

2 years agoUnbreak ASN.1 indefinite length encoding.
jsing [Mon, 17 Oct 2022 18:03:15 +0000 (18:03 +0000)]
Unbreak ASN.1 indefinite length encoding.

In r1.25 of tasn_enc.c a check was added to ensure that asn1_ex_i2c()
returned the same value on both calls, however in the ndef case the len
variable gets changed between calls. Keep a copy of the original value to
test against.

Issue reported by niklas, who encountered a test failure in rust-openssl.

ok miod@ tb@

2 years agoSHOW_METRICS for the actions enum. Just to match the rest.
claudio [Mon, 17 Oct 2022 16:51:36 +0000 (16:51 +0000)]
SHOW_METRICS for the actions enum. Just to match the rest.

2 years agoDocument /metrics endpoint and use bgpctl show metrics as command.
claudio [Mon, 17 Oct 2022 15:42:19 +0000 (15:42 +0000)]
Document /metrics endpoint and use bgpctl show metrics as command.
OK tb@

2 years agoUse metrics as the command name and document show metrics.
claudio [Mon, 17 Oct 2022 15:04:12 +0000 (15:04 +0000)]
Use metrics as the command name and document show metrics.
OK tb@

2 years agoChange pru_abort() return type to the type of void and make pru_abort()
mvs [Mon, 17 Oct 2022 14:49:01 +0000 (14:49 +0000)]
Change pru_abort() return type to the type of void and make pru_abort()
optional.

We have no interest on pru_abort() return value. We call it only from
soabort() which is dummy pru_abort() wrapper and has no return value.

Only the connection oriented sockets need to implement (*pru_abort)()
handler. Such sockets are tcp(4) and unix(4) sockets, so remove existing
code for all others, it doesn't called.

ok guenther@

2 years agoAdd /metrics endpoint which outputs stats in openmetrics format.
claudio [Mon, 17 Oct 2022 13:23:31 +0000 (13:23 +0000)]
Add /metrics endpoint which outputs stats in openmetrics format.

This uses `bgpctl show metric` to produce the payload.
OK tb@

2 years agoImplement openmetric output via bgpctl show metric command
claudio [Mon, 17 Oct 2022 12:01:19 +0000 (12:01 +0000)]
Implement openmetric output via bgpctl show metric command

This adds most of the generic code to output the metrics with labels
and implements some basic metrics. The code works but metrics may still
change.

OK tb@

2 years agoPreserve marked pane when renumbering windows.
nicm [Mon, 17 Oct 2022 10:59:42 +0000 (10:59 +0000)]
Preserve marked pane when renumbering windows.

2 years agoImprove the clickpad/touchpad detection in hidmt.
bru [Sun, 16 Oct 2022 20:17:08 +0000 (20:17 +0000)]
Improve the clickpad/touchpad detection in hidmt.

If the HID descriptors don't provide a HUD_BUTTON_TYPE property, hidmt
should treat all devices as clickpads if they report a "clickpad button",
or don't report to have both a left and right external button.

2 years agoFix a bug in the initialization mechanism of wsmouse.
bru [Sun, 16 Oct 2022 18:23:44 +0000 (18:23 +0000)]
Fix a bug in the initialization mechanism of wsmouse.

The CONFIGURED flag, which indicates that first-time initialization
has been completed, must be set immediately after the first call to
wstpad_configure.  Otherwise, passing touchpad parameters to the
initialization function has no effect for some of them.

2 years agoRather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
deraadt [Sun, 16 Oct 2022 16:27:02 +0000 (16:27 +0000)]
Rather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
go back to the old approach: using a new anon mapping because it removes
any potential gadgetry pre-placed in the region (by making it zero).  But
also bring in a few more validation checks beyond contigious mapping -- it
must not be a syscall region, and the protection must be precisely RW.
This does allow sigaltstack() to shoot zero'd MAP_STACK non-immutable regions
into the main stack area (which will soon be immutable).  I am not sure we
can keep reinforce immutable on the region after we do stack (like maybe
determine this while doing the validation entry walk?)
Sadly, continued support for sigaltstack() does require selecting the guessed
best compromise.
ok kettenis

2 years agoRather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
deraadt [Sun, 16 Oct 2022 16:16:37 +0000 (16:16 +0000)]
Rather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
go back to the old approach: using a new anon mapping because it removes
any potential gadgetry pre-placed in the region (by making it zero).  But
also bring in a few more validation checks beyond contigious mapping -- it
must not be a syscall region, and the protection must be precisely RW.
This does allow sigaltstack() to shoot zero'd MAP_STACK non-immutable regions
into the main stack area (which will soon be immutable).  I am not sure we
can keep reinforce immutable on the region after we do stack (like maybe
determine this while doing the validation entry walk?)
Sadly, continued support for sigaltstack() does require selecting the guessed
best compromise.
ok kettenis

2 years agoAdd the guts for EFI runtime services support on amd64. This will be used
kettenis [Sun, 16 Oct 2022 15:03:39 +0000 (15:03 +0000)]
Add the guts for EFI runtime services support on amd64.  This will be used
in the future to implement support for things like EFI variables.

ok krw@ (a few others ok'ed earlier incarnations of this diff)

2 years agodon't use | operator where || was intended
jsg [Sun, 16 Oct 2022 13:33:10 +0000 (13:33 +0000)]
don't use | operator where || was intended
ok gnezdo@ kn@ martijn@

2 years agoAdd new failing read/signal test
kn [Sun, 16 Oct 2022 12:34:13 +0000 (12:34 +0000)]
Add new failing read/signal test

^C does not abort `read < /dev/zero', instead it read(2)s indefinitely,
one null byte at a time;  bash and ksh93 from ports abort as expected.

Use the new timeout(1) $PROG trick to send ^C after 0.1s, but also
rely on it's -k for the final SIGKILL to stop the busy-looping process.

./th's `time-limit: 1' prints "test timed out (limit of 1 seconds)" but
leaves the process running.

2 years agoAdd new trap/errexit/signal test simulating interactive usage
kn [Sun, 16 Oct 2022 10:44:06 +0000 (10:44 +0000)]
Add new trap/errexit/signal test simulating interactive usage

First try add capturing use cases like the bin/ksh/main.c r1.52 one:
"[...] we would not run the signal trap if,
for example, ^C was pressed and -e was set."

With so many different factors (errexit?, receiving (special) signals,
traps themselves failing/returing non-zero, running child processes?, etc.)
it is very easy to miss subtle behaviour changes during scripting...

2 years agomove/rename usr1 test to new signal block, tweak other name
kn [Sun, 16 Oct 2022 10:19:02 +0000 (10:19 +0000)]
move/rename usr1 test to new signal block, tweak other name

2 years agoAlways pass the test program as PROG env var, fix synopsis
kn [Sun, 16 Oct 2022 08:49:03 +0000 (08:49 +0000)]
Always pass the test program as PROG env var, fix synopsis

The ./th perl script always runs -p prog (KSH in Makefile) as the shell,
but cannot signal it other than the optional SIGKILL after `time-limit'.

Implementing time-related signal handling in ./th seems overkill, so always
pass the program as PROG in the environment so it can wrap itself, e.g.
description:
simluate interrupting a script
stdin:
timeout --signal SIGINT --preserve-status -- 1s $PROG -c '
actual test script getting ^C after one second...
'

Avoiding hard-coded programs in tests with PROG allows testing different
shells through `make KSH=/path/to/sh' without changing or adding shell
specific tests.

While here, make -p and -s as mandatory in usage as ./th `die's if they're
not passed (allowing to always just pass -p's argument as PROG).

2 years agoLeave installurl handling to syspatch(8)
kn [Sun, 16 Oct 2022 08:47:20 +0000 (08:47 +0000)]
Leave installurl handling to syspatch(8)

When upgrading to releases, the installer fills rc.firsttime(8) with
a syspatch(8) snippet possibly displaying available patches.

That snippet itself checks for a release version as well as an existent
installurl(5) file as a precondition for syspatch, see the diff below.

syspatch, however, has code to fallback to cdn.o.o without a valid URL:

286 _MIRROR=$(while read _line; do _line=${_line%%#*}; [[ -n ${_line} ]] &&
287 print -r -- "${_line}"; done </etc/installurl | tail -1) 2>/dev/null
288 [[ ${_MIRROR} == @(file|ftp|http|https)://* ]] ||
289 _MIRROR=https://cdn.openbsd.org/pub/OpenBSD
290 _MIRROR="${_MIRROR}/syspatch/${_KERNV[0]}/$(machine)"

Furthermore, the installer actively sets a working URL if needed, in the
same finish_up() function shortly before placing the syspatch snippet:

2842 # Create /etc/installurl if it does not yet exist.
2843 if [[ ! -f /mnt/etc/installurl ]]; then
2844 echo "${INSTALL_URL:-https://cdn.openbsd.org/pub/OpenBSD}" \
2845 >/mnt/etc/installurl
2846 fi

So one of the following is true for installurl:
1. exists but has no valid URL, then syspatch falls back to cdn.o.o
2. exists and has a  valid URL, then syspatch uses that
3. does not exist so the installer creates it with cdn.o.o, see 2.

In the unlikely case that the install/upgrade finishes, i.e. installurl
does exist, but gets removed or truncated before rc.firsttime runs, the
existing check would actually prevent syspatch from running even though
it copes with such files.

So just remove the useless check.

OK aja

2 years agoChange function definitions using the identifier-list form used in the
jsg [Sun, 16 Oct 2022 01:22:39 +0000 (01:22 +0000)]
Change function definitions using the identifier-list form used in the
1st edition of Kernighan and Ritchie's The C Programming Language, to
that of the parameter-type-list form described in the ANSI X3.159-1989
standard.

In ISO/IEC 9899:2023 drafts, there is only one form of function definition.
"N2432 Remove support for function definitions with identifier lists".

ok kettenis@

2 years agoConvert remaining I2C RTC drivers to use todr_attach().
kettenis [Sat, 15 Oct 2022 18:22:53 +0000 (18:22 +0000)]
Convert remaining I2C RTC drivers to use todr_attach().
These all get a quality of 1000 since these are supposed to be battery
backed and almost certainly what the hardware designers want us to use.

ok mglocker@, jsg@

2 years agoreplace ewprintf("") calls with eerase(): no functional difference.
op [Sat, 15 Oct 2022 17:01:14 +0000 (17:01 +0000)]
replace ewprintf("") calls with eerase(): no functional difference.

ok florian@

2 years agofix comments wrt. pending ksh fixes
kn [Sat, 15 Oct 2022 15:29:45 +0000 (15:29 +0000)]
fix comments wrt. pending ksh fixes

2 years ago.Oc -> .Op in previous;
jmc [Sat, 15 Oct 2022 15:18:15 +0000 (15:18 +0000)]
.Oc -> .Op in previous;

2 years agoansi
jsg [Sat, 15 Oct 2022 14:58:54 +0000 (14:58 +0000)]
ansi

2 years agoDo not throw away errno.
florian [Sat, 15 Oct 2022 13:27:45 +0000 (13:27 +0000)]
Do not throw away errno.

Pointed out in the pref64 code, which was copied from here, by kn.

2 years agoImplement RFC 8781 PREF64 router advertisement option.
florian [Sat, 15 Oct 2022 13:26:15 +0000 (13:26 +0000)]
Implement RFC 8781 PREF64 router advertisement option.

With this clients can learn the presence and used prefix for Network
Address and Protocol Translation between IPv6 and IPv4 (NAT64).

Apparently there is support in mobile devices as well as in macOS.

This option, together with the the dhcp "IPv6-only preferred"
option (108) enables the Customer-side transLATor (CLAT) on macOS so
IPv4 literals can be used in IPv6-only networks.

Input & OK kn

2 years agoansi
jsg [Sat, 15 Oct 2022 10:12:12 +0000 (10:12 +0000)]
ansi

2 years agotypo in comment: Funtion -> Function
op [Sat, 15 Oct 2022 09:54:29 +0000 (09:54 +0000)]
typo in comment: Funtion -> Function

2 years agoansi
jsg [Sat, 15 Oct 2022 08:41:18 +0000 (08:41 +0000)]
ansi

2 years agoansi
jsg [Sat, 15 Oct 2022 08:04:02 +0000 (08:04 +0000)]
ansi

2 years agoremove one of the debug messages
deraadt [Sat, 15 Oct 2022 05:56:01 +0000 (05:56 +0000)]
remove one of the debug messages