openbsd
3 years ago"intrisic" -> "intrinsic" in a couple of comments.
krw [Mon, 7 Jun 2021 13:38:58 +0000 (13:38 +0000)]
"intrisic" -> "intrinsic" in a couple of comments.

3 years agobtrace(8): add "cpu" to long conversion
dv [Mon, 7 Jun 2021 12:55:19 +0000 (12:55 +0000)]
btrace(8): add "cpu" to long conversion

Special values need to be translated to longs for use with functions
like hist/lhist. Add "cpu" to conversion list.

ok mpi@

3 years agotweak previous: avoid markup and refer to an HTTP header only by its
tb [Mon, 7 Jun 2021 10:53:59 +0000 (10:53 +0000)]
tweak previous: avoid markup and refer to an HTTP header only by its
name as is done elsewhere on this page.

pointed out by jmc

3 years agoKill SS_ASYNC and only check SB_ASYNC when async signals are wanted.
mpi [Mon, 7 Jun 2021 09:10:32 +0000 (09:10 +0000)]
Kill SS_ASYNC and only check SB_ASYNC when async signals are wanted.

This socket flag was redundant with the socket buffer one.

ok mvs@

3 years agoChanging the default from (W)hole disk to (E)dit MBR wasn't enough to prevent
kettenis [Mon, 7 Jun 2021 07:38:55 +0000 (07:38 +0000)]
Changing the default from (W)hole disk to (E)dit MBR wasn't enough to prevent
folks from shooting themselves in the foot.  Make sure (W) can't be used
if an "APFS ISC" is found on the disk.  This is the most essential
partition that is required for Apple M1 machines to boot.

ok krw@, deraadt@

3 years agofix debug message when finding a private key to match a certificate
djm [Mon, 7 Jun 2021 03:38:38 +0000 (03:38 +0000)]
fix debug message when finding a private key to match a certificate
being attempted for user authentication. Previously it would print
the certificate's path, whereas it was supposed to be showing the
private key's path. Patch from Alex Sherwin via GHPR247

3 years agotest AuthenticationMethods inside a Match block as well as in
djm [Mon, 7 Jun 2021 01:16:34 +0000 (01:16 +0000)]
test AuthenticationMethods inside a Match block as well as in
the main config section

3 years agoReplace all uses of 'EFI_CALL(func, params)' with
krw [Mon, 7 Jun 2021 00:04:20 +0000 (00:04 +0000)]
Replace all uses of 'EFI_CALL(func, params)' with
the expansion 'func(params)'.

Allows upcoming removal of eficall.h.

3 years agoprepare for stricter sshd_config parsing that will refuse a config
djm [Mon, 7 Jun 2021 00:00:50 +0000 (00:00 +0000)]
prepare for stricter sshd_config parsing that will refuse a config
that has {Allow,Deny}{Users,Groups} on a line with no subsequent
arguments. Such lines are permitted but are nonsensical noops ATM

3 years agoReplace all uses of 'EFI_CALL(func, params)' with
krw [Sun, 6 Jun 2021 23:56:55 +0000 (23:56 +0000)]
Replace all uses of 'EFI_CALL(func, params)' with
the expansion 'func(params)'.

Allows upcoming removal of eficall.h.

Tested & ok naddy@

3 years agoTest must build also when started with make regress. Use consistent
bluhm [Sun, 6 Jun 2021 22:53:06 +0000 (22:53 +0000)]
Test must build also when started with make regress.  Use consistent
variable names in make file.

3 years agoappease mandoc -Tlint
tb [Sun, 6 Jun 2021 22:00:35 +0000 (22:00 +0000)]
appease mandoc -Tlint

3 years agoAdd .Pp for consistency with all other config blocks.
tb [Sun, 6 Jun 2021 21:59:20 +0000 (21:59 +0000)]
Add .Pp for consistency with all other config blocks.

3 years agoUse installboot(8) on arm64 ramdisks like we do for amd64.
kettenis [Sun, 6 Jun 2021 18:58:14 +0000 (18:58 +0000)]
Use installboot(8) on arm64 ramdisks like we do for amd64.

ok krw@

3 years agoMatch host certificates against host public keys, not private keys.
djm [Sun, 6 Jun 2021 11:34:16 +0000 (11:34 +0000)]
Match host certificates against host public keys, not private keys.
Allows use of certificates with private keys held in a ssh-agent.
Reported by Miles Zhou in bz3524; ok dtucker@

3 years agoAdd firmware selection for BRCM_CC_43241_CHIP_ID (0x4324).
aoyama [Sun, 6 Jun 2021 10:48:30 +0000 (10:48 +0000)]
Add firmware selection for BRCM_CC_43241_CHIP_ID (0x4324).

According to NetBSD, this chip uses one of three firmwares depending
on its revision, but all of them are already included in the
bwfm-firmware package, so we can load one of them.

ok patrick@ sthen@

