openbsd
18 months agoDo not attempt to write to read-only softraid
kn [Tue, 25 Apr 2023 10:11:20 +0000 (10:11 +0000)]
Do not attempt to write to read-only softraid

Bootloaders have no write support for softraid volumes, which manifests in,
e.g. /bsd.upgrade not being stripped of its 'x' permission bit to prevent
sysupgrade loops in case of upgrade failure.

Set a no-write flag handled by libsa to bail out early in write calls.
There should be no real behaviour change, writes just fail earlier now.

amd64 EFI bits, other architectues to come.  Crank minor.

"seems sensible" jsing

18 months agoDo not attempt to write to read-only softraid
kn [Tue, 25 Apr 2023 10:06:12 +0000 (10:06 +0000)]
Do not attempt to write to read-only softraid

Bootloaders have no write support for softraid volumes, which manifests in,
e.g. /bsd.upgrade not being stripped of its 'x' permission bit to prevent
sysupgrade loops in case of upgrade failure.

Set a no-write flag handled by libsa to bail out early in write calls.
There should be no real behaviour change, writes just fail earlier now.

amd64 BIOS bits first, rest to come.  Crank minor.

"seems sensible" jsing

18 months agoUse X509_set_version() and X509_REQ_set_version() instead doing it by hand
job [Tue, 25 Apr 2023 09:46:36 +0000 (09:46 +0000)]
Use X509_set_version() and X509_REQ_set_version() instead doing it by hand

A small side-effect in X509_to_X509_REQ() is that 'x->req_info->enc.modified'
now earlier on is set to 1.

OK tb@ jsing@

18 months agoTidy tparm wrapper functions to have more obvious names and check tparm
nicm [Tue, 25 Apr 2023 09:31:50 +0000 (09:31 +0000)]
Tidy tparm wrapper functions to have more obvious names and check tparm
return value.

18 months agoInvalidate cached tty state after changing features since they may
nicm [Tue, 25 Apr 2023 09:24:44 +0000 (09:24 +0000)]
Invalidate cached tty state after changing features since they may
change what the terminal can do and need mouse sequences or similar to
be sent again, GitHub issue 3513.

18 months agoAdd option 'rdroot' to simplify creation of rdroot filesystems for the install
krw [Tue, 25 Apr 2023 08:57:11 +0000 (08:57 +0000)]
Add option 'rdroot' to simplify creation of rdroot filesystems for the install
media.

No functional change to existing behaviour.

18 months agoDelete now unused disklabel template files.
krw [Tue, 25 Apr 2023 08:44:19 +0000 (08:44 +0000)]
Delete now unused disklabel template files.

18 months agodocument that prefix-region with a prefix argument prompts for the string
op [Tue, 25 Apr 2023 08:37:24 +0000 (08:37 +0000)]
document that prefix-region with a prefix argument prompts for the string

18 months agoregen
jsg [Tue, 25 Apr 2023 08:28:27 +0000 (08:28 +0000)]
regen

18 months agoadd Kingston KC3000 from Paul de Weerd
jsg [Tue, 25 Apr 2023 08:27:59 +0000 (08:27 +0000)]
add Kingston KC3000 from Paul de Weerd
and Samsung PM9B1 as found in sthen's t14 gen 3 intel

18 months agoFix allocation size
tb [Tue, 25 Apr 2023 07:50:38 +0000 (07:50 +0000)]
Fix allocation size

Reported by anton

18 months agoUnbreak tree: file missed in last commit
tb [Tue, 25 Apr 2023 07:48:15 +0000 (07:48 +0000)]
Unbreak tree: file missed in last commit

Reported by anton

18 months agoadd eoip to keepalive.
asou [Tue, 25 Apr 2023 05:02:56 +0000 (05:02 +0000)]
add eoip to keepalive.

ok david@

18 months agoAdd endbr64 where needed by inspection. Passes regresson tests.
deraadt [Tue, 25 Apr 2023 04:42:25 +0000 (04:42 +0000)]
Add endbr64 where needed by inspection.  Passes regresson tests.
ok jsing, and kind of tb an earlier version

18 months agoendbr64 is potentially neccessary in the syscall stubs.
deraadt [Tue, 25 Apr 2023 04:11:10 +0000 (04:11 +0000)]
endbr64 is potentially neccessary in the syscall stubs.

18 months agoAdd missing endbr64 instructions as required. Verified as neccessary with
deraadt [Tue, 25 Apr 2023 04:10:21 +0000 (04:10 +0000)]
Add missing endbr64 instructions as required.  Verified as neccessary with
a fully IBT userland operational..

