openbsd
3 years agoAlways call endservent_r() after getservbyport_r().
eric [Mon, 21 Dec 2020 09:40:35 +0000 (09:40 +0000)]
Always call endservent_r() after getservbyport_r().
Fix a memory leak when no entry is matched.

ok florian

3 years agoproperly fix ProxyJump parsing; Thanks to tb@ for pointing out my error
djm [Mon, 21 Dec 2020 09:19:53 +0000 (09:19 +0000)]
properly fix ProxyJump parsing; Thanks to tb@ for pointing out my error
(parse_ssh_uri() can return -1/0/1, that I missed). Reported by Raf
Czlonka via bugs@

ok tb@

3 years agoShow scope id when set; ok florian@
otto [Mon, 21 Dec 2020 07:47:37 +0000 (07:47 +0000)]
Show scope id when set; ok florian@

3 years agoadapt to API change in hostkeys_foreach()/load_hostkeys()
djm [Mon, 21 Dec 2020 01:31:06 +0000 (01:31 +0000)]
adapt to API change in hostkeys_foreach()/load_hostkeys()

3 years agoTest that IPv4 path MTU discovery works over IPsec in tunnel mode.
bluhm [Mon, 21 Dec 2020 00:47:18 +0000 (00:47 +0000)]
Test that IPv4 path MTU discovery works over IPsec in tunnel mode.

3 years agoplumb ssh_conn_info through to sshconnect.c; feedback/ok markus@
djm [Sun, 20 Dec 2020 23:40:19 +0000 (23:40 +0000)]
plumb ssh_conn_info through to sshconnect.c; feedback/ok markus@

3 years agoallow UserKnownHostsFile=none; feedback and ok markus@
djm [Sun, 20 Dec 2020 23:38:00 +0000 (23:38 +0000)]
allow UserKnownHostsFile=none; feedback and ok markus@

3 years agoload_hostkeys()/hostkeys_foreach() variants for FILE*
djm [Sun, 20 Dec 2020 23:36:51 +0000 (23:36 +0000)]
load_hostkeys()/hostkeys_foreach() variants for FILE*

Add load_hostkeys_file() and hostkeys_foreach_file() that accept a
FILE* argument instead of opening the file directly.

Original load_hostkeys() and hostkeys_foreach() are implemented using
these new interfaces.

Add a u_int note field to the hostkey_entry and hostkey_foreach_line
structs that is passed directly from the load_hostkeys() and
hostkeys_foreach() call. This is a lightweight way to annotate results
between different invocations of load_hostkeys().

ok markus@

3 years agoUse regress framework for setup and shorten target names.
bluhm [Sun, 20 Dec 2020 22:45:22 +0000 (22:45 +0000)]
Use regress framework for setup and shorten target names.

3 years agoslightly tweak the jot regress tests to avoid file name clashes on
tb [Sun, 20 Dec 2020 21:59:37 +0000 (21:59 +0000)]
slightly tweak the jot regress tests to avoid file name clashes on
case insensitive file systems.

3 years agoAccept reject and blackhole routes for IPsec PMTU discovery.
bluhm [Sun, 20 Dec 2020 21:15:47 +0000 (21:15 +0000)]
Accept reject and blackhole routes for IPsec PMTU discovery.

Since revision 1.87 of ip_icmp.c icmp_mtudisc_clone() ignored reject
routes.  Otherwise TCP would clone these routes for PMTU discovery.
They will not work, even after dynamic routing has found a better
route than the reject route.

With IPsec the use case is different.  First you need a route, but
then the flow handles the packet without routing.  Usually this
route should be a reject route to avoid sending unencrypted traffic
if the flow is missing.  But IPsec needs this route for PMTU
discovery, so use it for that.

OK claudio@ tobhe@

3 years agoFix typo.
kettenis [Sun, 20 Dec 2020 21:03:53 +0000 (21:03 +0000)]
Fix typo.

3 years agoDon't leak ipsec_hosts when building hosts_list.
tobhe [Sun, 20 Dec 2020 17:44:50 +0000 (17:44 +0000)]
Don't leak ipsec_hosts when building hosts_list.

ok patrick@