3 years agoClient-side workaround for a bug in OpenSSH 7.4: this release allows
djm [Sun, 6 Jun 2021 03:40:39 +0000 (03:40 +0000)]
Client-side workaround for a bug in OpenSSH 7.4: this release allows
RSA/SHA2 signatures for public key authentication but fails to advertise
this correctly via SSH2_MSG_EXT_INFO. This causes clients of these
server to incorrectly match PubkeyAcceptedAlgorithms and potentially
refuse to offer valid keys.

Reported by and based on patch from Gordon Messmer via bz3213, thanks
also for additional analysis by Jakub Jelen. ok dtucker

3 years agodegrade gracefully if a sftp-server offers the limits@openssh.com
djm [Sun, 6 Jun 2021 03:17:02 +0000 (03:17 +0000)]
degrade gracefully if a sftp-server offers the limits@openssh.com
extension but fails when the client tries to invoke it.
Reported by Hector Martin via bz3318

3 years agothe limits@openssh.com extension was incorrectly marked as an
djm [Sun, 6 Jun 2021 03:15:39 +0000 (03:15 +0000)]
the limits@openssh.com extension was incorrectly marked as an
operation that writes to the filesystem, which made it unavailable
in sftp-server read-only mode. Spotted by Hector Martin via bz3318

3 years agoPROTOCOL.certkeys: update reference from IETF draft to RFC
naddy [Sat, 5 Jun 2021 13:47:00 +0000 (13:47 +0000)]
PROTOCOL.certkeys: update reference from IETF draft to RFC

Also fix some typos.
ok djm@

3 years agothis file includes sys/param.h, so does not need to redefine PAGE_MASK
deraadt [Sat, 5 Jun 2021 13:32:52 +0000 (13:32 +0000)]
this file includes sys/param.h, so does not need to redefine PAGE_MASK

3 years agoRemove now unused eficall.S.
krw [Fri, 4 Jun 2021 15:19:38 +0000 (15:19 +0000)]
Remove now unused eficall.S.

prodded by jsg@

3 years agounbreak regress/libexec/ld.so/nodelete test
semarie [Fri, 4 Jun 2021 10:01:49 +0000 (10:01 +0000)]
unbreak regress/libexec/ld.so/nodelete test

pointed by bluhm@

3 years agoregen
mvs [Fri, 4 Jun 2021 09:06:09 +0000 (09:06 +0000)]
regen

3 years agoUnlock connect(2). Again.
mvs [Fri, 4 Jun 2021 09:05:19 +0000 (09:05 +0000)]
Unlock connect(2). Again.

ok mpi@

3 years agoavoid a use after free in a path taken if malloc M_NOWAIT fails
jsg [Fri, 4 Jun 2021 07:29:54 +0000 (07:29 +0000)]
avoid a use after free in a path taken if malloc M_NOWAIT fails

3 years agoThe RB_GENERATE_STATIC(3) macro expands to a series of function
djm [Fri, 4 Jun 2021 06:19:07 +0000 (06:19 +0000)]
The RB_GENERATE_STATIC(3) macro expands to a series of function
definitions and not a statement, so there should be no semicolon
following them. Patch from Michael Forney

3 years agorework authorized_keys example section, removing irrelevant stuff,
djm [Fri, 4 Jun 2021 05:59:18 +0000 (05:59 +0000)]
rework authorized_keys example section, removing irrelevant stuff,
de-wrapping the example lines and better aligning the examples with
common usage and FAQs; ok jmc

3 years agoadjust SetEnv description to clarify $TERM handling
djm [Fri, 4 Jun 2021 05:10:03 +0000 (05:10 +0000)]
adjust SetEnv description to clarify $TERM handling

3 years agoSwitch the listening select loop from select() to pselect() and
dtucker [Fri, 4 Jun 2021 05:09:08 +0000 (05:09 +0000)]
Switch the listening select loop from select() to pselect() and
mask signals while checking signal flags, umasking for pselect and
restoring afterwards. Also restore signals before sighup_restart
so they don't remain blocked after restart.

This prevents a race where a SIGTERM or SIGHUP can arrive between
checking the flag and calling select (eg if sshd is processing a
new connection) resulting in sshd not shutting down until the next
time it receives a new connection.  bz#2158, with & ok djm@

3 years agoallow ssh_config SetEnv to override $TERM, which is otherwise handled
djm [Fri, 4 Jun 2021 05:02:40 +0000 (05:02 +0000)]
allow ssh_config SetEnv to override $TERM, which is otherwise handled
specially by the protocol. Useful in ~/.ssh/config to set TERM to
something generic (e.g. "xterm" instead of "xterm-256color") for
destinations that lack terminfo entries. feedback and ok dtucker@

3 years agocorrect extension name "no-presence-required" => "no-touch-required"
djm [Fri, 4 Jun 2021 04:02:21 +0000 (04:02 +0000)]
correct extension name "no-presence-required" => "no-touch-required"

