openbsd
2 years agoAll of ROA, MFT, ASPA, and RSC define their respective 'version' field
job [Thu, 13 Oct 2022 04:43:32 +0000 (04:43 +0000)]
All of ROA, MFT, ASPA, and RSC define their respective 'version' field
in ASN.1 as following: "version [0] INTEGER DEFAULT 0,". Each object
profile preamble contains "DEFINITIONS EXPLICIT TAGS ::=".

We didn't bump into any issue yet, because all Signed Objects are at
version 0, which means the field is entirely omitted (including the tag,
be it implicit or explicit). (From X.690 section 11.5: "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.")

OK tb@

2 years agoNuke D_BADSECT and disktab's 'sf'.
krw [Wed, 12 Oct 2022 23:11:32 +0000 (23:11 +0000)]
Nuke D_BADSECT and disktab's 'sf'.

DEC standard 144 bad sector information is no longer a thing. As
evidenced by bad144(8) moving to the attic 16 years ago.

ok miod@, who points out that badsect(8) is now the nail sticking
out.

2 years agoExtend struct todr_chip_handle with a todr_quality member. This allows us
kettenis [Wed, 12 Oct 2022 13:39:50 +0000 (13:39 +0000)]
Extend struct todr_chip_handle with a todr_quality member.  This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC).  This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered.  It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized.  In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@

2 years agoavoid use after free in error paths
jsg [Wed, 12 Oct 2022 11:57:40 +0000 (11:57 +0000)]
avoid use after free in error paths
ok miod@ martijn@

2 years agouse correct type with sizeof
jsg [Wed, 12 Oct 2022 11:29:53 +0000 (11:29 +0000)]
use correct type with sizeof
ok miod@ kettenis@

2 years agouse correct type with sizeof
jsg [Wed, 12 Oct 2022 11:26:05 +0000 (11:26 +0000)]
use correct type with sizeof
ok miod@ claudio@ tb@

2 years agoRemove powerpc left-overs
kn [Wed, 12 Oct 2022 10:48:33 +0000 (10:48 +0000)]
Remove powerpc left-overs

There since the powerpc -> macppc move/rename.

KERN_AS   usage disappeared in
commit 5b7db11d478192c5908038bb1345e7d51cc35c8e
Author: rahnds <rahnds@openbsd.org>
Date:   Mon May 5 16:47:15 1997 +0000

only build one version of the libraries.

REAL_VIRT usage disappeared in
commit 08e027d6bb9ca863bfc44a1aa6957ff3a242e2f4
Author: rahnds <rahnds@openbsd.org>
Date:   Thu Apr 27 12:36:29 2000 +0000

Fixes to xcoff bootloader to allow it to execute and load kernels for OpenBSD.

Make agrees that these are defined but not used:

$ make -p            | grep -e KERN_AS -e REAL_VIRT
KERN_AS          = library
REAL_VIRT        = -v
$ make -C ofwboot -p | grep -e KERN_AS -e REAL_VIRT
KERN_AS          = library
REAL_VIRT        = -v

No object change.
Feedback OK miod

2 years agoFix -Wreturn-type
kn [Wed, 12 Oct 2022 09:23:45 +0000 (09:23 +0000)]
Fix -Wreturn-type

OK miod

2 years agoThe sigaltstack() MAP_STACK re-map mechanism is incompatible with immutable
deraadt [Wed, 12 Oct 2022 02:39:16 +0000 (02:39 +0000)]
The sigaltstack() MAP_STACK re-map mechanism is incompatible with immutable
regions, so immutable stack isn't viable yet. There are configure programs
which create sigstacks upon their own stacks, and there is no simple fix for
the sigaltstack mechanism...
discovered by sthen and tb

2 years agoGive checkdisklabel() a new parameter supplying the dev_t of the
krw [Tue, 11 Oct 2022 23:39:07 +0000 (23:39 +0000)]
Give checkdisklabel() a new parameter supplying the dev_t of the
device whose disklabel is being checked. Within checkdisklabel()
use this information to discover a device name iff (sic) the
label is an obsolete version. Use the name to generate a
meaningful warning message asking the user to rewrite the
disklabel and thus promote it to the current version.

Suggested by, feedback from and ok deraadt@