18 months agoplacing .align after the function start is crazy. other things are ensuring
deraadt [Tue, 25 Apr 2023 04:06:06 +0000 (04:06 +0000)]
placing .align after the function start is crazy.  other things are ensuring
this function is at the start of the section, there is no poing in potentially
stuffing nops into the sequence if things go wrong, it is better to fail hard.
ok guenther

18 months agoprof_state_toggle: keep a count of CPUs with profiling enabled
cheloha [Tue, 25 Apr 2023 01:32:36 +0000 (01:32 +0000)]
prof_state_toggle: keep a count of CPUs with profiling enabled

On MULTIPROCESSOR systems, the following sequence of kgmon(8)
invocations leaves the statclock() frequency at stathz when there is
still a CPU on the system where the gmon state is GMON_PROF_ON:

# kgmon -c 0 -b
# kgmon -c 1 -b
# kgmon -c 0 -h

The problem is that we aren't counting CPUs with profiling enabled.
Add "gmon_cpu_count" to keep a count.  Call startprofclock() for the
first CPU to enable profiling and stopprofclock() for the last CPU to
disable profiling.

18 months agoaddupc_intr: support adding multiple profiling ticks at once
cheloha [Tue, 25 Apr 2023 00:58:47 +0000 (00:58 +0000)]
addupc_intr: support adding multiple profiling ticks at once

Add a third parameter to addupc_intr(), "u_long nticks".  This will
allow us to credit more than one profiling tick to the thread at once.
Should be useful in the unusual case where the clock interrupt is
masked for an extended period.

18 months agoFuture users of libcrypto will also have to do without strong extranet
tb [Mon, 24 Apr 2023 22:30:17 +0000 (22:30 +0000)]
Future users of libcrypto will also have to do without strong extranet
support.

discussed with beck and jsing

18 months agoMark NETSCAPE_CERT_SEQUENCE for removal
tb [Mon, 24 Apr 2023 22:24:39 +0000 (22:24 +0000)]
Mark NETSCAPE_CERT_SEQUENCE for removal

discussed with beck and jsing

18 months agoMark the NDEF API for removal
tb [Mon, 24 Apr 2023 22:12:28 +0000 (22:12 +0000)]
Mark the NDEF API for removal

Discussed with jsing and beck

18 months agoSince ENTRY() already inserts a BTI instructions so don't add another one.
kettenis [Mon, 24 Apr 2023 22:06:05 +0000 (22:06 +0000)]
Since ENTRY() already inserts a BTI instructions so don't add another one.

ok patrick@

18 months agoIf the two mfts in mft_compare() are the same do not prefer the
claudio [Mon, 24 Apr 2023 17:11:33 +0000 (17:11 +0000)]
If the two mfts in mft_compare() are the same do not prefer the
first (DIR_VALID) but perfer the 2nd (DIR_TEMP) since this allows
rpki-client to move the equal files from .rrdp back into the valid
repo tree and so there are less unaccounted files for.
Problem noticed by and OK job@

18 months agoReplace the only two uses of disklabel template files with 'echo "/ *"'.
krw [Mon, 24 Apr 2023 17:07:33 +0000 (17:07 +0000)]
Replace the only two uses of disklabel template files with 'echo "/ *"'.

No functional change.

ok kn@

18 months agoFree and calloc() the tlsext_build_order and remember its length
tb [Mon, 24 Apr 2023 16:55:06 +0000 (16:55 +0000)]
Free and calloc() the tlsext_build_order and remember its length

Aligns tlsext_randomize_build_order() with tlsext_linearize_build_order()
and will help regression testing.

ok jsing

18 months agovmm(4): allow guests to enable and use supervisor IBT.
dv [Mon, 24 Apr 2023 16:53:57 +0000 (16:53 +0000)]
vmm(4): allow guests to enable and use supervisor IBT.

Why should hosts have all the fun? Conditionally unmask the cpuid
bits for IBT and allow r/w access to the supervisor CET msr.

Will need revisiting when we introduce usage of userland CET msr.

ok marlkin@

18 months agoRemove recursive spl grabbing in vfs_bio.c
beck [Mon, 24 Apr 2023 16:46:43 +0000 (16:46 +0000)]
Remove recursive spl grabbing in vfs_bio.c

in preparation for improvements.

ok claudio@

18 months agoadd default tmux config; ok sthen
kn [Mon, 24 Apr 2023 16:36:54 +0000 (16:36 +0000)]
add default tmux config;  ok sthen