document "verify-required" option

3 years agodisable ppgtt on cherryview/braswell
jsg [Fri, 4 Jun 2021 01:52:21 +0000 (01:52 +0000)]
disable ppgtt on cherryview/braswell

With ppgtt enabled the contents of struct gen6_ppgtt are overwritten
leading to unexpected values for vma pointer such as 0 and 1.

Multiple people have reported problems with 6.9 on cherryview/braswell
with traces along the lines of

uvm_fault(0xffffffff8214ea68, 0xb8, 0, 1) -> e
kernel: page fault trap, code=0
Stopped at      i915_ggtt_pin+0x29:     movq    0xb8(%rdi),%r12
i915_ggtt_pin(0,10000,20) at i915_ggtt_pin+0x29
gen6_ppgtt_pin(ffff800000cb9400) at gen6_ppgtt_pin+0x7c
__intel_context_do_pin(fffffd817dc8ad80) at __intel_context_do_pin+0xca
intel_engines_init(ffff800000104c38) at intel_engines_init+0x4b5
intel_gt_init(ffff800000104c38) at intel_gt_init+0x130
i915_gem_init(ffff800000100000) at i915_gem_init+0xa3
i915_driver_probe(ffff800000100000,ffffffff81fc6e90) at i915_driver_probe+0x7ed

The "use drm_mm from linux 5.7.y" commit made last October is
implicated in the change in behaviour but does not itself have any
cherryview/braswell specific changes. There is at least one report on
misc@ which suggests this occurred in some situations with 6.8 which
lacks that change.

Thanks to the people who reported this in particular Matthias Pressfreund
who tested many patches.

3 years agomachine/cpu.h requires a pre-include of sys/time.h
deraadt [Fri, 4 Jun 2021 00:29:15 +0000 (00:29 +0000)]
machine/cpu.h requires a pre-include of sys/time.h

3 years agoyasuoka@ pointed out that amd64 clang now understands
krw [Fri, 4 Jun 2021 00:09:34 +0000 (00:09 +0000)]
yasuoka@ pointed out that amd64 clang now understands
'__attribute((ms_abi))', removing the need for the EFI_CALL
abstraction.

Nuke the amd64 EFI_CALL dance from all copies of eficall.h,
remove eficall.S from the build.

ok kettenis@ yasuoka@

3 years agoImplement multicast support in mvpp(4) to make IPv6 work. With this
patrick [Thu, 3 Jun 2021 21:42:23 +0000 (21:42 +0000)]
Implement multicast support in mvpp(4) to make IPv6 work.  With this
change it's also not necessary to remember the old lladdr, since the
old one will be purged automatically prior to installing the current
set of multicast addresses.

Complaint filed by matthieu@

3 years agoUse machdep.compatible to determine Pine64 and Raspberry Pi "platforms".
kettenis [Thu, 3 Jun 2021 17:08:56 +0000 (17:08 +0000)]
Use machdep.compatible to determine Pine64 and Raspberry Pi "platforms".
Also recognize Apple "platforms" and change the default from "whole" to
"edit" when installing on disk with a GPT on those.  This should prevent
users from accidentally overwriting essential partitions that are needed
to boot those machines.

ok deraadt@

3 years agoEnable machdep.compatible on platforms that have it.
kettenis [Thu, 3 Jun 2021 17:05:41 +0000 (17:05 +0000)]
Enable machdep.compatible on platforms that have it.

ok deraadt@

3 years agoUse O_DIRECTORY when opening directories. This makes some errors a bit
claudio [Thu, 3 Jun 2021 15:10:05 +0000 (15:10 +0000)]
Use O_DIRECTORY when opening directories. This makes some errors a bit
clearer when using -d.
OK deraadt@

3 years agoRecognize the Apple APFS GPT partition types seen on Apple M1 boxen.
krw [Thu, 3 Jun 2021 15:05:55 +0000 (15:05 +0000)]
Recognize the Apple APFS GPT partition types seen on Apple M1 boxen.

ok kettenis@

3 years ago(man page also)
deraadt [Thu, 3 Jun 2021 13:38:18 +0000 (13:38 +0000)]
(man page also)
secure_path(3) hasn't been called since we recognized the TOCTOU issues a few
years back, so we can remove it.  Since nothing in the ecosystem calls it, I
am not cranking the libc major as required, surely another crank will come
along soon.
noticed by Dante Catalfamo
ok millert

3 years agosecure_path(3) hasn't been called since we recognized the TOCTOU issues a few
deraadt [Thu, 3 Jun 2021 13:19:45 +0000 (13:19 +0000)]
secure_path(3) hasn't been called since we recognized the TOCTOU issues a few
years back, so we can remove it.  Since nothing in the ecosystem calls it, I
am not cranking the libc major as required, surely another crank will come
along soon.
noticed by Dante Catalfamo
ok millert