2 years agoVox populi says "cdio:" prefix is useful so switch back to using
krw [Tue, 11 Oct 2022 16:32:40 +0000 (16:32 +0000)]
Vox populi says "cdio:" prefix is useful so switch back to using
warnx(), but with required "\n" manually output to stderr before
calling warnx().

Requested by tb@ and OP Michael Siegel.

2 years agoFix path of mentioned regress test
tb [Tue, 11 Oct 2022 13:52:23 +0000 (13:52 +0000)]
Fix path of mentioned regress test

2 years agoHandle corner case in which the test case can actually be a square
tb [Tue, 11 Oct 2022 13:51:41 +0000 (13:51 +0000)]
Handle corner case in which the test case can actually be a square

2 years agocorrect t_lex_type() return type
jsg [Tue, 11 Oct 2022 13:40:38 +0000 (13:40 +0000)]
correct t_lex_type() return type
ok miod@

2 years agoadd missing unlock in swapmount()
jsg [Tue, 11 Oct 2022 11:46:58 +0000 (11:46 +0000)]
add missing unlock in swapmount()
ok tb@ kn@ miod@

2 years agofix unintended sizeof pointer introduced in 1.10
jsg [Tue, 11 Oct 2022 07:36:27 +0000 (07:36 +0000)]
fix unintended sizeof pointer introduced in 1.10
ok cheloha@ miod@ matthieu@ martijn@

2 years agoRun noexec tests in a new thread, leveraging the fact that
anton [Tue, 11 Oct 2022 05:45:41 +0000 (05:45 +0000)]
Run noexec tests in a new thread, leveraging the fact that
pthread_create() allocates a new stack which has mutable permissions.
Allows the temporary expected failures to be dropped.

ok deraadt@

2 years agoremove unused var
jsg [Tue, 11 Oct 2022 03:37:14 +0000 (03:37 +0000)]
remove unused var

2 years agoAdd support for the RK817 PMIC.
kettenis [Mon, 10 Oct 2022 17:45:35 +0000 (17:45 +0000)]
Add support for the RK817 PMIC.

ok patrick@, mlarkin@

2 years agoRecalculate checksum of normalised packet
bket [Mon, 10 Oct 2022 16:43:12 +0000 (16:43 +0000)]
Recalculate checksum of normalised packet

In 2011, henning@ removed fiddling with the ip checksum of normalised
packets in r1.131 of sys/net/pf_norm.c. Rationale was that the checksum
is always recalculated in all output paths anyway. In 2016, procter@
reintroduced checksum modification to preserve end-to-end checksums in
r1.189 of sys/net/pf_norm.c. Likely soomewhere in that timeslot checksum
recalculation of normalised packets was broken.

With input from bluhm@.

OK sashan@, bluhm@

2 years agoUse warnx(), not warn(), when 'errno' is not relevant.
krw [Mon, 10 Oct 2022 15:04:09 +0000 (15:04 +0000)]
Use warnx(), not warn(), when 'errno' is not relevant.

2 years agoTrigger ERR trap on permanent I/O redirection failure
kn [Mon, 10 Oct 2022 14:57:48 +0000 (14:57 +0000)]
Trigger ERR trap on permanent I/O redirection failure

The following three cases behave identical in bash(1), but our ksh
(ksh93 also) fails to run the trap in the last case:

(non-zero exit code is trigger, no redirection)
$ ksh -c 'trap "echo ERR" ERR ; false'
ERR

(failed redirection is trigger, 'echo' was not executed)
$ ksh -c 'trap "echo ERR" ERR ; echo >/'
ksh: cannot create /: Is a directory
ERR

(failed redirection, no execution, trap was NOT triggered)
$ ksh -c 'trap "echo ERR" ERR ; exec >/'
ksh: cannot create /: Is a directory

bash(1) prints "ERR" in all three cases, as expected.
ksh93 behaves like our ksh(1).

In ksh `exec' is a builtin (CSHELL), but also special (SPEC_BI):
$ type alias
alias is a shell builtin
$ type exec
exec is a special shell builtin

Without command and redirection alone, `exec' permanently redirects I/O for
the shell itself, not executing anything;  it is the only (special) builtin
with such a special use-case, implemented as c_sh.c:c_exec().

This corner-case is overlooked in exec.c:execute() which handles iosetup()
failure for all commands, incl. builtins.

Exclude c_exec() from the rest of special builtins to ensure it runs the
ERR trap as expected:

$ ./obj/ksh -c 'trap "echo ERR" ERR ; exec >/'
ksh: cannot create /: Is a directory
ERR