18 months agoChange variables 'MRFSDISKTYPE' to 'MRDISKTYPE' like every other arch.
krw [Mon, 24 Apr 2023 16:21:43 +0000 (16:21 +0000)]
Change variables 'MRFSDISKTYPE' to 'MRDISKTYPE' like every other arch.

No functional change.

Noticed by & ok kn@

18 months agoFix sk_is_sorted to tread 0 and 1 element lists as sorted.
beck [Mon, 24 Apr 2023 15:35:22 +0000 (15:35 +0000)]
Fix sk_is_sorted to tread 0 and 1 element lists as sorted.

from boringssl

ok tb@ jsing@

18 months agoUse TLSEXT_TYPE_alpn instead of the stupid long one
tb [Mon, 24 Apr 2023 15:32:31 +0000 (15:32 +0000)]
Use TLSEXT_TYPE_alpn instead of the stupid long one

18 months agoChange variable 'DISKTYPE' to 'FSDISKTYPE' like every other arch.
krw [Mon, 24 Apr 2023 15:31:14 +0000 (15:31 +0000)]
Change variable 'DISKTYPE' to 'FSDISKTYPE' like every other arch.

No functional change.

ok patrick@

18 months agoEnable MSI if the node contains an msi-map, like we already do in pciecam(4).
patrick [Mon, 24 Apr 2023 15:15:00 +0000 (15:15 +0000)]
Enable MSI if the node contains an msi-map, like we already do in pciecam(4).
This will make MSIs work on the Lenovo x13s as soon as an updated device tree
is installed.

Discussed with kettenis@

18 months agoMissing the optional default config is not an error
kn [Mon, 24 Apr 2023 15:12:14 +0000 (15:12 +0000)]
Missing the optional default config is not an error

/var/log/{messages,daemon} logs ENOENT as error on default configless vmd.
Only complain on explicitly passed files and print a debug hint under `-vv'
in case someone forgot to populate their /etc/vm.conf.

OK dv mlarkin

18 months agoUpdate qcpon(4) compatibles to match on qcom,pmk8350-pon, which is the updated
patrick [Mon, 24 Apr 2023 14:34:13 +0000 (14:34 +0000)]
Update qcpon(4) compatibles to match on qcom,pmk8350-pon, which is the updated
binding in Linux 6.3 device trees.  While there, remove retrieving the register
address, as the new binding has an additional register with doesn't work with
a single OF_getpropint(), and since we're not using it we don't need to keep it
around.

18 months ago"ls rogue" needs root; OK aja
kn [Mon, 24 Apr 2023 14:31:15 +0000 (14:31 +0000)]
"ls rogue" needs root;  OK aja

18 months agoAdd '-s' option to simply display the number of bytes available for the rdroot
krw [Mon, 24 Apr 2023 14:06:01 +0000 (14:06 +0000)]
Add '-s' option to simply display the number of bytes available for the rdroot
filesystem in the specified kernel.

No behaviour change to existing uses of rdsetroot.

Improved option handling & ok kn@

18 months agoHoist privilege checks further
kn [Mon, 24 Apr 2023 12:11:56 +0000 (12:11 +0000)]
Hoist privilege checks further

in6.c already has the privilege check as early as possible, make in.c match.

For unprivileged IPv4 ioctl calls with invalid args, this changes errno from
E* to EPERM.

OK bluhm

18 months agogtk-update-icon-cache moved from being a gtk+3 subpackage to a gtk+4 one.
ajacoutot [Mon, 24 Apr 2023 11:54:28 +0000 (11:54 +0000)]
gtk-update-icon-cache moved from being a gtk+3 subpackage to a gtk+4 one.

18 months agoEnable branch target control flow enforcement on arm64.
kettenis [Mon, 24 Apr 2023 10:22:48 +0000 (10:22 +0000)]
Enable branch target control flow enforcement on arm64.

ok robert@, deraadt@

18 months agoAbuse the wxallowed flag to decide whether we should enforce branch target
kettenis [Mon, 24 Apr 2023 10:22:06 +0000 (10:22 +0000)]
Abuse the wxallowed flag to decide whether we should enforce branch target
or not.  The idea is that since /usr/local has wxallowed by default this
will enable enforcement for base while leaving ports alone for now.  This
will help us transition to a state where ports are properly marked and
allow us to establish that base is really clean.

Also add an exception for chrome.  Chrome already appears to be clean on
arm64 and this exception can be easily modified for testing other ports.

This will screw over people that deliberately disable wxallowed on
/usr/local or who don't have a separate partition for /usr/local.  We
think that is an acceptable compromise for the next months.

ok robert@, deraadt@ (who came up with the idea)

18 months agoDon't check `so_sp' within sofree(). The following isspliced() and
mvs [Mon, 24 Apr 2023 09:20:09 +0000 (09:20 +0000)]
Don't check `so_sp' within sofree(). The following isspliced() and
issplicedback() already have this check.