3 years agotypo
deraadt [Thu, 3 Jun 2021 13:14:03 +0000 (13:14 +0000)]
typo

3 years agoFor 4k sector disks, the minimum frag size is 4k. For a 2G fs
otto [Thu, 3 Jun 2021 06:42:03 +0000 (06:42 +0000)]
For 4k sector disks, the minimum frag size is 4k. For a 2G fs
that delivers too few inodes to hold a src tree.  So adjust the
density for partitions on a 4k disk if fragsize and density are not
passed on the command line. This is kind of a hack, since we do not
have a way to signal the desired # of inodes from the install script.
ok kettenis@ krw@

3 years agoip6_input_if used the ip6_hdr pointer uninitted after i refactored it.
dlg [Thu, 3 Jun 2021 04:47:54 +0000 (04:47 +0000)]
ip6_input_if used the ip6_hdr pointer uninitted after i refactored it.

i did test this, but i guess i was lucky. very lucky.

Coverity CID 1505114

3 years agoremember if the ipv4 header checksum is ok.
dlg [Thu, 3 Jun 2021 01:55:52 +0000 (01:55 +0000)]
remember if the ipv4 header checksum is ok.

if a bridge checks the ip header before the network stack, then we
can remember it was ok when the bridge checks it so the ip stack
doesnt have to.

ok claudio@ mvs@

3 years agoUse the same logic in all copies of gpt_chk_mbr(), relaxing the
krw [Wed, 2 Jun 2021 22:44:26 +0000 (22:44 +0000)]
Use the same logic in all copies of gpt_chk_mbr(), relaxing the
media length check to allow EFI GPT partitions to be smaller that
the entire disk.

Consistently use GPTSECTOR instead of randomly tossing in some
literal '1's.

ok kettenis@

3 years agoWith parallel execution of pf_test() two packets may try to update the same
sashan [Wed, 2 Jun 2021 21:49:31 +0000 (21:49 +0000)]
With parallel execution of pf_test() two packets may try to update the same
state in pfsync(4) queue. pfsync_q_ins() takes that race into account with one
exception: the KASSERT() at line 2352. That KASSERT()  needs to be removed.