Also add three new regress cases covering this;  rest keep passing.

OK millert

2 years agoDon't leak 'sec' in error path.
krw [Mon, 10 Oct 2022 14:52:02 +0000 (14:52 +0000)]
Don't leak 'sec' in error path.

2 years agoEnable configtest
kn [Mon, 10 Oct 2022 12:07:53 +0000 (12:07 +0000)]
Enable configtest

OK solene

2 years agoMove enabling the policy refcounting from policy_ref() to config_free_policy().
tobhe [Mon, 10 Oct 2022 11:33:55 +0000 (11:33 +0000)]
Move enabling the policy refcounting from policy_ref() to config_free_policy().
In config_free_policy() the refcounting is unchanged and each SA linked to the
policy will trigger a call to policy_ref() and increase the references as
before the change.  This allows unconditional calls to policy_ref() and
policy_unref() and the callers no longer have to check if IKED_POLICY_REFCNT
is set.

From and ok markus@

2 years agoContinue tests is the mountpoint already exists
kn [Mon, 10 Oct 2022 11:06:14 +0000 (11:06 +0000)]
Continue tests is the mountpoint already exists

regress should be resilient against partially cleaned obj/.

Feedback bluhm

2 years agoDiscard stdout/err only where needed in check_unattendedupgrade()
kn [Mon, 10 Oct 2022 11:04:17 +0000 (11:04 +0000)]
Discard stdout/err only where needed in check_unattendedupgrade()

We should be fine silencing only the test condition which produces legit
output and warnings.

All else produces no output and should not error out;  if it does, those
warnings should be printed and fixed.

Feedback OK halex

2 years agoconsistently use IPv4/IPv6
jsg [Mon, 10 Oct 2022 10:42:42 +0000 (10:42 +0000)]
consistently use IPv4/IPv6

2 years agoconsistently use IPv4/IPv6; from jmc@
jsg [Mon, 10 Oct 2022 09:13:43 +0000 (09:13 +0000)]
consistently use IPv4/IPv6; from jmc@

2 years agoncurses wide character functions should be available with _XOPEN_SOURCE
nicm [Mon, 10 Oct 2022 09:03:08 +0000 (09:03 +0000)]
ncurses wide character functions should be available with _XOPEN_SOURCE
of 500 or greater and not require _XOPEN_SOURCE_EXTENDED. Bring in
changes from upstream ncurses patches 20100403 and 20111030 to take this
into account. Reported by Grigory Kirillov via jmc@.

ok millert jmc

2 years agotwo tests are now expected to fail since the introduction of mimmutable
anton [Mon, 10 Oct 2022 05:26:11 +0000 (05:26 +0000)]
two tests are now expected to fail since the introduction of mimmutable

2 years agoadd references to 10h 12h revision guides
jsg [Mon, 10 Oct 2022 03:01:11 +0000 (03:01 +0000)]
add references to 10h 12h revision guides

2 years agorevert amdgpu dirty fb helper changes from 5.15.71
jsg [Mon, 10 Oct 2022 01:58:36 +0000 (01:58 +0000)]
revert amdgpu dirty fb helper changes from 5.15.71

drm/amdgpu: don't register a dirty callback for non-atomic
drm/amdgpu: use dirty framebuffer helper

kettenis found that these changes made xpdf slow on x395 (picasso).
I can not reproduce this on renoir.

2 years agoIpv6 -> IPv6
jsg [Mon, 10 Oct 2022 00:12:45 +0000 (00:12 +0000)]
Ipv6 -> IPv6

2 years agoDrop fattr promise unless file creation is allowed
kn [Sun, 9 Oct 2022 23:04:57 +0000 (23:04 +0000)]
Drop fattr promise unless file creation is allowed

This is only required for the single fchmod(2) ensuring default permissions
which only happens in the -c code path.

OK millert

2 years agoRK3566/RK3568 support.
kettenis [Sun, 9 Oct 2022 20:31:30 +0000 (20:31 +0000)]
RK3566/RK3568 support.

ok mlarkin@, patrick@

2 years agoRK3566/RK3568 support.
kettenis [Sun, 9 Oct 2022 20:30:59 +0000 (20:30 +0000)]
RK3566/RK3568 support.

ok patrick@