ok bluhm@

18 months agoAdd initial support for Atlantic 2 hardware. Atlantic 2 has
jmatthew [Mon, 24 Apr 2023 09:18:55 +0000 (09:18 +0000)]
Add initial support for Atlantic 2 hardware.  Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving.  RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@

18 months agoToggle IBT off during amd64 hibernate before dropping to real mode.
dv [Mon, 24 Apr 2023 09:04:03 +0000 (09:04 +0000)]
Toggle IBT off during amd64 hibernate before dropping to real mode.

Hibernate on IBT-capable MP systems broke when trying to quiesce
cpus. Instead of finding the locations of endbr64 in the asm indirect
jumps in acpi_wakecode.S, simply disable CR4.CET beforehand and
re-enable on resume.

This will also disable shadowstack, but there are no plans to use it.

"this approach is fine" deraadt@

18 months agodo a cache lookup as well in case a full pathname is passed to dlopen
robert [Mon, 24 Apr 2023 08:59:09 +0000 (08:59 +0000)]
do a cache lookup as well in case a full pathname is passed to dlopen

18 months agoSort X.509 error reasons, use next available error value, and align
job [Mon, 24 Apr 2023 08:39:06 +0000 (08:39 +0000)]
Sort X.509 error reasons, use next available error value, and align
error message with internal error code name.

OK tb@ jsing@

18 months agoRevert 1.32
job [Mon, 24 Apr 2023 08:09:29 +0000 (08:09 +0000)]
Revert 1.32

jsing@ noted that ASN1_OP_D2I_POST might not be the best place to
introduce this check (as could lead to pushing errors
(ASN1_R_AUX_ERROR) onto the stack). Additionally, without matching
validation on the encoding side brittleness is introduced.

18 months agohandle fixed-link configuration in the device tree.
dlg [Mon, 24 Apr 2023 01:33:32 +0000 (01:33 +0000)]
handle fixed-link configuration in the device tree.

if fixed-link is present, populate the interface baudrate and link
status (full duplex or half duplex), and then call the statch handler
to apply that config to the MAC. if fixed-link is specified then
do not attach a phy.

note that phy lookup and reset still occurs in case the device tree
still uses the deprecated snps,reset-gpio properties. the fixed
link port on the bpi r2 pro is connected to a switch chip (which
is not really a phy) that needs needs a reset provided by the
snps,reset-gpio handling. an improved device tree would have the
reset properties on the switch node so it could do its own reset,
but we can't have nice things can we?

tested on a nanopi r5s, which has a phy but no fixed-link config,
and a banana pi bpi-r2 pro, which has both (cos it has two dwqes,
one with a phy and one without).

18 months agoactually xr to iosf this time.
dlg [Mon, 24 Apr 2023 00:11:08 +0000 (00:11 +0000)]
actually xr to iosf this time.

with patience from jmc@

18 months agoAdjust some printfs in the attach code path to make more sense,
jmatthew [Sun, 23 Apr 2023 22:57:23 +0000 (22:57 +0000)]
Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@

18 months agoPrepare for adding Atlantic 2 support by renaming functions and defines
jmatthew [Sun, 23 Apr 2023 22:48:03 +0000 (22:48 +0000)]
Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@

18 months agoReplace X509v3_get_ext_count() with X509_get_ext_count()
job [Sun, 23 Apr 2023 21:49:15 +0000 (21:49 +0000)]
Replace X509v3_get_ext_count() with X509_get_ext_count()

Error introduced in 1.24

18 months agoIn the case of V1 certs, the extension count should be exactly 0
job [Sun, 23 Apr 2023 21:46:07 +0000 (21:46 +0000)]
In the case of V1 certs, the extension count should be exactly 0

OK tb@

18 months agoIf extensions are encountered on a X.509 V1 cert, mark as invalid
job [Sun, 23 Apr 2023 21:39:19 +0000 (21:39 +0000)]
If extensions are encountered on a X.509 V1 cert, mark as invalid

While there, explicitly check for 0 - as X509_get_version() is a wrapper
around the less than beloved ASN1_INTEGER_get().

OK tb@