2346 void
2347 pfsync_q_ins(struct pf_state *st, int q)
2348 {
2349    struct pfsync_softc *sc = pfsyncif;
2350    size_t nlen, sc_len;
2351
2352    KASSERT(st->sync_state == PFSYNC_S_NONE);
2353
2354 #if defined(PFSYNC_DEBUG)
2355         if (sc->sc_len < PFSYNC_MINPKT)
2356                 panic("pfsync pkt len is too low %zd", sc->sc_len);
2357 #endif
2358 do {
2359         mtx_enter(&sc->sc_mtx[q]);
2360
2361         /*
2362          * If two threads are competing to insert the same state, then
2363          * there must be just single winner.
2364          */
2365         if (st->sync_state != PFSYNC_S_NONE) {
2366                 mtx_leave(&sc->sc_mtx[q]);
2367                 break;
2368         }

OK bluhm@

3 years agoLinux folks introduced "10gbase-r" since it is "more correct" and we're
kettenis [Wed, 2 Jun 2021 21:41:38 +0000 (21:41 +0000)]
Linux folks introduced "10gbase-r" since it is "more correct" and we're
starting to see firmware that uses this instead of the "10gbase-kr" that
was used before to describe the PHYs.  So recognize both and treat that
the same.

ok deraadt@, patrick@

3 years agoAvoid spinning on the kernel lock with interrupts disabled.
kettenis [Wed, 2 Jun 2021 19:38:14 +0000 (19:38 +0000)]
Avoid spinning on the kernel lock with interrupts disabled.

ok gkoehler@

3 years agoWhen processing a received packet, only sync the amount of bytes
patrick [Wed, 2 Jun 2021 19:16:11 +0000 (19:16 +0000)]
When processing a received packet, only sync the amount of bytes
mcx(4) told us has arrived.  The DMA map's mapsize on RX packets
is the length of the allocated buffer.  For mcx(4), this can be
more than around 9000 bytes, as each buffer will be at least as
big as the maximum supported MTU.  There's no need to sync the
whole buffer, if it's only a small packet.

ok dlg@ jmatthew@

3 years agoCorrectly calculate number of PRPL entries we have to sync by adding
patrick [Wed, 2 Jun 2021 19:11:02 +0000 (19:11 +0000)]
Correctly calculate number of PRPL entries we have to sync by adding
brackets to manage operator precedence.  Otherwise we'd attempt to sync
more than needed, which doesn't cause issues, but it's still wrong.

ok dlg@ jmatthew@

3 years agosync
deraadt [Wed, 2 Jun 2021 18:44:16 +0000 (18:44 +0000)]
sync

3 years agoIn -W style mode, check .Xr links along the full manpath because
schwarze [Wed, 2 Jun 2021 18:27:36 +0000 (18:27 +0000)]
In -W style mode, check .Xr links along the full manpath because
that is more useful for validating manuals of non-base software.
Nothing changes in -W all mode: by default for -T lint, we still
assume we want to check base system conventions, including usually
not wanting to link to non-base manual pages.

The use case, a partial idea how to handle it, and a preliminary
patch was originally presented by kn@, then refined by me.
Final patch tested and OK'ed by kn@.

3 years agotest private use areas some more as they have proven fragile
schwarze [Wed, 2 Jun 2021 17:36:59 +0000 (17:36 +0000)]
test private use areas some more as they have proven fragile

3 years agoCleanup:
schwarze [Wed, 2 Jun 2021 16:35:25 +0000 (16:35 +0000)]
Cleanup:
1. Move invalid two-byte sequences after valid ones
and make their descriptions easier to understand.
2. Replace the wrong and confusing expression "middle byte"
with the correct term "start byte".
3. Add test lines for U+EFFFF and U+F0000.
4. Replace the unhelpful word "strange" with more descriptive terms.
Arguably, nothing about this (or maybe everything?) is strange.

3 years agoAdd GPT support; stolen from i386_installboot.c.
kettenis [Wed, 2 Jun 2021 16:12:18 +0000 (16:12 +0000)]
Add GPT support; stolen from i386_installboot.c.

ok krw@, deraadt@

3 years agoAdd support for booting from disks with 4k sectors. Inspired by the
kettenis [Wed, 2 Jun 2021 15:31:15 +0000 (15:31 +0000)]
Add support for booting from disks with 4k sectors.  Inspired by the
code we already have for amd64, but changed to use EFI memory allocation
interfaces as some implementations seem to insist on page-aligned memory.

ok krw@

3 years agoThe wcwidth(3) of Plane 15 and Plane 16 Private Use Characters
schwarze [Wed, 2 Jun 2021 15:07:42 +0000 (15:07 +0000)]
The wcwidth(3) of Plane 15 and Plane 16 Private Use Characters
was changed from 0 to 1. Adjust the test results accordingly.
Issue reported by bluhm@.

3 years agovmd(8): allow locking a randomly assigned lladdr
dv [Wed, 2 Jun 2021 14:40:46 +0000 (14:40 +0000)]
vmd(8): allow locking a randomly assigned lladdr

Provide a default value of a zero'd mac address so a user can still
specify the interface should be "locked" (only transmitting ethernet
packets with a matching source address). vmd will assign a random
address at vm launch.

As an example, this is now valid:

  vm "name" {
    interface {
      locked lladdr
    }
    ...
  }

From Martin Vahlensieck
ok claudio@

3 years agoEnable pool cache on knote pool
visa [Wed, 2 Jun 2021 13:56:28 +0000 (13:56 +0000)]
Enable pool cache on knote pool

Use the pool cache to reduce the overhead of memory management in
function kqueue_register().

When EV_ADD is given, kqueue_register() pre-allocates a knote to avoid
potential sleeping in the middle of the critical section that spans
from knote lookup to insertion. However, the pre-allocation is useless
if the lookup finds a matching knote.

The cost of knote allocation will become significant with kqueue-based
poll(2) and select(2) because the frequency of allocation will increase.
Most of the cost appears to come from the locking inside the pool.
The pool cache amortizes it by using CPU-local caches of free knotes
as buffers.

OK dlg@ mpi@

3 years agoregen
mvs [Wed, 2 Jun 2021 11:31:10 +0000 (11:31 +0000)]
regen

3 years agoUnlock setrtable(2). Local copy of `ps_rtableid' used to make checks
mvs [Wed, 2 Jun 2021 11:30:23 +0000 (11:30 +0000)]
Unlock setrtable(2). Local copy of `ps_rtableid' used to make checks
consistent.

ok mpi@

3 years agoThe getnext_indexoid tests now pass
martijn [Wed, 2 Jun 2021 08:41:16 +0000 (08:41 +0000)]
The getnext_indexoid tests now pass

3 years agoagentx_context_object_nfind had its ax_oid_cmp arguments swapped.
martijn [Wed, 2 Jun 2021 08:40:09 +0000 (08:40 +0000)]
agentx_context_object_nfind had its ax_oid_cmp arguments swapped.

OK bluhm@

3 years agoMake the hints at the bottom row sticky by turning the knobs toggles.
martijn [Wed, 2 Jun 2021 08:32:22 +0000 (08:32 +0000)]
Make the hints at the bottom row sticky by turning the knobs toggles.
Specifically this effects ^G, help and order.

While here also document the 'h' character.

Initial inspiration and diff from Anindya Mukherjee (anindya49 <at> hotmail
<dot> com)

OK bluhm@

3 years agowhitespace tweaks, no functional change.
dlg [Wed, 2 Jun 2021 07:46:22 +0000 (07:46 +0000)]
whitespace tweaks, no functional change.

3 years agoadd regress test for RTLD_NODELETE support
semarie [Wed, 2 Jun 2021 07:32:34 +0000 (07:32 +0000)]
add regress test for RTLD_NODELETE support

3 years agoadd RTLD_NODELETE support
semarie [Wed, 2 Jun 2021 07:29:03 +0000 (07:29 +0000)]
add RTLD_NODELETE support

if RTLD_NODELETE isn't POSIX, it is widely deployed: at least linux,
freebsd, dragonfly, netbsd, solaris, illumos, apple, and fuchsia have
it.

ok kettenis@ on previous version
with help from and ok guenther@

diff partially inspired from a diff from brad@

3 years agoonly read the if_bpf pointer once.
dlg [Wed, 2 Jun 2021 01:37:10 +0000 (01:37 +0000)]
only read the if_bpf pointer once.

3 years agotpmr_input is called in an smr crit section, so it doesnt need its own.
dlg [Wed, 2 Jun 2021 01:36:10 +0000 (01:36 +0000)]
tpmr_input is called in an smr crit section, so it doesnt need its own.

this simplifies the code a little bit.

3 years agoread the tpmr if_flags once in tpmr_input so link flags apply consistently.
dlg [Wed, 2 Jun 2021 01:30:30 +0000 (01:30 +0000)]
read the tpmr if_flags once in tpmr_input so link flags apply consistently.

this avoids IFF_LINK1 getting set by another cpu halfway through
tpmr_input. if LINK1 is not set when a packet enters a tpmr pair
it skips ip/pf checks, but if it is then set then only pf is run
against it. this way you either get the ip checks and pf when the
packet enters and leaves tpmr, or you dont get the ip and pf checks
at all.

3 years agouse ipv4_check and ipv6_check to well, check ip headers before running pf.
dlg [Wed, 2 Jun 2021 00:44:18 +0000 (00:44 +0000)]
use ipv4_check and ipv6_check to well, check ip headers before running pf.

unlike bridge(4), these checks are only run when the packet is
entering the veb/tpmr topology. the assumption is that only valid
IP packets end up inside the topology so we don't have to check
them when they're leaving.

ok bluhm@ sashan@

3 years agouse ipv4_check and ipv6_check provided by the network stacks.
dlg [Wed, 2 Jun 2021 00:40:51 +0000 (00:40 +0000)]
use ipv4_check and ipv6_check provided by the network stacks.

this removes the duplication of the check code, and lets the v6
code in particular pick up a lot more sanity checks around valid
addresses on the wire.

ok bluhm@ sashan@

3 years agokernel: introduce per-CPU panic(9) message buffers
cheloha [Wed, 2 Jun 2021 00:39:25 +0000 (00:39 +0000)]
kernel: introduce per-CPU panic(9) message buffers

Add a 512-byte buffer (ci_panicbuf) to each cpu_info struct on each
platform for use by panic(9).  The first panic on a given CPU writes
its message to this buffer.  Subsequent panics on a given CPU print
the panic message to the console but do not modify the buffer.  This
aids debugging in two cases:

- If 2+ CPUs panic simultaneously there is no risk of garbled messages
  in the panic buffer.

- If a CPU panics and then the operator causes a second panic while
  using ddb(4), the operator can still recall the first failure on
  a particular CPU.

Misc. changes to support this bigger change:

- Set panicstr atomically to identify the first CPU to reach panic().

- Tweak db_show_panic_cmd() to print all panic messages across all
  CPUs.  Prefix the first panic with an asterisk ('*').

- Prefer db_printf() to printf() during a panic if we have it.
  Apparently it disturbs less global state.

- On amd64, tweak fault() to write the local panic buffer.  This needs
  more work.

Prompted by bluhm@ and deraadt@.  Mostly written by deraadt@.
Discussed with bluhm@, deraadt@ and kettenis@.

Borne from a discussion on tech@ about making panic(9) more MP-safe:

https://marc.info/?l=openbsd-tech&m=162086462316143&w=2

ok kettenis@, visa@, bluhm@, deraadt@

3 years agodon't init a pointer just to immediately set it again.
dlg [Wed, 2 Jun 2021 00:27:03 +0000 (00:27 +0000)]
don't init a pointer just to immediately set it again.

this is in ip6_input_if just before ipv6_check returns the pointer
we end up using.

pointed out by bluhm@

3 years agofactor out the code that does sanity checks on ipv6 headers and addresses.
dlg [Wed, 2 Jun 2021 00:20:50 +0000 (00:20 +0000)]
factor out the code that does sanity checks on ipv6 headers and addresses.

this will allow these checks to be reused for ip packet inspection
in bridge, veb, and tpmr.

ok bluhm@ sashan@

3 years agoMerge back shell portability changes bringing it back in sync with
dtucker [Wed, 2 Jun 2021 00:17:45 +0000 (00:17 +0000)]
Merge back shell portability changes bringing it back in sync with
-portable.

3 years agofactor out the code that does basic sanity checks on ipv4 headers.
dlg [Wed, 2 Jun 2021 00:09:57 +0000 (00:09 +0000)]
factor out the code that does basic sanity checks on ipv4 headers.

this will allow these checks to be reused by bridge (where they're
currently duplicated), veb, and tpmr.

ok bluhm@ sashan@

3 years agoUse a default value for $OPENSSL, allowing it to be overridden.
dtucker [Tue, 1 Jun 2021 23:56:20 +0000 (23:56 +0000)]
Use a default value for $OPENSSL, allowing it to be overridden.
Do the same in the PuTTY tests since it's needed there and not exported
by test-exec.sh.

3 years agoMake spoofed disklabel boundstart and boundend default to the bounds
krw [Tue, 1 Jun 2021 22:54:43 +0000 (22:54 +0000)]
Make spoofed disklabel boundstart and boundend default to the bounds
of the usable LBA range defined by the GPT header. And then shrink
them to the bounds of the first OpenBSD partition if one is found.

While here simplify the logic, eliminate some superfluous variables
and reduce use of magic numbers.

Improvement suggested by sobrado@ ok kettenis@

3 years agoDon't clear the cpu's bit in the old pmap's pm_cpus until we're off
guenther [Tue, 1 Jun 2021 21:12:11 +0000 (21:12 +0000)]
Don't clear the cpu's bit in the old pmap's pm_cpus until we're off
the old one and set it in the new pmap's pm_cpus before loading
%cr3 with the new value.  In particular, do neither if %cr3 isn't
changing.

This eliminates a window where, when switching between threads in
a single a process, the pmap wouldn't have this cpu's bit set even
though we didn't change %cr3.  With more of uvm unlocked, it was
possible for another cpu to update the page tables but not see a
need to send an IPI to this cpu, leading to crashes when TLB entries
that should have been invalidated were used.

malloc_duel testing by abluhm@
ok abluhm@ kettenis@ mlarkin@

3 years agoRemember flow routes in addition to host routes and delete
tobhe [Tue, 1 Jun 2021 20:57:12 +0000 (20:57 +0000)]
Remember flow routes in addition to host routes and delete
them explicitly on shutdown.  Store netmask in route queue
to fix cleanup of 0/1 routes.  Sending delete messages
without mask doesn't work reliably.

ok patrick@

3 years agoUpdate RFC reference. RFC 4366 was obsoleted by RFC 6066.
tb [Tue, 1 Jun 2021 20:26:11 +0000 (20:26 +0000)]
Update RFC reference. RFC 4366 was obsoleted by RFC 6066.

3 years agoAvoid sending a trailing dot in SNI as a client
tb [Tue, 1 Jun 2021 20:14:17 +0000 (20:14 +0000)]
Avoid sending a trailing dot in SNI as a client

While an FQDN includes a trailing dot for the zero-length label of
the root, SNI explicitly does not contain it. Contrary to other TLS
implementations, our tlsext_sni_is_valid_hostname() rejects a trailing
dot. The result is that LibreSSL TLS servers encountering an SNI with
trailing dot abort the connection with an illegal_parameter alert.

This fixes an issue reported by danj in nc(1) and by sthen in ftp(1).
DNS cluebat from florian.

ok jsing

3 years agoRemove unnecessary cast in free.
tb [Tue, 1 Jun 2021 19:49:17 +0000 (19:49 +0000)]
Remove unnecessary cast in free.

ok jsing

3 years agoRevert iwm(4) firmware updates for now; robert@ reports stalled Tx on 9260
stsp [Tue, 1 Jun 2021 18:03:56 +0000 (18:03 +0000)]
Revert iwm(4) firmware updates for now; robert@ reports stalled Tx on 9260

3 years agoCheck `so_state' in rtm_senddesync() and return if SS_ISCONNECTED or
mvs [Tue, 1 Jun 2021 14:23:34 +0000 (14:23 +0000)]
Check `so_state' in rtm_senddesync() and return if SS_ISCONNECTED or
SS_CANTRCVMORE bits are set.

The first check required to prevent timeout_add(9) reschedule
`rop_timeout', otherwise timeout_del_barrier(9) can't help us.

The second check is for the case when shutdown(2) with SHUT_RD argument
occurred on this socket and we should not receive anything include
RTM_DESYNC packets.

ok claudio@

3 years agoSwitch iwm(4) to new firmware images available in iwm-firmware-20210512.
stsp [Tue, 1 Jun 2021 13:21:08 +0000 (13:21 +0000)]
Switch iwm(4) to new firmware images available in iwm-firmware-20210512.

This updates firmware for 3165, 3168, 7265, 8260, 8265, 9260, 9560 devices.
Other devices did not receive firmware updates from Intel.
New firmware images should contain revelant fixes for fragattacks:
https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00473.html

Running fw_update(1) may be required before rebooting into a new kernel.
sysupgrade(8) will take care of this.

When reporting issues (I am sure there will be new "fatal firmware errors"
for some people) please enable 'ifconfig iwm0 debug', reproduce the error
once more, and include the full dmesg in your bug report.

Important changes required for new firmware:
- Support new variants of several existing firmware commands just
  because Intel loves adding new features and changing the commands.
- Implement the 'clear persistence bit' workaround for 9k devices to
  avoid potential issues during suspend/resume.
- Recognize Mobile Country Code update notifications for the regulatory
  domain, like iwx(4) does.
- Handle PHY context updates more like the Linux iwlwifi driver does.
  Some devices need an add/remove dance if the band has changed.
- For 9560, configure SoC latency parameters after booting firmware.
- Handle critical temperature notifications by shutting the device down.
- Use only antenna B for single-antenna Tx on 9k devices (matches what
  Linux and FreeBSD do; Likely only matters if Bluetooth is active, but
  who knows, Git logs and comments are the only documentation we have).

Other small fixes:
- Fix various scan command parameters. Some fixes were taken from iwx(4).
- Don't send probe requests when scanning passive channels. Experimentation
  has shown that this will make 9k devices crash after associating to an AP.
  This same fix does not seem to work on iwx(4) devices, where active scan
  is disabled for the same reason, and it is not yet clear why.
- Fix firmware reloading after parsing the firmware image has failed.
- Flushing Tx rings will fail if the AP disappears. Don't make any noise
  about that in dmesg, instead gracefully reset the device and continue.

Tested:
7260: florian
3168: kevlo
7265: stsp, mlarkin
8260: bket
8265: stsp, benno
9560: stsp, steven

3 years agoIntroduce the new test which enforces unp_gc() run and close
mvs [Tue, 1 Jun 2021 13:13:10 +0000 (13:13 +0000)]
Introduce the new test which enforces unp_gc() run and close
unreferenced descriptors.

ok bluhm@

3 years agoFix iwx(4) firmware reloading after a failure to parse the firmware file.
stsp [Tue, 1 Jun 2021 12:33:54 +0000 (12:33 +0000)]
Fix iwx(4) firmware reloading after a failure to parse the firmware file.

Noticed by Peter N. M. Hansteen

This issue will also be fixed in iwm(4) soon, along with a firmware update.

3 years agoa couple of minor whitespace tweaks. no functional change.
dlg [Tue, 1 Jun 2021 09:57:11 +0000 (09:57 +0000)]
a couple of minor whitespace tweaks. no functional change.

am i a pf hacker now?

3 years agoamd64 U-Boot arch code should be ARCH_X86_64 not ARCH_IA64
jsg [Tue, 1 Jun 2021 02:59:01 +0000 (02:59 +0000)]
amd64 U-Boot arch code should be ARCH_X86_64 not ARCH_IA64

3 years agolist aarch64 as a valid arch
jsg [Tue, 1 Jun 2021 02:13:15 +0000 (02:13 +0000)]
list aarch64 as a valid arch

from Leon Fischer

3 years agosync
deraadt [Tue, 1 Jun 2021 01:43:59 +0000 (01:43 +0000)]
sync

3 years agoChange the behavior of the UVIDEO_FLAG_REATTACH flag to attach an
mglocker [Mon, 31 May 2021 21:06:48 +0000 (21:06 +0000)]
Change the behavior of the UVIDEO_FLAG_REATTACH flag to attach an
unsupported device to uvideo(4), but not to video(1), instead of just
keeping it unmatched.  Also uvideo(4) will print a message about the
device not being supported.

ok mpi@

3 years agoauth_call(3) no longer uses secure_path(3)
millert [Mon, 31 May 2021 19:54:04 +0000 (19:54 +0000)]
auth_call(3) no longer uses secure_path(3)
This updates the manual to match the change made in 2019.
OK deraadt@

3 years agoadd an -R flag to dump the raw report descriptor bytes for parsing
jcs [Mon, 31 May 2021 18:30:11 +0000 (18:30 +0000)]
add an -R flag to dump the raw report descriptor bytes for parsing
with other tools

man page help from jmc
ok anton

3 years agoRevert previous. bluhm noted that it causes a regress failure.
tb [Mon, 31 May 2021 17:39:24 +0000 (17:39 +0000)]
Revert previous. bluhm noted that it causes a regress failure.

3 years agoDon't fail hard in ikev2_cp_fixaddr() if no address pool is found.
tobhe [Mon, 31 May 2021 17:10:14 +0000 (17:10 +0000)]
Don't fail hard in ikev2_cp_fixaddr() if no address pool is found.
Fixes a bug where no flows are loaded when a single config address without
pool is configured.

ok patrick@