2 years agoallow newlines inside the `alternative names' block in acme-client.conf
op [Sun, 9 Oct 2022 09:59:31 +0000 (09:59 +0000)]
allow newlines inside the `alternative names' block in acme-client.conf

ok florian

2 years agoremove by now unwanted extra space in output
anton [Sun, 9 Oct 2022 05:54:40 +0000 (05:54 +0000)]
remove by now unwanted extra space in output

2 years agoFix typo in debug messages.
kevlo [Sun, 9 Oct 2022 02:32:02 +0000 (02:32 +0000)]
Fix typo in debug messages.

ok deraadt@

2 years agoAdd PNP ID to make this attach on Qualcomm SoCs.
kettenis [Sat, 8 Oct 2022 19:46:52 +0000 (19:46 +0000)]
Add PNP ID to make this attach on Qualcomm SoCs.

ok mglocker@, patrick@

2 years agoList SIMCom SIM8262E-M2 as supported for umb(4)
kevlo [Sat, 8 Oct 2022 17:08:55 +0000 (17:08 +0000)]
List SIMCom SIM8262E-M2 as supported for umb(4)

ok jmc@

2 years agoThe stack can also be marked immutable, because we expect no sane program
deraadt [Sat, 8 Oct 2022 17:03:09 +0000 (17:03 +0000)]
The stack can also be marked immutable, because we expect no sane program
to try to change the permissions of it.  We won't know who's trying that
until we enable it and see what breaks.
A tricky piece relating to setrlimit stack size changing was previously commited.
ok kettenis

2 years agoThe signal trampoline and timekeep regions can be marked immutable at
deraadt [Sat, 8 Oct 2022 16:58:34 +0000 (16:58 +0000)]
The signal trampoline and timekeep regions can be marked immutable at
execve() time
ok kettenis

2 years agoSince the PF_MUTABLE flag is an OpenBSD-specific flag, rename it to
kettenis [Sat, 8 Oct 2022 16:42:41 +0000 (16:42 +0000)]
Since the PF_MUTABLE flag is an OpenBSD-specific flag, rename it to
PF_OPENBSD_MUTABLE.  While there, add the missing PF_MASKOS, which makes
it obvious this bit is indeed in the space reserved for OS-specific bits.

ok deraadt@

2 years agoregen
mglocker [Sat, 8 Oct 2022 06:55:49 +0000 (06:55 +0000)]
regen

2 years agoAdd Wacom One M CTL-672 USB tablet.
mglocker [Sat, 8 Oct 2022 06:53:06 +0000 (06:53 +0000)]
Add Wacom One M CTL-672 USB tablet.

2 years agoFix some error output, replacing some silly 'warnx("\n...")' with
krw [Fri, 7 Oct 2022 19:59:19 +0000 (19:59 +0000)]
Fix some error output, replacing some silly 'warnx("\n...")' with
fprintf(stderr, "\n...").

Reported by Michael Siegel via bugs@. ok tb@ (with some further suggestions)

2 years agoNuke GPTDOSACTIVE which specified the wrong bit. It was superseded by
krw [Fri, 7 Oct 2022 19:34:40 +0000 (19:34 +0000)]
Nuke GPTDOSACTIVE which specified the wrong bit. It was superseded by
GPTPARTATTR_BOOTABLE which specifies the correct one.

Reminded by drahn@

2 years agosort SEE ALSO;
jmc [Fri, 7 Oct 2022 16:31:36 +0000 (16:31 +0000)]
sort SEE ALSO;

2 years agosync
deraadt [Fri, 7 Oct 2022 15:43:41 +0000 (15:43 +0000)]
sync

2 years agoShow the entry immutable bit in the various output formats.
deraadt [Fri, 7 Oct 2022 15:22:10 +0000 (15:22 +0000)]
Show the entry immutable bit in the various output formats.

2 years agoAdd mimmutable(2) libc stub, add & adjust manual pages, and crank the minor.
deraadt [Fri, 7 Oct 2022 15:21:04 +0000 (15:21 +0000)]
Add mimmutable(2) libc stub, add & adjust manual pages, and crank the minor.
ok kettenis

2 years agoIn the linkers, collect objects in section "openbsd.mutable" and place
deraadt [Fri, 7 Oct 2022 15:04:51 +0000 (15:04 +0000)]
In the linkers, collect objects in section "openbsd.mutable" and place
them into a page-aligned region in the bss, with the right markers for
kernel/ld.so to identify the region and skip making it immutable.
While here, fix readelf/objdump versions to show all of this.
ok miod kettenis