3 years agorename pkg_add's pod files to avoid filenames with colons
daniel [Sun, 20 Dec 2020 15:30:58 +0000 (15:30 +0000)]
rename pkg_add's pod files to avoid filenames with colons

Filenames with colons are not allowed on windows filesystems. So we rename
the pod files to avoid this. Should get us closer to being able to check
out the openbsd source code on a windows system.

ok espie@ (who suggested the current approach); sthen@ was ok with a
previous version of the diff

3 years agoOnlly call event_del if there are events enabled, since not all libevents
martijn [Sun, 20 Dec 2020 14:06:12 +0000 (14:06 +0000)]
Onlly call event_del if there are events enabled, since not all libevents
are created equal.

From gilles@

3 years agoFree filter_name in lka_filter_end
martijn [Sun, 20 Dec 2020 13:27:46 +0000 (13:27 +0000)]
Free filter_name in lka_filter_end

From gilles@
OK millert@ eric@

3 years agoThe TCE table needs to be aligned on a boundary that is a multiple of its
kettenis [Sun, 20 Dec 2020 13:02:10 +0000 (13:02 +0000)]
The TCE table needs to be aligned on a boundary that is a multiple of its
size.  Fixes booting on machines that have memory banks higher up in
physical address space which needs a larger TCE table.

3 years agoIntroduce klistops
visa [Sun, 20 Dec 2020 12:54:05 +0000 (12:54 +0000)]
Introduce klistops

This patch extends struct klist with a callback descriptor and
an argument. The main purpose of this is to let the kqueue subsystem
assert when a klist should be locked, and operate the klist lock
in klist_invalidate().

Access to a knote list of a kqueue-monitored object has to be
serialized somehow. Because the object often has a lock for protecting
its state, and because the object often acquires this lock at the latest
in its f_event callback function, it makes sense to use this lock also
for the knote lists. The existing uses of NOTE_SUBMIT already show
a pattern that is likely to become more prevalent.

There could be an embedded lock in klist. However, such a lock would be
redundant in many cases. The code cannot rely on a single lock type
(mutex, rwlock, something else) because the needs of monitored objects
vary. In addition, an embedded lock would introduce new lock order
constraints. Note that the patch does not rule out use of dedicated
klist locks.

The patch introduces a way to associate lock operations with a klist.
The caller can provide a custom implementation, or use a ready-made
interface with a mutex or rwlock.

For compatibility with old code, the new code falls back to using the
kernel lock if no specific klist initialization has been done. The
existing code already relies on implicit initialization of klist.

Sadly, this change increases the size of struct klist. dlg@ thinks this
is not fatal, though.

OK mpi@

3 years agoFix EDNS Client Subnet option (+subnet=)
florian [Sun, 20 Dec 2020 12:02:00 +0000 (12:02 +0000)]
Fix EDNS Client Subnet option (+subnet=)

This got broken when we introduced ecs_plen so that we can use
natural socket types.

3 years agoFix IPv6 link-local address handling for nameservers to talk to as
florian [Sun, 20 Dec 2020 11:27:47 +0000 (11:27 +0000)]
Fix IPv6 link-local address handling for nameservers to talk to as
well as address to bind to.
Reported by Jordan Geoghegan (jordan AT geoghegan.ca), thanks!
Debugged by & initial fix by otto
Input & OK otto

3 years agoFix copy-pasto when selecting the addresses read from resolv.conf by
otto [Sun, 20 Dec 2020 10:29:50 +0000 (10:29 +0000)]
Fix copy-pasto when selecting the addresses read from resolv.conf by
address family.  ok florian@

3 years agoConvert uvm_km_valloc(9) calls to km_alloc(9). Tested in qemu with
jmatthew [Sun, 20 Dec 2020 09:49:53 +0000 (09:49 +0000)]
Convert uvm_km_valloc(9) calls to km_alloc(9).  Tested in qemu with
acpi disabled, no real mpbios hardware in sight.

ok kettenis@

3 years agosync with i915_pciids.h
jsg [Sun, 20 Dec 2020 04:13:12 +0000 (04:13 +0000)]
sync with i915_pciids.h

3 years agodrm/i915: Remove dubious Valleyview PCI IDs
jsg [Sun, 20 Dec 2020 04:12:14 +0000 (04:12 +0000)]
drm/i915: Remove dubious Valleyview PCI IDs