18 months agoAdd compliance checks for the X.509 version field
job [Sun, 23 Apr 2023 21:31:16 +0000 (21:31 +0000)]
Add compliance checks for the X.509 version field

Check whether the X.509 version is in the range of valid version
values, and also checks whether the version is consistent with fields
new to those versions (such as X.509 v3 extensions).

X.690 section 11.5 states: "The encoding of a set value or a sequence
value shall not include an encoding for any component value which is
equal to its default value." However, enforcing version 1 (value 0) to
be absent reportedly caused some issues as recent as July 2020, so
accept version 1 even if it is explicitly encoded.

OK tb@ beck@

18 months agoDon't create IBT .plt if there are no PLT entries. Cherry picked from
kettenis [Sun, 23 Apr 2023 21:08:26 +0000 (21:08 +0000)]
Don't create IBT .plt if there are no PLT entries.  Cherry picked from
upstream.  Fixes several issues including problems with ld.bfd when it
sees such a .plt in an object file that is getting linked into a binary.

ok deraadt@

18 months agosync
deraadt [Sun, 23 Apr 2023 19:22:08 +0000 (19:22 +0000)]
sync

18 months agoFix the client test and the tlsext test to work with randomized
tb [Sun, 23 Apr 2023 18:59:41 +0000 (18:59 +0000)]
Fix the client test and the tlsext test to work with randomized
TLS extensions (this involves unrandomizing the extension order
for the tests that rely on golden numbers.

18 months agoRandomize the order of TLS extensions
tb [Sun, 23 Apr 2023 18:51:53 +0000 (18:51 +0000)]
Randomize the order of TLS extensions

On creation of an SSL using SSL_new(), randomize the order in which the
extensions will be sent. There are several constraints: the PSK extension
must always come last. The order cannot be randomized on a per-message
basis as the strict interpretation of the standard chosen in the CH hashing
doesn't allow changing the order between first and second ClientHello.

Another constraint is that the current code calls callbacks directly on
parsing an extension, which means that the order callbacks are called
depends on the order in which the peer sent the extensions. This results
in breaking apache-httpd setups using virtual hosts with full ranomization
because virtual hosts don't work if the SNI is unknown at the time the
ALPN callback is called. So for the time being, we ensure that SNI always
precedes ALPN to avoid issues until this issue is fixed.

This is based on an idea by David Benjamin
https://boringssl-review.googlesource.com/c/boringssl/+/48045

Input & ok jsing

18 months agocope with more s/XCR0/XFEATURE renames
anton [Sun, 23 Apr 2023 18:38:55 +0000 (18:38 +0000)]
cope with more s/XCR0/XFEATURE renames

18 months agoMan page update for EVP_sha512_224() and EVP_sha512_256()
job [Sun, 23 Apr 2023 18:24:01 +0000 (18:24 +0000)]
Man page update for EVP_sha512_224() and EVP_sha512_256()

OK tb@

18 months agoLink c2sp test to build
tb [Sun, 23 Apr 2023 13:47:35 +0000 (13:47 +0000)]
Link c2sp test to build

18 months agoImport C2SP/CCTV test
tb [Sun, 23 Apr 2023 13:43:46 +0000 (13:43 +0000)]
Import C2SP/CCTV test

This currently only covers Ed25519 using the c2sp-testvectors package
and checks that our Ed25519 implementation behaves as expected from a
"ref10" implementation.

This test has Go and c2sp-testvectors as a hard dependency. It will
optionally pick up any OpenSSL package installed on the system and
test that as well.

https://github.com/C2SP/CCTV
https://github.com/C2SP/CCTV/tree/main/ed25519

18 months agoIn filemode, if an ASPA contains information for only 1 AFI, supplement the other
job [Sun, 23 Apr 2023 13:19:34 +0000 (13:19 +0000)]
In filemode, if an ASPA contains information for only 1 AFI, supplement the other

OK claudio@

18 months agovmd(8): teach vmm process how to exec.
dv [Sun, 23 Apr 2023 12:11:37 +0000 (12:11 +0000)]
vmd(8): teach vmm process how to exec.

Use execvp(2) to launch vm children with new address spaces.
Consequently, introduces use of unveil(2) into the vmm and vm
processes.

This imposes the requirement of launching vmd with absolute paths,
similar to sshd(8).

ok mlarkin@

18 months agoDrop some extra parentheses
tb [Sun, 23 Apr 2023 11:52:14 +0000 (11:52 +0000)]
Drop some extra parentheses

18 months agoFlowspec show support an address family argument. Copy the description
claudio [Sun, 23 Apr 2023 11:42:45 +0000 (11:42 +0000)]
Flowspec show support an address family argument. Copy the description
from the very similar 'network show'.

18 months agoDrop a superfluous isneg check.
tb [Sun, 23 Apr 2023 11:39:56 +0000 (11:39 +0000)]
Drop a superfluous isneg check.

18 months agoFor FLOWSPEC_SHOW conver the AID form regular inet/inet6 to flowspec versions.
claudio [Sun, 23 Apr 2023 11:39:51 +0000 (11:39 +0000)]
For FLOWSPEC_SHOW conver the AID form regular inet/inet6 to flowspec versions.
OK tb@

18 months agoAdd the same AID filter to prefix_flowspec_dump() like in the other
claudio [Sun, 23 Apr 2023 11:39:10 +0000 (11:39 +0000)]
Add the same AID filter to prefix_flowspec_dump() like in the other
prefix/rib dump functions.
OK tb@

18 months agoAdd missing NULL check for BN_new()
tb [Sun, 23 Apr 2023 11:34:57 +0000 (11:34 +0000)]
Add missing NULL check for BN_new()

18 months agoDocument flowspec commands
claudio [Sun, 23 Apr 2023 11:29:57 +0000 (11:29 +0000)]
Document flowspec commands
OK tb@ jmc@

18 months agoInitialize ishex and isneg at the top and drop some elses
tb [Sun, 23 Apr 2023 11:25:21 +0000 (11:25 +0000)]
Initialize ishex and isneg at the top and drop some elses

18 months agoStop setting ri->ri_bs to prevent a panic caused by rasops accessing its
patrick [Sun, 23 Apr 2023 10:29:35 +0000 (10:29 +0000)]
Stop setting ri->ri_bs to prevent a panic caused by rasops accessing its
uninitialized content.  When we rasops_init() with RI_VCONS, a new screen
is allocated.  If ri->ri_bs is set, this will be copied.  Otherwise a new
one will be allocated and filled with ASCII spaces.  Copying the ri->ri_bs
is useful in case we have an early console which contents we want to keep.
As we do not have an early console here, there's no point in setting it at
the moment.

With this my Hetzner arm64 VM doesn't panic anymore.

ok jcs@ kettenis@

18 months agoAlign hex_to_string with OpenSSL 1.1 behavior
tb [Sun, 23 Apr 2023 10:19:52 +0000 (10:19 +0000)]
Align hex_to_string with OpenSSL 1.1 behavior

This is a bit of a strange one. When this function was moved and renamed,
somehow checks for NULL pointers and 0 length were lost. Whether that was
due to great review missing it or great review suggesting it, is unclear.

Now the function can actually legitimately be called with a length of 0
(as ASN.1 OCTET STRINGS can have length 0) and "" is the appropriate
representation for that, so the fix is to allocate a 0 octet. That much
was correct. What was completely missed is that a long can be negative
which will then still lead to an out-of-bounds access. So fix that as
well.

Finally, don't malloc 3 * len + 1 without overflow checking. Rather
use calloc's internal checks. The + 1 isn't really needed anyway.

All this is still really gross and can be done much more cleanly and
safely with CBB/CBS. This will done later once we have better regress
coverage.

ok jsing

18 months agox509_utl.c: Use correct spelling of NULL
tb [Sun, 23 Apr 2023 09:58:38 +0000 (09:58 +0000)]
x509_utl.c: Use correct spelling of NULL

18 months agoXr to iosf(4). pci(4) needed an Xr to dwiic(4) too.
dlg [Sun, 23 Apr 2023 08:04:59 +0000 (08:04 +0000)]
Xr to iosf(4). pci(4) needed an Xr to dwiic(4) too.

pointed out by jmc@

18 months agorename sc_tick to sc_phy_tick. no functional change.
dlg [Sun, 23 Apr 2023 06:22:15 +0000 (06:22 +0000)]
rename sc_tick to sc_phy_tick. no functional change.

18 months agounbreak tree by coping with recent s/XCR0/XFEATURE rename
anton [Sun, 23 Apr 2023 05:37:55 +0000 (05:37 +0000)]
unbreak tree by coping with recent s/XCR0/XFEATURE rename

18 months agoenable iosf(4)
dlg [Sun, 23 Apr 2023 00:50:29 +0000 (00:50 +0000)]
enable iosf(4)

this should help some braswell and bay trail machines. it definitely
helps my dell wyse 3040 avoid locking up.

ok kettenis@ patrick@

18 months agoiosf(4) implements functionality that was stubbed out in drm
dlg [Sun, 23 Apr 2023 00:49:04 +0000 (00:49 +0000)]
iosf(4) implements functionality that was stubbed out in drm

18 months agoadd a manpage for iosf(4)
dlg [Sun, 23 Apr 2023 00:44:44 +0000 (00:44 +0000)]
add a manpage for iosf(4)

18 months agoadd support for coordinating i2c bus access with iosf(4)
dlg [Sun, 23 Apr 2023 00:33:02 +0000 (00:33 +0000)]
add support for coordinating i2c bus access with iosf(4)

if the acpi node has a _SEM property, add wrappers around the i2c
bus acquire and release handlers to try and call the iosf provided
hardware semaphore ops. this means bus accesses can be coordinate
with other parts of the platform such as the punit.

this stops my Dell Wyse 3040 from locking up.

ok kettenis@ patrick@

18 months agoadd iosf(4), a driver for the Intel OnChip System Fabric
dlg [Sun, 23 Apr 2023 00:20:26 +0000 (00:20 +0000)]
add iosf(4), a driver for the Intel OnChip System Fabric

The OnChip System Fabric is mostly an implementation detail on a
bunch of Intel SoC platforms we usually don't care about, except
on some of these machines there are devices shared between the
kernel and the platform that need to coordinate. The iosf(4) driver
allows the kernel to talk via a mailbox interface to take and
release a semaphore that the hardware also uses to lock around
accesses to some components.

There are two ways to talk to the mailbox interface, one via mmio
ops on an INT33BD acpi device. The other is via magic pci conf space
operations on the pci host device. This provides a generic iosf
driver with attachment glue for both acpi and pci so either can be
used. According to linux, the pci ops are a lot more reliable and
less buggy, so if both acpi and pci are available we will prefer
the pci ops after they attach.

I found this because I got a Dell Wyse 3040, which is a cherry
trail/braswell system that has an acpitz(4) which talks to a tipmic(4)
device attached to dwiic(4) on acpi. This box almost always locked
up by the time it got to showing the console login prompt, and it
turns out one of the reasons for this is because acpitz was touching
the tipmic device at the same time the powerunit on the platform
was also trying to use it. The tipmic device lists the iosf mailbox
as a dependency, and the dwiic controller has a _SEM property, both
of which indicate we should use an iosf device to coordinate iic
ops when talking to the tipmic.

This adds the code, but doesn't wire it into dwiic or the build yet.

help from patrick@ jsg@ kettenis@
ok kettenis@ patrick@

18 months agoclockintr_cpu_init: don't update cached uptime
cheloha [Sun, 23 Apr 2023 00:08:36 +0000 (00:08 +0000)]
clockintr_cpu_init: don't update cached uptime

clockintr_advance() now calls nsecuptime(9) when called outside
clockintr_dispatch().  There is no need for clockintr_cpu_init() to
update the queue's cached uptime (cq->cq_uptime) to ensure it is
fresh.

18 months agoclockintr_advance: don't use cached uptime when called outside of dispatch
cheloha [Sun, 23 Apr 2023 00:01:40 +0000 (00:01 +0000)]
clockintr_advance: don't use cached uptime when called outside of dispatch

When clockintr_advance() is eventually used by outside callers, there
will be no way to know how fresh cq_uptime is.  If we're not running
in the dispatch loop, we need to call nsecuptime(9) to get a high-res
uptime before advancing a clockintr.

18 months agoclockintr, ddb(4): label non-pending clock interrupts "idle"
cheloha [Sat, 22 Apr 2023 23:51:27 +0000 (23:51 +0000)]
clockintr, ddb(4): label non-pending clock interrupts "idle"

"idle" is more obvious than "est" and requires no knowledge of the
implementation.

18 months agoCall pfkeyv2_sysctl_policydumper() with shared netlock. It performs
mvs [Sat, 22 Apr 2023 20:51:56 +0000 (20:51 +0000)]
Call pfkeyv2_sysctl_policydumper() with shared netlock. It performs
read-olny access to netlock protected data, so the radix tree will
not be modified during spd_table_walk() run.

Also change netlock assertion within spd_table_add() and
ipsec_delete_policy() to exclusive. These are correlating functions
which modifies radix tree, so make us sure spd_table_walk() run with
shared netlock is safe.

Feedback and ok by bluhm@

18 months agoDocument the change in default to comma plus space but leave out the
tb [Sat, 22 Apr 2023 20:51:26 +0000 (20:51 +0000)]
Document the change in default to comma plus space but leave out the
compat nonsense

18 months agoFix UTF-8 issuer printing
tb [Sat, 22 Apr 2023 20:50:26 +0000 (20:50 +0000)]
Fix UTF-8 issuer printing

If no field separator is specified, default to using the comma plus space
separation, unless the compat flag is set.

Fixes an a bug with printing issuers and other things that contain UTF-8

Reported by Jean-Luc Duprat
The very simple fix ix is a joint effort by Henson and Levitte
Fixes libressl/portable issue #845

ok jsing

18 months agovmd(8): fix vm send/receive due to invalid hva's.
dv [Sat, 22 Apr 2023 19:47:35 +0000 (19:47 +0000)]
vmd(8): fix vm send/receive due to invalid hva's.

Moving some of the virtio devices to zero-copy approaches required
tracking the host-side virtual address for the gpa of virtqueues.
Upon a send/receive they are invalid as the restoring system will
most likely use a different address space layout.

Recompute the hva's on receive and NULL them on send.

ok mlarkin@

18 months agoRename the XCR0_* #defines to XFEATURE_* and add the new supervisor-state
guenther [Sat, 22 Apr 2023 18:27:28 +0000 (18:27 +0000)]
Rename the XCR0_* #defines to XFEATURE_* and add the new supervisor-state
features: while all are appropriate for xsaves/xrstors, the
supervisor-state features aren't for xcr0 but rather for the new XSS_MSR,
making the current names kinda confusing.

Add #defines for masking bits for xcr0 vs XSS.

Add and report the new XSAVE_XFD xsave subfeature bit.

ok mlarkin@

18 months agoTeach the disassembler about xrstors, xsavec, and xsaves
guenther [Sat, 22 Apr 2023 18:26:17 +0000 (18:26 +0000)]
Teach the disassembler about xrstors, xsavec, and xsaves

ok mlarkin@

18 months agoImprove bn_montgomery_multiply_words()
jsing [Sat, 22 Apr 2023 14:31:44 +0000 (14:31 +0000)]
Improve bn_montgomery_multiply_words()

Pull a number of invariants into variables, which avoids repeated loading
from memory on architectures where sufficient registers are available.
Also keep track of the per-iteration carry in a variable, rather than
unnecessarily reading from and writing to memory.

This gives a reasonable performance gain on some architectures (e.g. armv7)

18 months agoProvide initial regress for BN_{asc,dec,hex}2bn()/BN_bn2{dec,hex}()
jsing [Sat, 22 Apr 2023 14:03:03 +0000 (14:03 +0000)]
Provide initial regress for BN_{asc,dec,hex}2bn()/BN_bn2{dec,hex}()

18 months agoreduce the delays used in the mii/mdio bus ops
dlg [Sat, 22 Apr 2023 06:36:35 +0000 (06:36 +0000)]
reduce the delays used in the mii/mdio bus ops

this produces a significant speed up.

say you're reading 40ish mib counters off a port on switch chip,
where each counter read relies on multiple mdio operations. it took
well over a second to read the counters off a port in my my initial
version. after optimising the switch reads i got that down to a bit
under a second. after this change in dwqe i can read counters off
5 ports in about 0.03 seconds.

ok patrick@

18 months agouse if_baudrate and if_link_state for mac config, not mii media values
dlg [Sat, 22 Apr 2023 05:01:44 +0000 (05:01 +0000)]
use if_baudrate and if_link_state for mac config, not mii media values

the phy code sets if_baudrate and if_link_state, so the information
needed to config the mac on the chip is there anyway. it also has
the benefit that the driver doesnt have to understand every type
of media (eg, 1000baseTX vs 1000baseSX) because they're both the
same speed and that's what matters when configuring the chip and
the clocks etc.

this is a step toward being able to use a fixed-link node in the
device tree instead of a phy, as is found on the banana pi bpi-r2
pro on the gmac connected to a switch chip.

18 months agorevert vlan(4) inherits TSO flags
dlg [Sat, 22 Apr 2023 04:39:46 +0000 (04:39 +0000)]
revert vlan(4) inherits TSO flags

tb reports amd64 RAMDISK doesn't build with it.

also, vlan_flags_from_parent doesn't look right right. it iterates
over ifnetlist, which is all interfaces in the system, but appears
to assume they're all vlan interfaces and so uses a vlan_softc *
to inspect their if_softc pointers.

18 months agocms_io: sort includes
tb [Fri, 21 Apr 2023 20:36:07 +0000 (20:36 +0000)]
cms_io: sort includes