2 years agosync
deraadt [Fri, 7 Oct 2022 15:00:12 +0000 (15:00 +0000)]
sync

2 years agoAdd mimmutable(2) system call which locks the permissions (PROT_*) of
deraadt [Fri, 7 Oct 2022 14:59:39 +0000 (14:59 +0000)]
Add mimmutable(2) system call which locks the permissions (PROT_*) of
memory mappings so they cannot be changed by a later mmap(), mprotect(),
or munmap(), which will error with EPERM instead.
ok kettenis

2 years agoKill extra space in ext community ovs output.
claudio [Fri, 7 Oct 2022 09:20:30 +0000 (09:20 +0000)]
Kill extra space in ext community ovs output.
Noticed by job@, OK tb@

2 years agossh-agent.1:
jmc [Fri, 7 Oct 2022 06:00:58 +0000 (06:00 +0000)]
ssh-agent.1:
- use Nm not Xr for self-ref
- while here, wrap a long line

ssh-agent.c:
- add -O to usage()

2 years agonew UVM_ET_IMMUTABLE flag marks a uvm entry as immutable.
deraadt [Fri, 7 Oct 2022 05:01:44 +0000 (05:01 +0000)]
new UVM_ET_IMMUTABLE flag marks a uvm entry as immutable.

2 years agodocument "-O no-restrict-websafe"; spotted by Ross L Richardson
djm [Fri, 7 Oct 2022 04:06:26 +0000 (04:06 +0000)]
document "-O no-restrict-websafe"; spotted by Ross L Richardson

2 years agoAdd identifiers for the new "mutable bss" section, ".openbsd.mutable" is
deraadt [Fri, 7 Oct 2022 03:20:58 +0000 (03:20 +0000)]
Add identifiers for the new "mutable bss" section, ".openbsd.mutable" is
0x65a3dbe5.  Also add PF_MUTABLE as a segment flag for later use.

2 years agounstub intel_guc_send_busy_loop() ct_send()
jsg [Fri, 7 Oct 2022 03:12:22 +0000 (03:12 +0000)]
unstub intel_guc_send_busy_loop() ct_send()

2 years agoadd msleep_interruptible()
jsg [Fri, 7 Oct 2022 03:09:26 +0000 (03:09 +0000)]
add msleep_interruptible()

2 years agounstub guc_ct_buffer_reset() h2g_has_room()
jsg [Fri, 7 Oct 2022 03:05:28 +0000 (03:05 +0000)]
unstub guc_ct_buffer_reset() h2g_has_room()

2 years agoadd CIRC_SPACE()
jsg [Fri, 7 Oct 2022 03:00:44 +0000 (03:00 +0000)]
add CIRC_SPACE()

2 years agounstub guc_mmio_reg_add()
jsg [Fri, 7 Oct 2022 02:59:25 +0000 (02:59 +0000)]
unstub guc_mmio_reg_add()

2 years agoadd bsearch() from libc
jsg [Fri, 7 Oct 2022 02:58:01 +0000 (02:58 +0000)]
add bsearch() from libc

2 years agounstub i915_gem_object_create_shmem_from_data()
jsg [Fri, 7 Oct 2022 02:52:46 +0000 (02:52 +0000)]
unstub i915_gem_object_create_shmem_from_data()

2 years agoBuild CRC calc/static block decode tables when needed to fix netboot
kn [Thu, 6 Oct 2022 23:32:17 +0000 (23:32 +0000)]
Build CRC calc/static block decode tables when needed to fix netboot

The last libz update broke sparc64's ofwboot.net on at least T4-2 machines
running OpenBoot 4.38.16 as bootblocks grew too big for OBP to load:

# size ofwboot.net.*
60684   596     2472    63752   f908    ofwboot.net.71
71340   596     2472    74408   122a8   ofwboot.net.snap

{0} ok boot net
Boot device: /virtual-devices@100/channel-devices@200/network@0  File and args:
TFTP: Transfer timed out

As suggested by tb, adapt b7dd453d18bbd69c3a22e9c7e44e83163348942a to make
OBP load and execute ofwboot.net over TFTP again on at least T4-2 and T5220
where ofwboot off disk keeps loading and both bootblocks boot plain and
gzipped kernels before.