From Alexei Podtelezhnikov
f2bde2546b81b64fb58aa04888fdd82a090b3908 in mainline linux

3 years agoremove duplicate device id caused by subids in INTEL_IVB_Q_IDS
jsg [Sun, 20 Dec 2020 03:58:42 +0000 (03:58 +0000)]
remove duplicate device id caused by subids in INTEL_IVB_Q_IDS

3 years agotest against [VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS] in access_ok()
jsg [Sun, 20 Dec 2020 03:42:01 +0000 (03:42 +0000)]
test against [VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS] in access_ok()

ok kettenis@

3 years agoPrint client kem key with correct length.
tobhe [Sat, 19 Dec 2020 22:09:21 +0000 (22:09 +0000)]
Print client kem key with correct length.

ok markus@

3 years agoremove extra s
tb [Sat, 19 Dec 2020 18:05:44 +0000 (18:05 +0000)]
remove extra s

3 years agoApply r1.86 of amd64 acpi_machdep.c to arm64 and i386, converting a few
jmatthew [Sat, 19 Dec 2020 06:28:42 +0000 (06:28 +0000)]
Apply r1.86 of amd64 acpi_machdep.c to arm64 and i386, converting a few
uvm_km_valloc(9) to km_alloc(9).

tested on arm64 by bluhm@, i386 by me
ok kettenis@

3 years agorename filenames ending in a period
daniel [Sat, 19 Dec 2020 02:57:03 +0000 (02:57 +0000)]
rename filenames ending in a period

While windows may technically allow filenames to end in a period, the
recommendation is to avoid this as the shell does not support such files.
As of git 2.25, the behaviour was apparently changed to not allow files
with names ending in a period to be checked out on windows.

A second problem is upper/lower case conflicts for filenames.

To allow the source tree to be checked out on windows we follow FreeBSD
and rename a few files:

ss.. -> ss_
ssA  -> ss10
ssB  -> ss11

(FreeBSD svn revision 210167 from 2010)

as usual, this issue was extensively researched by jsg@

3 years agoThere's no need to include the OFW GPIO header.
patrick [Sat, 19 Dec 2020 01:21:35 +0000 (01:21 +0000)]
There's no need to include the OFW GPIO header.

3 years agoAdd support for the i.MX8MP PCIe clocks.
patrick [Sat, 19 Dec 2020 01:18:11 +0000 (01:18 +0000)]
Add support for the i.MX8MP PCIe clocks.

3 years agoAdd support for the i.MX8MP second ethernet. The Plus SoC not only has the
patrick [Fri, 18 Dec 2020 22:18:56 +0000 (22:18 +0000)]
Add support for the i.MX8MP second ethernet.  The Plus SoC not only has the
usual fec(4), but also a variant of dwge(4).  Unfortunately it seems to be
a newer version, which isn't compatible to the one currently in our tree.

3 years agoEmulate open drain GPIOs. This replaces the hack added in the last commit.
kettenis [Fri, 18 Dec 2020 22:15:29 +0000 (22:15 +0000)]
Emulate open drain GPIOs.  This replaces the hack added in the last commit.

ok patrick@

3 years agoAdd symbolic constants related to open source and open drain GPIOs.
kettenis [Fri, 18 Dec 2020 22:14:13 +0000 (22:14 +0000)]
Add symbolic constants related to open source and open drain GPIOs.

ok patrick@

3 years agoMake large read and write transactions work.
kettenis [Fri, 18 Dec 2020 22:13:06 +0000 (22:13 +0000)]
Make large read and write transactions work.

3 years agoUpdate awk to December 18, 2020 version.
millert [Fri, 18 Dec 2020 21:36:24 +0000 (21:36 +0000)]
Update awk to December 18, 2020 version.
Includes the official fix for +-inf and +-nan handling.

3 years agoAdd glue for the USB3 controller on the i.MX8MP SoC. NXP had this glue for
patrick [Fri, 18 Dec 2020 18:24:44 +0000 (18:24 +0000)]
Add glue for the USB3 controller on the i.MX8MP SoC.  NXP had this glue for
the i.MX8MQ as well, but while upstreaming they were told to shove it.  Now
for the i.MX8MP this glue is making a comeback.  Apparently there's some
divergence in low power handling to the regular DWC3 IP with special IRQs.
Now the question remains if this driver will be obsolete soon again, or if
this time it's here to stay.  The fun part is that while this driver was
written independent from the previous version, the diff is basically zero.

ok kettenis@

3 years agoAdd code to initialize the USB 3 PHY on i.MX8MP.
patrick [Fri, 18 Dec 2020 18:13:17 +0000 (18:13 +0000)]
Add code to initialize the USB 3 PHY on i.MX8MP.

ok kettenis@

3 years agoUse regress framework.
bluhm [Fri, 18 Dec 2020 18:05:29 +0000 (18:05 +0000)]
Use regress framework.

3 years agoIn io_str_read() return 0-length strings as NULL pointers instead of
claudio [Fri, 18 Dec 2020 16:58:59 +0000 (16:58 +0000)]
In io_str_read() return 0-length strings as NULL pointers instead of
empty strings. There are no empty strings being passed around but a
fair amount of optional strings and this will simplify this code.
OK tb@

3 years agoAdd support for the i.MX8MP USB clocks.
patrick [Fri, 18 Dec 2020 16:29:57 +0000 (16:29 +0000)]
Add support for the i.MX8MP USB clocks.

3 years agoAttach imxgpc(4) to i.MX8MP as well.
patrick [Fri, 18 Dec 2020 16:26:21 +0000 (16:26 +0000)]
Attach imxgpc(4) to i.MX8MP as well.

3 years agoAdd fd close notification for kqueue-based poll() and select()
visa [Fri, 18 Dec 2020 16:16:14 +0000 (16:16 +0000)]
Add fd close notification for kqueue-based poll() and select()

When the file descriptor of an __EV_POLL-flagged knote is closed,
post EBADF through the kqueue instance to the caller of kqueue_scan().
This lets kqueue-based poll() and select() preserve their current
behaviour of returning EBADF when a polled file descriptor is closed
concurrently.

OK mpi@

3 years agoMake knote_{activate,remove}() internal to kern_event.c.
visa [Fri, 18 Dec 2020 16:10:57 +0000 (16:10 +0000)]
Make knote_{activate,remove}() internal to kern_event.c.

OK mpi@

3 years agoAdd details to -F flag
solene [Fri, 18 Dec 2020 15:03:40 +0000 (15:03 +0000)]
Add details to -F flag

If you add alternatives domain names to
acme-client.conf, using -F is required to
renew the certificate with the new names.

ok jmc@

3 years agoUse asprintf with %.*s to construct the path based on the mft file
claudio [Fri, 18 Dec 2020 12:31:06 +0000 (12:31 +0000)]
Use asprintf with %.*s to construct the path based on the mft file
location and the filename of the referenced file. Use the same method
both in main.c and mft.c which is a fair bit simpler than using calloc
and strlcpy/strlcat to build the string by hand.
OK tb@