Overall size is now smaller that 7.1 release:
-current
71340   596     2472    74408   122a8   ofwboot.net/obj/ofwboot.net
119580  532     2512    122624  1df00   ofwboot/obj/ofwboot
71140   532     2472    74144   121a0   ofwbootfd/obj/ofwbootfd
-current with -DDYNAMIC_CRC_TABLE -DBUILDFIXED
59788   608     15040   75436   126ac   ofwboot.net/obj/ofwboot.net
108028  544     15080   123652  1e304   ofwboot/obj/ofwboot
59588   544     15040   75172   125a4   ofwbootfd/obj/ofwbootfd

happy kettenis
OK tb

2 years agohonour user's umask if it is more restrictive then the ssh default
djm [Thu, 6 Oct 2022 22:42:37 +0000 (22:42 +0000)]
honour user's umask if it is more restrictive then the ssh default
(022); based on patch from Alex Henrie, ok dtucker@ deraadt@

2 years agoregen after vdsp(4) crank
kn [Thu, 6 Oct 2022 21:43:32 +0000 (21:43 +0000)]
regen after vdsp(4) crank

2 years agocrank vdsp(4) to 24
kn [Thu, 6 Oct 2022 21:43:01 +0000 (21:43 +0000)]
crank vdsp(4) to 24

With eight domains and two or more disks per domain it is easy to exceed the
current number of 16 virtual disks.

I pass at least one miniroot and one root/data disk to every guest, one
domain has additional disk for softraid testing, making >16 disks already.

OK kettenis

2 years agoaccept iodevices as NACs as well
kn [Thu, 6 Oct 2022 21:35:52 +0000 (21:35 +0000)]
accept iodevices as NACs as well

Assignable PCIe devices have a root complex path and a more descriptive
I/O slot path;  example output from a T4-2:

# ldomctl list-io | head -n2
PATH             NAME
/@400/@2/@0/@8   /SYS/MB/PCIE0

ldom.conf(5) `iodevice' currently accepts PATH values, which are cryptic and
completely hardware specific, whereas NAME values are obvious (partially
same across machines) and match physical slot labels ("0 PCIe2 x8") besides
information from ILOM:
    /System/PCI_Devices/Add-on/Device_0 location = PCIE0 (PCIe Slot 0).

Make ldom.conf `iodevice' accept either value;  internally nothing changes.

Rename struct iodev's path member to dev to clarify this further.

OK kettenis

2 years agoRemove a lot of old (dead) code that's either been superseded, or moved to
martijn [Thu, 6 Oct 2022 14:41:08 +0000 (14:41 +0000)]
Remove a lot of old (dead) code that's either been superseded, or moved to
snmpd_metrics.

OK benno@ sthen@

2 years agounwrap two lines for readability
tb [Wed, 5 Oct 2022 21:16:14 +0000 (21:16 +0000)]
unwrap two lines for readability

2 years agoGet rid of useless/confusing subshell
kn [Wed, 5 Oct 2022 19:30:47 +0000 (19:30 +0000)]
Get rid of useless/confusing subshell

This function's style is a bit off:  it wraps the body in a subshell to
discard all stdout/err at once, but still uses return inside it.

1. A command list (using {}) would be enough here as it groups like a
   subshell but avoids spawning another shell;
2. discarding stdout/err at the end of an if block works the same
   (effecting both condition and body) and saves one level of indent;
3. return inside a subshell inside a function does NOT return from the
   function but merely exits the subshell;  this is easily misread.

Saving a fork and indent and improving readability boils down to this
(cvs diff -wU1):

|@@ -3320,3 +3317,2 @@ check_unattendedupgrade() {
|  _d=${_d%% *}
|- (
|  if [[ -n $_d ]]; then
|@@ -3331,5 +3327,5 @@ check_unattendedupgrade() {
|  rm -f /dev/{r,}$_d?
|- fi
|+ fi >/dev/null 2>&1
|+
|  return $_rc
|- ) > /dev/null 2>&1
| }

OK halex

2 years agoSkip softraid(4) keydisks
kn [Wed, 5 Oct 2022 09:58:43 +0000 (09:58 +0000)]
Skip softraid(4) keydisks

Keydisks appear as chunks internally (with special properties) and
installboot(8) thus treated them like actual data chunks.

Most users probably don't hit this as their keydisk is detached and thus
appears "offline" and gets skipped.

Installing to online keydisks may work but is neither expected nor intended
to work, so properly skip them.

Odd setups like keydisk and CRYPTO chunk on the same physical disk would
end up installing getting bootblocks installed twice.

Pointed out by Mikolaj Kucharski <mikolaj AT kucharski DOT name> who also
provided the actual diff (minor wording tweaks by me)

OK jsing

2 years agosort options list;
jmc [Wed, 5 Oct 2022 05:40:16 +0000 (05:40 +0000)]
sort options list;

2 years agoRemove REQUIRE_TFTPBOOT left-over
kn [Tue, 4 Oct 2022 23:58:09 +0000 (23:58 +0000)]
Remove REQUIRE_TFTPBOOT left-over

-t succeeded this macro in 2004.

2 years agoSwitch default to read-only, add -w for write access (previous default)
kn [Tue, 4 Oct 2022 23:33:22 +0000 (23:33 +0000)]
Switch default to read-only, add -w for write access (previous default)

Write access seems less often required these days and other ways to ensure
effective read-only access are mere workarounds;  worst case malicious users
can fill up the server's disk by writing to existing files.

diskless(8) only ever needs to read and running with "stdio rpath dns inet"
by default is much safer for a network daemon without any authentication.

Initially proposed as a new -R flag for read-only mode
new default suggestion dlg deraadt
"looks great" millert
OK sthen dlg

2 years agoCorrectly check for DH_compute_key() error
tb [Tue, 4 Oct 2022 20:46:13 +0000 (20:46 +0000)]
Correctly check for DH_compute_key() error

DH_size() only gives an upper bound for the size of the key. The key can be
shorter.

Found after anton reported sporadic regress test failures

ok jsing

2 years agoReplace temporary file with variable
kn [Tue, 4 Oct 2022 19:59:10 +0000 (19:59 +0000)]
Replace temporary file with variable

On supported -release systems, syspatch(8) -c is run from rc.firsttime(8)
and the list of patches it pretty-printed if non-empty.

-c output fits into a shell variable, not needing a temporary file, which
is also what usr.sbin/syspatch/syspatch.sh does internally.

OK millert

2 years agoOn CPUs that support the Data Independent Timing feature, enable this feature
kettenis [Tue, 4 Oct 2022 19:41:21 +0000 (19:41 +0000)]
On CPUs that support the Data Independent Timing feature, enable this feature
by default in both the kernel and userland.  At this point, this feature has
only been seen on Apple's CPU cores, where turning it on has no measurable
impact on performance.  Turning this feature on should help to mitigate
timing side-channel attacks.

ok deraadt@, beck@

2 years agoRepair Apple-specific translation support broken by mistake in 1.88; reported
miod [Tue, 4 Oct 2022 19:38:20 +0000 (19:38 +0000)]
Repair Apple-specific translation support broken by mistake in 1.88; reported
by Leonardo Moreno

2 years agoAdd a few more PSTATE bits.
kettenis [Tue, 4 Oct 2022 19:36:20 +0000 (19:36 +0000)]
Add a few more PSTATE bits.

ok deraadt@

2 years agosh(1) is not make(1), use newlines inside double quotes
kn [Tue, 4 Oct 2022 19:34:44 +0000 (19:34 +0000)]
sh(1) is not make(1), use newlines inside double quotes

sh(1) happily accepts newlines inside double quotes just like in scripts:

        $ sh -c "echo foo
echo bar"
foo
bar

So no need to squash things into a single line as usually done inside make
targets where each makefile line is considered its own script unless
continued with trailing backslashes.

OK millert

2 years agofix an obvious thinko without serious consequences in the display of e
espie [Tue, 4 Oct 2022 15:31:02 +0000 (15:31 +0000)]
fix an obvious thinko without serious consequences in the display of e
for rsa and friends.

okay tb@

2 years agoBetter path handling description, also document tzname, timezone daylight.
millert [Tue, 4 Oct 2022 13:33:57 +0000 (13:33 +0000)]
Better path handling description, also document tzname, timezone daylight.
Explicitly mention that most programs do not need to call tzset() directly.
OK deraadt@ jmc@ benno@

2 years agoSort commands in help output, add help to manual
kn [Tue, 4 Oct 2022 08:03:26 +0000 (08:03 +0000)]
Sort commands in help output, add help to manual

OK millert
Feedback OK jmc

2 years agoDrop cpath promise unless file creation is allowed
kn [Tue, 4 Oct 2022 07:05:28 +0000 (07:05 +0000)]
Drop cpath promise unless file creation is allowed

OK millert

2 years agoOnly print prompt in interactive usage
kn [Tue, 4 Oct 2022 07:03:27 +0000 (07:03 +0000)]
Only print prompt in interactive usage

Scripting tftp(1) makes it non-interactive, yet the prompt is still
printed and may mess up the shell's PS1:
$ echo put nonexistent | tftp localhost
tftp> tftp: open: nonexistent: No such file or directory
tftp> $

The fix seems easy and works as expected for multiple commands as well:
$ echo 'verbose\nput nonexistent' | ./obj/tftp localhost
Verbose mode on.
tftp: open: nonexistent: No such file or directory
$

OK millert

2 years agoUnveil /tftpboot only if needed
kn [Tue, 4 Oct 2022 07:01:38 +0000 (07:01 +0000)]
Unveil /tftpboot only if needed

Unless -t is used, this directory is not accessed in any way.

OK millert

2 years agoDon't print device when passed as an argument
kn [Tue, 4 Oct 2022 06:52:52 +0000 (06:52 +0000)]
Don't print device when passed as an argument

r1.11 "Don't print device name on failure" made it print unconditionally,
which contradicts what the manual says.

Report + diff from Brin Conway <bconway AT rcesoftware DOT com>, thanks.

From Brian Conway

2 years agosync
deraadt [Tue, 4 Oct 2022 02:58:41 +0000 (02:58 +0000)]
sync

2 years agodapmic(4): support clean shutdown with the power button
jca [Mon, 3 Oct 2022 21:02:02 +0000 (21:02 +0000)]
dapmic(4): support clean shutdown with the power button

Register an interrupt handler and look for nONKEY events.
Mask off all other events.  Also clear the FAULT_LOG register at
startup, but don't attempt to acknowledge its contents at runtime.  This
lets the user force a shutdown with a long power button press.  Some
events in EVENT_* or FAULT_LOG may benefit from more graceful handling.

This makes it possible to cleanly shutdown my Hifive Unmatched using
the power button.

Thanks to kettenis@ who wrote sfgpio(4) to handle dapmic(4) interrupts
on the Unmatched.  ok kettenis@

2 years agoReorganize the EFI code a bit. Move the efi.h header from dev/acpi to
kettenis [Mon, 3 Oct 2022 19:32:22 +0000 (19:32 +0000)]
Reorganize the EFI code a bit.  Move the efi.h header from dev/acpi to
dev/efi and rename the arm64 efi.c to efi_machdep.c, preparing the way
for MI EFI code and an amd64 implementation of EFI runtime support.

ok deraadt@, mlarkin@

2 years agoSystem calls should not fail due to temporary memory shortage in
bluhm [Mon, 3 Oct 2022 16:43:52 +0000 (16:43 +0000)]
System calls should not fail due to temporary memory shortage in
malloc(9) or pool_get(9).
Pass down a wait flag to pru_attach().  During syscall socket(2)
it is ok to wait, this logic was missing for internet pcb.  Pfkey
and route sockets were already waiting.
sonewconn() must not wait when called during TCP 3-way handshake.
This logic has been preserved.  Unix domain stream socket connect(2)
can wait until the other side has created the socket to accept.
OK mvs@

2 years agoAllow TZ to contain absolutes paths starting with /usr/share/zoneinfo/
millert [Mon, 3 Oct 2022 15:34:39 +0000 (15:34 +0000)]
Allow TZ to contain absolutes paths starting with /usr/share/zoneinfo/
Other absolutes paths are still rejected.

2 years agoAdd a second membar producer into counters_zero(). Now it is
bluhm [Mon, 3 Oct 2022 14:10:53 +0000 (14:10 +0000)]
Add a second membar producer into counters_zero().  Now it is
symmetric to counters_read().
OK jmatthew@

2 years agodrm/amdgpu: don't register a dirty callback for non-atomic
jsg [Mon, 3 Oct 2022 12:02:12 +0000 (12:02 +0000)]
drm/amdgpu: don't register a dirty callback for non-atomic

From Alex Deucher
21b0301f2234112fbe5cfc1e13968f0a12f0f2d2 in linux 5.15.y/5.15.71
abbc7a3dafb91b9d4ec56b70ec9a7520f8e13334 in mainline linux