3 years agoMake sure the first packet of an SA has sequence number 1 (as described in
tobhe [Fri, 18 Dec 2020 12:30:23 +0000 (12:30 +0000)]
Make sure the first packet of an SA has sequence number 1 (as described in
RFC 4302 and RFC 4303).  It seems this was changed by accident when support
for 64 bit sequence numbers was added.

ok bluhm@ patrick@

3 years agotht(4): more tsleep(9) -> tsleep_nsec(9)
cheloha [Thu, 17 Dec 2020 23:36:47 +0000 (23:36 +0000)]
tht(4): more tsleep(9) -> tsleep_nsec(9)

The first wait-loop in tht_fw_load() can sleep for at least 10ms per
iteration instead of up to 1 tick per iteration with no ill effects.
The worst-case scenario is that we sleep a little longer than we do
now while we wait.

The second wait-loop can be simplified to sleep for at least 10ms per
iteration for up to 2000ms instead of using a timeout.  This method is
less precise and less efficient but is far simpler to read and
understand than using a timeout.  We can then remove all the
timeout-related stuff from if_tht.c.

Discussed with mpi@.

ok dlg@

3 years agofix possible error("%s", NULL) on error paths
djm [Thu, 17 Dec 2020 23:28:50 +0000 (23:28 +0000)]
fix possible error("%s", NULL) on error paths

3 years agorefactor client percent_expand() argument passing; consolidate the
djm [Thu, 17 Dec 2020 23:26:11 +0000 (23:26 +0000)]
refactor client percent_expand() argument passing; consolidate the
common arguments into a single struct and pass that around instead
of using a bunch of globals. ok markus@

3 years agoprepare readconf.c for fuzzing; remove fatal calls and fix some
djm [Thu, 17 Dec 2020 23:10:27 +0000 (23:10 +0000)]
prepare readconf.c for fuzzing; remove fatal calls and fix some
(one-off) memory leaks; ok markus@

3 years agoOnly enable the USB 3.0 port and PHY if it is enabled on a board.
kettenis [Thu, 17 Dec 2020 22:39:45 +0000 (22:39 +0000)]
Only enable the USB 3.0 port and PHY if it is enabled on a board.

3 years agoReset pin 3 of the GPIOAO bank to input mode to work around a hardware
kettenis [Thu, 17 Dec 2020 21:52:09 +0000 (21:52 +0000)]
Reset pin 3 of the GPIOAO bank to input mode to work around a hardware
bug in the Odroid C4/HC4 boards.

3 years agoReformating the test logging affected the expected output.
bluhm [Thu, 17 Dec 2020 20:58:17 +0000 (20:58 +0000)]
Reformating the test logging affected the expected output.

3 years agoUse strtonum() instead of atoi() to parse port option.
tobhe [Thu, 17 Dec 2020 20:43:07 +0000 (20:43 +0000)]
Use strtonum() instead of atoi() to parse port option.

3 years agoSort command line options.
tobhe [Thu, 17 Dec 2020 20:32:21 +0000 (20:32 +0000)]
Sort command line options.

ok bluhm@

3 years agoFix some breakage in handling +-inf and +-nan introduced in last version.
millert [Thu, 17 Dec 2020 20:06:09 +0000 (20:06 +0000)]
Fix some breakage in handling +-inf and +-nan introduced in last version.

3 years agoMatch on "amlogic,meson-g12a-dwmac" which is used by newer Linux mainline
kettenis [Thu, 17 Dec 2020 19:50:06 +0000 (19:50 +0000)]
Match on "amlogic,meson-g12a-dwmac" which is used by newer Linux mainline
device trees.

3 years agoAdd support for the "Always On" GPIOs.
kettenis [Thu, 17 Dec 2020 19:43:32 +0000 (19:43 +0000)]
Add support for the "Always On" GPIOs.

3 years agoFix some issues with referencing named ACPI nodes from Packages.
kettenis [Thu, 17 Dec 2020 17:57:19 +0000 (17:57 +0000)]
Fix some issues with referencing named ACPI nodes from Packages.
These references need to be resolved at runtime rather than when
they're parsed such that they pick up the right values for those nodes
which can be changed when for example _INI methods run.

The current approach is to replace these reference with a string that
names the node in question.  The problem with that is that packages
can also contain normal strings.  Which means that we need special
code that depends on the context where the package is used.

This diff takes a different approach by retaining a reference when
parsing.  Code that uses a package will need to resolve this reference
but there is no ambiguiety anymore.

ok patrick@

3 years agobwfm: add a delay in bwfm_set_key_cb before talking to hardware
jcs [Thu, 17 Dec 2020 15:37:09 +0000 (15:37 +0000)]
bwfm: add a delay in bwfm_set_key_cb before talking to hardware

This works around an issue on the BCM43602 where ieee80211 calls
this too quickly during authentication and triggers "unexpected
pairwise key update" errors.

ok patrick

3 years agoRun setup_once targets in a sepearate block with headline before
bluhm [Thu, 17 Dec 2020 14:54:15 +0000 (14:54 +0000)]
Run setup_once targets in a sepearate block with headline before
all other targets.
OK tb@

3 years agoFix regress target name, they must be unique.
bluhm [Thu, 17 Dec 2020 14:22:42 +0000 (14:22 +0000)]
Fix regress target name, they must be unique.

3 years agoLink broadcast_bind, carp, in_pcbbind, sendsrcaddr regress to build.
bluhm [Thu, 17 Dec 2020 14:16:10 +0000 (14:16 +0000)]
Link broadcast_bind, carp, in_pcbbind, sendsrcaddr regress to build.

3 years agoUse ${SUDO} or skip test if not root.
bluhm [Thu, 17 Dec 2020 14:06:42 +0000 (14:06 +0000)]
Use ${SUDO} or skip test if not root.

3 years agoFix a race where the ${SUDO} process was killed instead of tcpdump.
bluhm [Thu, 17 Dec 2020 13:07:18 +0000 (13:07 +0000)]
Fix a race where the ${SUDO} process was killed instead of tcpdump.

3 years agoLink pflow and wg regress to build.
bluhm [Thu, 17 Dec 2020 12:44:21 +0000 (12:44 +0000)]
Link pflow and wg regress to build.

3 years agorework the maths used to set mbuf timestamps.
dlg [Thu, 17 Dec 2020 04:15:03 +0000 (04:15 +0000)]
rework the maths used to set mbuf timestamps.

there's a comment that explains how it works now, but the result is
that i get much tighter and more consistent synchronisation between
the kernel clock and the values derived from the mcx timestamps
now.

however, i only just worked out that there is still an unresolved
problem where the kernel clock changes how fast it ticks. this
happens when ntpd uses adjtime(2) or adjfreq(2) to try and make the
kernel tick at the same rate as the rest of the universe (well, the
small bit of it that it can observe). these adjustments to the
kernel clock immediately skew the timestamps that mcx calculates,
but then it also throws off the mcx calibration calculations that
run every 30 seconds. the offsets calculated in the next calibration
period are often (very) negative.

eg, when things are synced up nicely and you do a read of the mcx
timer and immediately follow it with a nanouptime(9) call, on this
box it calculates that the time in between those two events is about
2600ns. in the calibration period after ntpd did a very small adjtime
call, it now thinks the time between those two events is -700000ns.

this is a pretty obvious problem in hindsight. i can't think of a
simple solution to it at the moment though so i'm going to leave
mcx timestamping disabled for now.

3 years agoLog reason a request is NAK'ed, as well as any problems sending the
krw [Thu, 17 Dec 2020 02:06:23 +0000 (02:06 +0000)]
Log reason a request is NAK'ed, as well as any problems sending the
NAK.

Suggestion & ok dlg@

3 years agoRemove echo headlines.
bluhm [Thu, 17 Dec 2020 00:51:11 +0000 (00:51 +0000)]
Remove echo headlines.

3 years agoUse setup and cleanup feature from regress framework.
bluhm [Thu, 17 Dec 2020 00:39:42 +0000 (00:39 +0000)]
Use setup and cleanup feature from regress framework.
Remove echo headlines.  Use consistent target names.
Makefile cleanup.

3 years agoRemove echo headlines. Makefile cleanup.
bluhm [Wed, 16 Dec 2020 23:10:48 +0000 (23:10 +0000)]
Remove echo headlines.  Makefile cleanup.

3 years agoRemove echo headlines. Use consistent target names.
bluhm [Wed, 16 Dec 2020 22:59:54 +0000 (22:59 +0000)]
Remove echo headlines.  Use consistent target names.

3 years agoUse setup and cleanup feature from regress framework.
bluhm [Wed, 16 Dec 2020 21:49:20 +0000 (21:49 +0000)]
Use setup and cleanup feature from regress framework.
Remove echo headlines.  Use consistent target names.

3 years agoDo not clear useful bits in panic messages, always print full opte
bluhm [Wed, 16 Dec 2020 21:11:35 +0000 (21:11 +0000)]
Do not clear useful bits in panic messages, always print full opte
variable.  Make PG_PVLIST panics consistent and print more values.
OK mpi@

3 years agoClean directory recursively only where necessary.
bluhm [Wed, 16 Dec 2020 20:37:16 +0000 (20:37 +0000)]
Clean directory recursively only where necessary.

3 years agoUse ESP sequence number as IV for AES-CTR, AES-GCM and Chacha20.
tobhe [Wed, 16 Dec 2020 19:28:59 +0000 (19:28 +0000)]
Use ESP sequence number as IV for AES-CTR, AES-GCM and Chacha20.
This eliminates the risk for IV reuse because of random collisions
and increases performance a little.

ok patrick@ markus@

3 years agoRemove a redundant memset call.
tb [Wed, 16 Dec 2020 18:53:10 +0000 (18:53 +0000)]
Remove a redundant memset call.

3 years agoRemove two reduntat memset calls.
tb [Wed, 16 Dec 2020 18:46:29 +0000 (18:46 +0000)]
Remove two reduntat memset calls.

pointed out by jsing

3 years agoUse consistent target names. Makefile cleanup.
bluhm [Wed, 16 Dec 2020 18:44:55 +0000 (18:44 +0000)]
Use consistent target names.  Makefile cleanup.

3 years agoMake test actually fail if something is broken.
bluhm [Wed, 16 Dec 2020 18:40:10 +0000 (18:40 +0000)]
Make test actually fail if something is broken.
Remove echo headlines.  Use consistent target names.

3 years agoAvoid potential use of uninitialized in ASN1_time_parse
tb [Wed, 16 Dec 2020 18:35:59 +0000 (18:35 +0000)]
Avoid potential use of uninitialized in ASN1_time_parse

When parsing an UTCTime into a struct tm that wasn't cleared by the caller,
the years would be added to the already present value, which could give an
incorrect result.  This is an issue in ASN1_UTCTIME_cmp_time_t(), which is
practically unused.  Fix this by always zeroing the passed struct tm.

Issue reported by Olivier Taïbi, thanks!

ok jsing

3 years agosoftraid(4): more tsleep(9) -> tsleep_nsec(9) conversions
cheloha [Wed, 16 Dec 2020 18:16:34 +0000 (18:16 +0000)]
softraid(4): more tsleep(9) -> tsleep_nsec(9) conversions

These wait loops block for up to 1 tick per iteration.  I think they
will continue to work if we block for at least 1ms per iteration.

My gut says that these could be rewritten not to spin and instead to
await a wakeup(9) from the other thread, but I think that would
involve making softraid(4) more MP-safe.

3 years agoFail to parse rules with invalid ranges
kn [Wed, 16 Dec 2020 18:01:16 +0000 (18:01 +0000)]
Fail to parse rules with invalid ranges

This makes pfctl(8) detect bogus ranges (with and without `-n') before
loading the ruleset and completes the previous commit.

OK sashan sthen

3 years agoReject rules with invalid port ranges
kn [Wed, 16 Dec 2020 18:00:44 +0000 (18:00 +0000)]
Reject rules with invalid port ranges

Ranges where the left boundary is bigger than the right one are always bogus
as they work like `port any' (`port 34<>12' means "all ports") or in way
that inverts the rule's action (`pass ... port 34:12' means "pass no port at
all").

Add checks for all ranges and invalidate those that yield no or all ports.

For this to work on redirections, make pfctl(8) pass the range's type,
otherwise boundary including ranges are not detected as such;  that is to
say, `struct pf_pool's `port_op' member was unused in the kernel so far.

`rdr-to' rules with invalid ranges could panic the kernel when hit.
Reported-by: syzbot+9c309db201f06e39a8ba@syzkaller.appspotmail.com
OK sashan

3 years agoWhen debugging tests, it is useful to see the target name and which
bluhm [Wed, 16 Dec 2020 16:53:24 +0000 (16:53 +0000)]
When debugging tests, it is useful to see the target name and which
output belongs to it.  Echo headline with regress target and empty
line afterwards.
OK sthen@ tb@ OK claudio@

3 years agoRemove kqueue_free() and use KQRELE() in kqpoll_exit().
visa [Wed, 16 Dec 2020 15:07:30 +0000 (15:07 +0000)]
Remove kqueue_free() and use KQRELE() in kqpoll_exit().

Because kqpoll instances are now linked to the file descriptor table,
the freeing of kqpoll and ordinary kqueues is similar.

Suggested by mpi@

3 years agoLink kqpoll instances to fd_kqlist.
visa [Wed, 16 Dec 2020 15:06:11 +0000 (15:06 +0000)]
Link kqpoll instances to fd_kqlist.

This lets the system remove kqpoll-related event registrations when
a file descriptor is closed.

OK mpi@

3 years agoFix some KNF issues
tb [Wed, 16 Dec 2020 13:44:17 +0000 (13:44 +0000)]
Fix some KNF issues

3 years agoUse km_alloc(9)/km_free(9) instead of uvm_km_valloc(9)/uvm_km_free(9).
kettenis [Tue, 15 Dec 2020 22:51:34 +0000 (22:51 +0000)]
Use km_alloc(9)/km_free(9) instead of uvm_km_valloc(9)/uvm_km_free(9).
These are the preferred interfaces and using them avoids tripping over
a kernel lock assertion during early boot.

Tested by bluhm@, sthen@ and Hrvoje Popovski.
ok mpi@

3 years agoRemove the assertion in uvm_km_pgremove().
mpi [Tue, 15 Dec 2020 22:14:42 +0000 (22:14 +0000)]
Remove the assertion in uvm_km_pgremove().

At least some initialization code on i386 calls it w/o KERNEL_LOCK().

Found the hardway by jungle Boogie and Hrvoje Popovski.

3 years agoFix leak of REQUEST string.
tobhe [Tue, 15 Dec 2020 21:47:10 +0000 (21:47 +0000)]
Fix leak of REQUEST string.

3 years agoUse natural sizes for S3I(s)->tmp's *_md arrays
tb [Tue, 15 Dec 2020 16:04:49 +0000 (16:04 +0000)]
Use natural sizes for S3I(s)->tmp's *_md arrays

It is a historical artifact that cert_verify_md[], finish_md[] and
peer_finish_md[] are twice as large as they need to be. This is
confusing, especially for finish_md[] and peer_finish_md[] which are
copied to to previous_client_finished[] and previous_server_finished[]
which are only half as large. It is easy to check that they will never
get more than EVP_MAX_MD_SIZE data written to them.

In 1998, EVP_MAX_MD_SIZE was 20 bytes long (for SHA-1). This got bumped to
16+20 for the SSLv3-specific md5+sha1.  Apparently under the impression
that EVP_MAX_MD_SIZE was still 20 bytes, someone else doubled finish_md[]'s
size to EVP_MAX_MD_SIZE*2 and added /* actually only needs to be 16+20 */.
A bit later finish_md[] was split up, and still a bit later the comment was
amended for TLSv1.  Shortly thereafter SHA-512 required a bump of
EVP_MAX_MD_SIZE to 64 by a third person and we have been carrying 192 bytes
of untouched memory in each of our SSLs ever since.

ok inoguchi jsing (jsing had the same diff)

3 years agomissing NET_LOCK()/NET_UNLOCK() in pf_osfp_flush()
sashan [Tue, 15 Dec 2020 15:23:48 +0000 (15:23 +0000)]
missing NET_LOCK()/NET_UNLOCK() in pf_osfp_flush()

OK mpi@

3 years agoAvoid NULL dereference after returning from copy().
zhuk [Tue, 15 Dec 2020 14:06:32 +0000 (14:06 +0000)]
Avoid NULL dereference after returning from copy().

okay martijn@

3 years agotypo fix from aisha tammy; ok nicm
jmc [Tue, 15 Dec 2020 13:40:22 +0000 (13:40 +0000)]
typo fix from aisha tammy; ok nicm

3 years agoAdd helpers around rw_status(9) to help checking if a lock is held.
mpi [Tue, 15 Dec 2020 10:23:01 +0000 (10:23 +0000)]
Add helpers around rw_status(9) to help checking if a lock is held.

ok visa@

3 years agoFix return value variable type in tls_keypair_load_cert
inoguchi [Tue, 15 Dec 2020 08:47:45 +0000 (08:47 +0000)]
Fix return value variable type in tls_keypair_load_cert

ERR_peek_error() returns unsigned long.
Reported by github issue by @rozhuk-im.

ok bcook@ jsing@

3 years agoMake synchronize-panes a pane option and add -U flag to set-option to
nicm [Tue, 15 Dec 2020 08:31:50 +0000 (08:31 +0000)]
Make synchronize-panes a pane option and add -U flag to set-option to
unset an option on all panes. GitHub issue 2491 from Rostislav Nesin.