]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agovfs: change vn_freevnodes_* prefix to idiomatic vfs_freevnodes_*
Mateusz Guzik [Fri, 14 May 2021 19:01:56 +0000 (21:01 +0200)]
vfs: change vn_freevnodes_* prefix to idiomatic vfs_freevnodes_*

(cherry picked from commit 715fcc0d342684da5d109a7e4891d30aa38667c9)

3 years agovfs: add missing atomic conversion to writecount adjustment
Mateusz Guzik [Fri, 14 May 2021 15:41:39 +0000 (17:41 +0200)]
vfs: add missing atomic conversion to writecount adjustment

Fixes: ("vfs: lockless writecount adjustment in set/unset text")
(cherry picked from commit 852088f6af6c5cd44542dde72aa5c3f4c4f9353c)

3 years agovfs: add more safety against concurrent forced unmount to vn_write
Mateusz Guzik [Fri, 14 May 2021 11:26:56 +0000 (13:26 +0200)]
vfs: add more safety against concurrent forced unmount to vn_write

1. stop re-reading ->v_mount (can become NULL)
2. stop re-reading ->v_type (can change to VBAD)

(cherry picked from commit ca1ce50b2b5ef11d85841f3aead98b2a9ad18819)

3 years agovfs: lockless writecount adjustment in set/unset text
Mateusz Guzik [Fri, 7 May 2021 14:04:27 +0000 (16:04 +0200)]
vfs: lockless writecount adjustment in set/unset text

... for cases where this is not the first/last exec.

(cherry picked from commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa)

3 years agocache: remove incomplete lockless lockout support during resize
Mateusz Guzik [Sat, 10 Apr 2021 17:20:28 +0000 (19:20 +0200)]
cache: remove incomplete lockless lockout support during resize

This is already properly handled thanks to 2 step hash replacement.

(cherry picked from commit 074abaccfaadef0da6e2695225ce537cb53bb8de)

3 years agocache: extend mismatch vnode assert print to include the name
Mateusz Guzik [Thu, 15 Apr 2021 07:55:43 +0000 (07:55 +0000)]
cache: extend mismatch vnode assert print to include the name

(cherry picked from commit 4f0279e064bb163dbcc4859e409fc65dcbe8f1bf)

3 years agotmpfs: dynamically register tmpfs pager
Konstantin Belousov [Fri, 7 May 2021 19:42:06 +0000 (22:42 +0300)]
tmpfs: dynamically register tmpfs pager

(cherry picked from commit 28bc23ab92ce7393aab48da7d71ccde63592ff2d)

3 years agovm: Add KPI to dynamically register pagers
Konstantin Belousov [Fri, 7 May 2021 19:06:16 +0000 (22:06 +0300)]
vm: Add KPI to dynamically register pagers

(cherry picked from commit b730fd30b78f502ed5dd08e5285cb2c951495d65)

3 years agosys/vm: remove several other uses of OBJT_SWAP_TMPFS
Konstantin Belousov [Fri, 7 May 2021 18:21:22 +0000 (21:21 +0300)]
sys/vm: remove several other uses of OBJT_SWAP_TMPFS

(cherry picked from commit 7079449b0b56d13b4ae7b4039ac8eb7c45c03fb5)

3 years agovm_object_set_memattr(): handle all object types without listing them explicitly
Konstantin Belousov [Fri, 7 May 2021 18:19:30 +0000 (21:19 +0300)]
vm_object_set_memattr(): handle all object types without listing them explicitly

(cherry picked from commit 3e7a11ca21f3a7948c50f27de5b2159f0bb56672)

3 years agoprocfs_map: switch to use vm_object_kvme_type
Konstantin Belousov [Mon, 10 May 2021 15:20:42 +0000 (18:20 +0300)]
procfs_map: switch to use vm_object_kvme_type

(cherry picked from commit 8b99833ac2538a74d013d101e2b5ec2d9e29d198)

3 years agovm_object_kvme_type(): reimplement by embedding kvme_type into pagerops
Konstantin Belousov [Fri, 7 May 2021 17:46:51 +0000 (20:46 +0300)]
vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops

(cherry picked from commit 00a3fe968b840ee197c32dfe4107dab730bd9915)

3 years agoClose races in vm object chain traversal for unlock
Ryan Libby [Thu, 25 Feb 2021 20:11:19 +0000 (12:11 -0800)]
Close races in vm object chain traversal for unlock

(cherry picked from commit d7671ad8d6ebe205933628466dc0a52d32eea2e8)

3 years agoConstify vm_pager-related virtual tables.
Konstantin Belousov [Mon, 3 May 2021 21:58:07 +0000 (00:58 +0300)]
Constify vm_pager-related virtual tables.

(cherry picked from commit d474440ab33c683b0e3f55e8e854f055615db6ec)

3 years agoAdd OBJT_SWAP_TMPFS pager
Konstantin Belousov [Sat, 1 May 2021 01:18:00 +0000 (04:18 +0300)]
Add OBJT_SWAP_TMPFS pager

(cherry picked from commit 4b8365d752ef48c14f0584d21b719bb386a7be82)

3 years agopagertab: use designated initializers
Konstantin Belousov [Sat, 1 May 2021 17:20:36 +0000 (20:20 +0300)]
pagertab: use designated initializers

(cherry picked from commit 0d2dfc6fed03c36f7c4a9bb2a4223028f3b4431b)

3 years agoStyle enum obj_type
Konstantin Belousov [Sat, 1 May 2021 01:14:24 +0000 (04:14 +0300)]
Style enum obj_type

(cherry picked from commit 838adc533fa11b8c4e7da5603377fdd62c2f1d90)

3 years agoImplement vm_object_vnode() using vm_pager_getvp()
Konstantin Belousov [Sat, 1 May 2021 01:08:28 +0000 (04:08 +0300)]
Implement vm_object_vnode() using vm_pager_getvp()

(cherry picked from commit a7c198a24b12b9e6d83d7718d8d16a5cef48d35f)

3 years agoAdd pgo_freespace method
Konstantin Belousov [Sat, 1 May 2021 17:12:32 +0000 (20:12 +0300)]
Add pgo_freespace method

(cherry picked from commit 1390a5cbeb1828b11584783c53f50b9679379651)

3 years agoAdd pgo_getvp method
Konstantin Belousov [Sat, 1 May 2021 01:04:04 +0000 (04:04 +0300)]
Add pgo_getvp method

(cherry picked from commit 192112b74fed56ca652cf1d70c11ba7e17bc1ce2)

3 years agoAdd pgo_mightbedirty method
Konstantin Belousov [Sat, 1 May 2021 00:43:08 +0000 (03:43 +0300)]
Add pgo_mightbedirty method

(cherry picked from commit c23c555bc15ce1523b95fb8da99ae77c0bb0977e)

3 years agovm_pager: add pgo_set_writeable_dirty method
Konstantin Belousov [Sat, 1 May 2021 00:14:48 +0000 (03:14 +0300)]
vm_pager: add pgo_set_writeable_dirty method

(cherry picked from commit 180bcaa46c5d297d137749258b23593d578d76a5)

3 years agovm_pager: style some wrappers
Konstantin Belousov [Sat, 1 May 2021 00:28:39 +0000 (03:28 +0300)]
vm_pager: style some wrappers

(cherry picked from commit ee4211bca600af48aab95000f39b4797a74eeb85)

3 years agoswappagerops: slightly more style-compliant formatting
Konstantin Belousov [Fri, 30 Apr 2021 23:54:17 +0000 (02:54 +0300)]
swappagerops: slightly more style-compliant formatting

(cherry picked from commit a0850dd0570fcfbb5cf72cb0962a201d39db040e)

3 years agonfscl: Add support for va_birthtime to NFSv4
Rick Macklem [Sat, 8 May 2021 00:30:56 +0000 (17:30 -0700)]
nfscl: Add support for va_birthtime to NFSv4

There is a NFSv4 file attribute called TimeCreate
that can be used for va_birthtime.
r362175 added some support for use of TimeCreate.
This patch completes support of va_birthtime by adding
support for setting this attribute to the server.
It also eanbles the client to
acquire and set the attribute for a NFSv4
server that supports the attribute.

(cherry picked from commit dd02d9d605b6d8849e858d7644bb84b45c606b46)

3 years agofstyp(8): define HAVE_ZFS macro when built with zfs
Robert Wing [Wed, 12 May 2021 02:57:24 +0000 (18:57 -0800)]
fstyp(8): define HAVE_ZFS macro when built with zfs

The HAVE_ZFS macro was dropped from the Makefile during the OpenZFS
merge, bring it back.

While here, drop unused WARNS setting.

PR:             255616
Reported by:    Michael Büker <freebsd@michael-bueker.de>
Submitted by:   Michael Büker <freebsd@michael-bueker.de>
Fixes: 9e5787d2284e187abb5b654d924394a65772e004
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D30221

(cherry picked from commit 91f251b2ab3ade5de703756873142bfae2573753)

3 years agokqueue timer: Remove detached knotes from the process stop queue
Mark Johnston [Fri, 14 May 2021 14:07:56 +0000 (10:07 -0400)]
kqueue timer: Remove detached knotes from the process stop queue

There are some scenarios where a timer event may be detached when it is
on the process' kqueue timer stop queue.  If kqtimer_proc_continue() is
called after that point, it will iterate over the queue and access freed
timer structures.

It is also possible, at least in a multithreaded program, for a stopped
timer event to be scheduled without removing it from the process' stop
queue.  Ensure that we do not doubly enqueue the event structure in this
case.

Reported by: syzbot+cea0931bb4e34cd728bd@syzkaller.appspotmail.com
Reported by: syzbot+9e1a2f3734652015998c@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30251

(cherry picked from commit 2cca77ee01343bf080f1b70f0217a84c200fe7c1)

3 years agostorvsc: fix auto-sense reporting
Andriy Gapon [Fri, 7 May 2021 07:17:57 +0000 (10:17 +0300)]
storvsc: fix auto-sense reporting

I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb
even though SRB_STATUS_AUTOSENSE_VALID was not set in the status.
The actual sense data remained all zeros.
The problem seems to be that create_storvsc_request() always sets
hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0
is not enough to determine if any auto-sense data is actually available.

Sponsored by: CyberSecure

(cherry picked from commit 8afecefd57c5ac95200f43227cd00f265154acee)

3 years agompsutil: extend show adapter information, add NCQ control
Daniel Austin [Fri, 7 May 2021 11:41:53 +0000 (14:41 +0300)]
mpsutil: extend show adapter information, add NCQ control

'show adapter' now shows PCIe width and speed, IOC Speed, and the
temperature of the controller.

A new command, 'set ncq', is added.
It enables or disables SATA NCQ in the NVRAM of the card.
Its current setting is added to 'show adapter' as well.

PR: 254841
MFC after: 2 weeks
Relnotes: perhaps

(cherry picked from commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51)

3 years agoPCI hot-plug: use dedicated taskqueue for device attach / detach
Andriy Gapon [Thu, 6 May 2021 18:49:37 +0000 (21:49 +0300)]
PCI hot-plug: use dedicated taskqueue for device attach / detach

Attaching and detaching devices can be heavy-weight and detaching can
sleep waiting for events.  For that reason using the system-wide
single-threaded taskqueue_thread is not really appropriate.
There is even a possibility for a deadlock if taskqueue_thread is used
for detaching.

In fact, there is an easy to reproduce deadlock involving nvme, pass
and a sudden removal of an NVMe device.
A pass peripheral would not release a reference on an nvme sim until
pass_shutdown_kqueue() is executed via taskqueue_thread.  But the
taskqueue's thread is blocked in nvme_detach() -> ... -> cam_sim_free()
because of the outstanding reference.

Sponsored by: CyberSecure
Reviewed by: mav, imp

(cherry picked from commit 12588ce02dd835b332952d9fece5881d943554a9)

3 years agoMFC fixes to hostuuid handling
Colin Percival [Sat, 15 May 2021 05:57:38 +0000 (22:57 -0700)]
MFC fixes to hostuuid handling

330f110b:
Fix 'hostuuid: preload data malformed' warning

If the preloaded hostuuid value is invalid and verbose booting is
enabled, a warning is printed.  This printf had two bugs:

1. It was missing a trailing \n character.
2. The malformed UUID is printed with %s even though it is not known
to be NUL-terminated.

This commit adds the missing \n and uses %.*s with the (already known)
length of the preloaded UUID to ensure that we don't read past the end
of the buffer.

Reported by: kevans
Fixes: c3188289 Preload hostuuid for early-boot use

b6be9566:
Fix buffer overflow in preloaded hostuuid cleaning

When a module of type "hostuuid" is provided by the loader,
prison0_init strips any trailing whitespace and ASCII control
characters by (a) adjusting the buffer length, and (b) zeroing out
the characters in question, before storing it as the system's
hostuuid.

The buffer length adjustment was correct, but the zeroing overwrote
one byte higher in memory than intended -- in the typical case,
zeroing one byte past the end of the hostuuid buffer.  Due to the
layout of buffers passed by the boot loader to the kernel, this will
be the first byte of a subsequent buffer.

This was *probably* harmless; prison0_init runs after preloaded kernel
modules have been linked and after the preloaded /boot/entropy cache
has been processed, so in both cases having the first byte overwritten
will not cause problems.  We cannot however rule out the possibility
that other objects which are preloaded by the loader could suffer from
having the first byte overwritten.

Since the zeroing does not in fact serve any purpose, remove it and
trim trailing whitespace and ASCII control characters by adjusting
the buffer length alone.

Fixes: c3188289 Preload hostuuid for early-boot use
Reviewed by: kevans, markj

(cherry picked from commit 330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd)
(cherry picked from commit b6be9566d236f83ad1a44170a64b9a34e382eafa)

3 years agoCorrect assert added to dump program.
Kirk McKusick [Mon, 17 May 2021 23:33:59 +0000 (16:33 -0700)]
Correct assert added to dump program.

(cherry picked from commit efe145a7453e4208f032816ce3f80e9fb6b0e4ee)

3 years agofork: Suspend other threads if both RFPROC and RFMEM are not set
Mark Johnston [Thu, 13 May 2021 12:33:23 +0000 (08:33 -0400)]
fork: Suspend other threads if both RFPROC and RFMEM are not set

Otherwise, a multithreaded parent process may trigger races in
vm_forkproc() if one thread calls rfork() with RFMEM set and another
calls rfork() without RFMEM.

Also simplify vm_forkproc() a bit, vmspace_unshare() already checks to
see if the address space is shared.

Reported by: syzbot+0aa7c2bec74c4066c36f@syzkaller.appspotmail.com
Reported by: syzbot+ea84cb06937afeae609d@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30220

(cherry picked from commit 9246b3090cbc82c54350391601b9acef2aa9a625)

3 years agoposix timers: Check for overflow when converting to ns
Mark Johnston [Thu, 13 May 2021 12:33:37 +0000 (08:33 -0400)]
posix timers: Check for overflow when converting to ns

Disallow a time or timer period value when the conversion to nanoseconds
would overflow.  Otherwise it is possible to trigger a divison by zero
in realtime_expire_l(), where we compute the number of overruns by
dividing by the timer interval.

Fixes: 7995dae9 ("posix timers: Improve the overrun calculation")
Reported by: syzbot+5ab360bd3d3e3c5a6e0e@syzkaller.appspotmail.com
Reported by: syzbot+157b74ff493140d86eac@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30233

(cherry picked from commit 8b3c4231abf0ef6ac79655e463d0ef98ad84cd51)

3 years agosort: Hook NetBSD tests up to the build
Mark Johnston [Thu, 13 May 2021 12:57:26 +0000 (08:57 -0400)]
sort: Hook NetBSD tests up to the build

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 186ba88a7c1f2bea14eb3fb092671e8367f7187f)

3 years agosort: Make NetBSD sort tests compatible with our sort
Cyril Zhang [Thu, 13 May 2021 12:50:23 +0000 (08:50 -0400)]
sort: Make NetBSD sort tests compatible with our sort

This diff primarily adds/removes flags to make the tests compatible with
sort.  Two tests are removed.  One test is changed to expect fail due to
a bug.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30217

(cherry picked from commit f9e565abca9b5880fe3203ba67c90eaf3e906e95)

3 years agosort: Cache value of MB_CUR_MAX
Cyril Zhang [Thu, 13 May 2021 12:55:06 +0000 (08:55 -0400)]
sort: Cache value of MB_CUR_MAX

Every usage of MB_CUR_MAX results in a call to __mb_cur_max.  This is
inefficient and redundant.  Caching the value of MB_CUR_MAX in a global
variable removes these calls and speeds up the runtime of sort.  For
numeric sorting, runtime is almost halved in some tests.

PR: 255551
PR: 255840
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30170

(cherry picked from commit 71ec05a21257e159f40d54e26ad0011bb19b5134)

3 years agosort: Stop "fixing" obsolete key syntax after -- flag
Cyril Zhang [Thu, 13 May 2021 12:52:51 +0000 (08:52 -0400)]
sort: Stop "fixing" obsolete key syntax after -- flag

PR: 255798
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30234

(cherry picked from commit fa43162c63790806d0effba5ac98a1a3c6b835e1)

3 years agonetgraph/ng_bridge: Handle send errors during loop handling
Lutz Donnerhacke [Tue, 27 Apr 2021 07:49:50 +0000 (09:49 +0200)]
netgraph/ng_bridge: Handle send errors during loop handling

If sending out a packet fails during the loop over all links, the
allocated memory is leaked and not all links receive a copy.  This
patch fixes those problems, clarifies a premature abort of the loop,
and fixes a minory style(9) bug.

PR: 255430
Submitted by: Dancho Penev
Tested by: Dancho Penev
Differential Revision: https://reviews.freebsd.org/D30008

(cherry picked from commit a56e5ad6903037861457da754574b4903dcb0e7e)

3 years agoregen syscall files after 0bd5d81f1edf
Ed Maste [Thu, 20 May 2021 00:32:37 +0000 (20:32 -0400)]
regen syscall files after 0bd5d81f1edf

3 years agomakesyscalls.lua: improve generated file style(9) compliance
Ed Maste [Wed, 12 May 2021 20:11:44 +0000 (16:11 -0400)]
makesyscalls.lua: improve generated file style(9) compliance

We generally like to avoid style changes when other changes are not
planned.  In this case there are some makesyscalls.lua changes in the
pipeline, and this cleans up style nits in generated files that were
highlighted by experiments with clang-format.

Reviewed by: brooks, kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30235

(cherry picked from commit ad385f7b46e7636b11fb0fd56bc42b60b06b16ad)

3 years agokerberos.8: Replace dead link
Guangyuan Yang [Sun, 16 May 2021 05:37:09 +0000 (01:37 -0400)]
kerberos.8: Replace dead link

Replace it with a tutorial hosted on kerberos.org and the classic
"dialogue" from Bill Bryant. The change has been reported and
merged upstream (https://github.com/heimdal/heimdal/commit/7f3445f1b7).

PR: 251854
Reported by: ktullavik@gmail.com
Submitted by: bjk (upstream github)
Reviewed by: bcr

(cherry picked from commit 80ba60f64394fab3cda10d5921af896ed1c57c5f)

3 years agocache: fix lockless absolute symlink traversal to non-fp mounts
Mateusz Guzik [Tue, 11 May 2021 03:48:08 +0000 (05:48 +0200)]
cache: fix lockless absolute symlink traversal to non-fp mounts

Said lookups would incorrectly fail with EOPNOTSUP.

Reported by: kib

(cherry picked from commit 12288bd999ca3a493b8dc4cba109e5a8fa838c45)

3 years agotruss: Decode FreeBSD 11 mknod(2) and mknodat(2)
Mark Johnston [Wed, 12 May 2021 13:42:11 +0000 (09:42 -0400)]
truss: Decode FreeBSD 11 mknod(2) and mknodat(2)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cd497bd40bb65b5e4603d57614eb15ca7d947a10)

3 years agond6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink()
Mark Johnston [Wed, 12 May 2021 15:49:24 +0000 (11:49 -0400)]
nd6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink()

Commit 81728a538 ("Split rtinit() into multiple functions.") removed
the initialization of sa6, but not one of its uses.  This meant that we
were passing an uninitialized sockaddr as the address to
lltable_prefix_free().  Remove the variable outright to fix the problem.
The caller is expected to hold a reference on pr.

Fixes: 81728a538 ("Split rtinit() into multiple functions.")
Reported by: KMSAN
Reviewed by: donner
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30166

(cherry picked from commit c1dd4d642fa0e2c8ea4f9a879f2cc4e5d6c39211)

3 years agoswap_pager: Zero swap info before exporting to userspace
Mark Johnston [Wed, 12 May 2021 13:42:44 +0000 (09:42 -0400)]
swap_pager: Zero swap info before exporting to userspace

Otherwise padding bytes are leaked.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 06d1fd9f42fa9c060fad8f3a71fcaada3baaf200)

3 years agoif: Remove unnecessary validation in the SIOCSIFNAME handler
Mark Johnston [Wed, 12 May 2021 14:05:37 +0000 (10:05 -0400)]
if: Remove unnecessary validation in the SIOCSIFNAME handler

A successful copyinstr() call guarantees that the returned string is
nul-terminated.  Furthermore, the removed check would harmlessly compare
an uninitialized byte with '\0' if the new name is shorter than
IFNAMESIZ - 1.

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4)

3 years agovn_open_cred(): disallow O_CREAT | O_EMPTY_PATH
Konstantin Belousov [Wed, 12 May 2021 19:04:44 +0000 (22:04 +0300)]
vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH

(cherry picked from commit 6de3cf14c47d97b423ae25d5bd1d80b896ecd9e6)

3 years agoopenat(2): add O_EMPTY_PATH
Konstantin Belousov [Thu, 6 May 2021 17:16:53 +0000 (20:16 +0300)]
openat(2): add O_EMPTY_PATH

(cherry picked from commit 5e7cdf1817924f8ae0333c0b53c2da32f35b65ea)

3 years agortld: initialize default dlerror_seen_val as true
Konstantin Belousov [Tue, 11 May 2021 23:36:09 +0000 (02:36 +0300)]
rtld: initialize default dlerror_seen_val as true

PR: 255698

(cherry picked from commit 529ab5a75925c9c1eeea0b2712911048119d06ae)

3 years agortld: preserve the 'seen' state of the dlerror message in errmsg_save()
Konstantin Belousov [Mon, 10 May 2021 19:02:19 +0000 (22:02 +0300)]
rtld: preserve the 'seen' state of the dlerror message in errmsg_save()

PR: 255698

(cherry picked from commit 630caa95d46191220dd457c2ae2d06460cb4f71b)

3 years agoEnsure that files with no allocated blocks are trimmed to zero length.
Kirk McKusick [Tue, 11 May 2021 21:51:06 +0000 (14:51 -0700)]
Ensure that files with no allocated blocks are trimmed to zero length.

(cherry picked from commit a3628327e7b62c955e7bad9e43044cdb01984d80)

3 years agotests: Only log critical errors from scapy
Kristof Provost [Wed, 12 May 2021 17:13:40 +0000 (19:13 +0200)]
tests: Only log critical errors from scapy

Since 2.4.5 scapy started issuing warnings about a few different
configurations during our tests. These are harmless, but they generate
stderr output, which upsets atf_check.

Configure scapy to only log critical errors (and thus not warnings) to
fix these tests.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit a26e895f3d803cc1f4ee1c2b33c61330998808b9)

3 years agobridge tests: Test STP config BPDU validation
Kristof Provost [Thu, 15 Apr 2021 12:55:00 +0000 (14:55 +0200)]
bridge tests: Test STP config BPDU validation

PR: 254924
Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D29783

(cherry picked from commit 4ae3a97e127cea14277b904af31483af7e6e2891)

3 years agobridgestp: validate timer values in config BPDU
Jonah Caplan [Thu, 15 Apr 2021 09:28:42 +0000 (11:28 +0200)]
bridgestp: validate timer values in config BPDU

IEEE Std 802.1D-2004 Section 17.14 defines permitted ranges for timers.
Incoming BPDU messages should be checked against the permitted ranges.
The rest of 17.14 appears to be enforced already.

PR: 254924
Reviewed by: kp, donner
Differential Revision: https://reviews.freebsd.org/D29782

(cherry picked from commit 0e4025bffa2bab3461b72b40d0b1468722ff76e6)

3 years agonetinet6 tests: Fix Python warning
Kristof Provost [Tue, 11 May 2021 13:47:45 +0000 (15:47 +0200)]
netinet6 tests: Fix Python warning

Python 3.8 warns about line 112:
    'SyntaxWarning: "is" with a literal. Did you mean "=="?'

Use '==' as Python suggests.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 80430c15caac0c10832455f868fa01c912996982)

3 years agoe1000: fix em_mac_min and 82547 packet buffer
Kevin Bowling [Thu, 15 Apr 2021 16:58:36 +0000 (09:58 -0700)]
e1000: fix em_mac_min and 82547 packet buffer

The boundary differentiating "lem" vs "em" class devices was wrong
after the iflib conversion of lem(4).

The Packet Buffer size for 82547 class chips was not set correctly
after the iflib conversion of lem(4).

These changes restore functionality on an 82547 for the submitter.

PR: 236119
Reported by: Jeff Gibbons <jgibbons@protogate.com>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29766

(cherry picked from commit bb1b375fa7487ee5c3843121a0621ac8379c18e6)

3 years agoe1000: disable hw.em.sbp debug setting
Kevin Bowling [Thu, 15 Apr 2021 16:48:41 +0000 (09:48 -0700)]
e1000: disable hw.em.sbp debug setting

This is a debugging tunable that shouldn't have retained this setting
after the initial iflib conversion of the driver

PR: 248934
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29768

(cherry picked from commit 548d8a131d536d5f8e0818ff8cff7ffd63dbedfe)

3 years agosbin/ipfw: Fix parsing error in table based forward
Lutz Donnerhacke [Fri, 7 May 2021 18:59:34 +0000 (20:59 +0200)]
sbin/ipfw: Fix parsing error in table based forward

The argument parser does not recognise the optional port for an
"tablearg" argument.  Fix simplifies the code by make the internal
representation expicit for the parser.  Includes the fix from D30208.

PR: 252744
Reported by: <bugs.freebsd.org@mx.zzux.com>
Approved by: nc
Tested by: <bugs.freebsd.org@mx.zzux.com>
Differential Revision: https://reviews.freebsd.org/D30164

(cherry picked from commit 6cb13813caa09305046e0cecad8bba3ae2287b0d)
(cherry picked from commit f6f297871d469daf808f78faead8f950a2c81e36)

3 years agovfs: fix vnode use count leak in O_EMPTY_PATH support
Mateusz Guzik [Thu, 13 May 2021 09:23:03 +0000 (11:23 +0200)]
vfs: fix vnode use count leak in O_EMPTY_PATH support

The vnode returned by namei_setup is already referenced.

Reported by: pho

(cherry picked from commit cef8a95acbae0c3043d95028d8ebb24d959a82a0)

3 years agonfscl: fix typo in a comment
Rick Macklem [Tue, 4 May 2021 01:29:27 +0000 (18:29 -0700)]
nfscl: fix typo in a comment

(cherry picked from commit 0755df1eeee838e5b114c61886d6462507290977)

3 years agoAdd missing sockaddr length and family validation to various protocols
Mark Johnston [Mon, 3 May 2021 16:51:04 +0000 (12:51 -0400)]
Add missing sockaddr length and family validation to various protocols

Several protocol methods take a sockaddr as input.  In some cases the
sockaddr lengths were not being validated, or were validated after some
out-of-bounds accesses could occur.  Add requisite checking to various
protocol entry points, and convert some existing checks to assertions
where appropriate.

Reported by: syzkaller+KASAN
Reviewed by: tuexen, melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29519

(cherry picked from commit f161d294b92732df6254a89f393ab24999e122bf)

3 years agoin6_mcast: Return EADDRINUSE when we've already joined the group
Kristof Provost [Tue, 4 May 2021 17:23:15 +0000 (19:23 +0200)]
in6_mcast: Return EADDRINUSE when we've already joined the group

Distinguish between truly invalid requests and those that fail because
we've already joined the group. Both cases fail, but differentiating
them allows userspace to make more informed decisions about what the
error means.

For example. radvd tries to join the all-routers group on every SIGHUP.
This fails, because it's already joined it, but this failure should be
ignored (rather than treated as a sign that the interface's multicast is
broken).

This puts us in line with OpenBSD, NetBSD and Linux.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30111

(cherry picked from commit 2ef5d803e3847f56771c107d9517ec560cf318c9)

3 years agoservice/ipfw: Silence warning on restart
Lutz Donnerhacke [Sun, 2 May 2021 20:47:04 +0000 (22:47 +0200)]
service/ipfw: Silence warning on restart

Once the ipfw0 interface has been created, ifconfig(8) create will
throw a warning: "ifconfig: create: bad value" when trying to create
it again.

PR: 241013
Submitted by: Jose Luis Duran
Approved by: kp
Differential Revision: https://reviews.freebsd.org/D30083

(cherry picked from commit 5c4fe2ac81a5e05062266d684fb53b9faefd0d38)

3 years agoClean up copyright messages.
Kirk McKusick [Tue, 11 May 2021 06:01:58 +0000 (23:01 -0700)]
Clean up copyright messages.

(cherry picked from commit 9e16b9530aab5e1c4efee2a8fe2feaf33340c764)

3 years agoixgbe: Restore AIM support
Sai Rajesh Tallamraju [Mon, 3 May 2021 17:45:00 +0000 (13:45 -0400)]
ixgbe: Restore AIM support

AIM (adaptive interrupt moderation) was part of BSD11 driver. Upon IFLIB
migration, AIM feature got lost. Re-introducing AIM back into IFLIB
based IXGBE driver.

One caveat is that in BSD11 driver, a queue comprises both Rx and Tx
ring. Starting from BSD12, Rx and Tx have their own queues and rings.
Also, IRQ is now only configured for Rx side. So, when AIM is
re-enabled, we should now consider only Rx stats for configuring EITR
register in contrast to BSD11 where Rx and Tx stats were considered to
manipulate EITR register.

Reviewed by: gallatin, markj
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27344

(cherry picked from commit 64881da478071431a2d9e62613997a5772c56cdf)

3 years agoClean up fsck_ffs error message output.
Kirk McKusick [Tue, 27 Apr 2021 01:42:48 +0000 (18:42 -0700)]
Clean up fsck_ffs error message output.

(cherry picked from commit 689724cb23c2acf58091c80f27de4823d7cd87ca)

Sponsored by: Netflix

3 years agoMake fsck_ffs more persistent in creating a lost+found directory.
Kirk McKusick [Mon, 26 Apr 2021 23:47:27 +0000 (16:47 -0700)]
Make fsck_ffs more persistent in creating a lost+found directory.

(cherry picked from commit 84a0e3f95700733695115fb2a9d84d6666efe5d9)

Sponsored by: Netflix

3 years agocopy_file_range(2): improve copying of a large hole to EOF
Rick Macklem [Sun, 2 May 2021 23:04:27 +0000 (16:04 -0700)]
copy_file_range(2): improve copying of a large hole to EOF

PR#255523 reported that a file copy for a file with a large hole
to EOF on ZFS ran slowly over NFSv4.2.
The problem was that vn_generic_copy_file_range() would
loop around reading the hole's data and then see it is all
0s. It was coded this way since UFS always allocates a data
block near the end of the file, such that a hole to EOF never exists.

This patch modifies vn_generic_copy_file_range() to check for a
ENXIO returned from VOP_IOCTL(..FIOSEEKDATA..) and handle that
case as a hole to EOF. asomers@ confirms that it works for his
ZFS test case.

PR: 255523

(cherry picked from commit 4f592683c356379c5bac56b52807ed4ad54ee647)

3 years agofind(1): Document the -f option
Ceri Davies [Thu, 13 May 2021 08:10:22 +0000 (10:10 +0200)]
find(1): Document the -f option

PR: 223127
Reported by: Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by: bcr, gbe
Differential Revision: https://reviews.freebsd.org/D30215

(cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0)

3 years agousr.bin/patch: remove unneeded header.
Xin LI [Sun, 2 May 2021 16:27:32 +0000 (09:27 -0700)]
usr.bin/patch: remove unneeded header.

(cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075)

3 years agousr.bin/netstat: use roundup2 when rounding up to power of 2.
Xin LI [Sun, 2 May 2021 16:30:22 +0000 (09:30 -0700)]
usr.bin/netstat: use roundup2 when rounding up to power of 2.

(cherry picked from commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8)

3 years agocxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management.
Navdeep Parhar [Sat, 1 May 2021 23:53:50 +0000 (16:53 -0700)]
cxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management.

The _ext event notification includes the address being added/removed and
that gives the driver an easy way to ignore non-IPv6 addresses.  Remove
'tom' from the handler's name while here, it was moved out of t4_tom a
long time ago.

Sponsored by: Chelsio Communications

(cherry picked from commit f4ba035bca927e21f0f88ce56915523bafd573d9)

3 years agocxgbe(4): Do not panic when tx is called with invalid checksum requests.
Navdeep Parhar [Wed, 28 Apr 2021 20:45:58 +0000 (13:45 -0700)]
cxgbe(4): Do not panic when tx is called with invalid checksum requests.

There is no need to panic in if_transmit if the checksums requested are
inconsistent with the frame being transmitted.  This typically indicates
that the kernel and driver were built with different INET/INET6 options,
or there is some other kernel bug.  The driver should just throw away
the requests that it doesn't understand and move on.

Sponsored by: Chelsio Communications

(cherry picked from commit b9820bca183aba6c0c03a8b717bedd24da7428da)

3 years agocxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
Navdeep Parhar [Fri, 23 Apr 2021 19:17:54 +0000 (12:17 -0700)]
cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.

Sponsored by: Chelsio Communications

(cherry picked from commit 50f5d13eeb8835fe8250d65f033334d7d956d703)

3 years agocxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.
Navdeep Parhar [Fri, 23 Apr 2021 07:26:47 +0000 (00:26 -0700)]
cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.

It can be called to (re)apply the settings in the driver softc to the
hardware.

Sponsored by: Chelsio Communications

(cherry picked from commit 5f00292fe3b76aba9115f3b2dfc887acb647eb91)

3 years agocxgbe(4): Add flag to reliably stop the driver from accessing hw stats.
Navdeep Parhar [Fri, 23 Apr 2021 00:45:52 +0000 (17:45 -0700)]
cxgbe(4): Add flag to reliably stop the driver from accessing hw stats.

There are two kinds of routines in the driver that read statistics from
the hardware: the cxgbe_* variants read the per-port MPS/MAC registers
and the vi_* variants read the per-VI registers.  They can be called
from the 1Hz callout or if_get_counter.  All stats collection now takes
place under the callout lock and there is a new flag to indicate that
these routines should not access any hardware register.

Sponsored by: Chelsio Communications

(cherry picked from commit b47b28e5b28aeaa42e87f905fe6a0fe65dbfc184)

3 years agocxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.
Navdeep Parhar [Tue, 13 Apr 2021 23:50:12 +0000 (16:50 -0700)]
cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.

Sponsored by: Chelsio Communications

(cherry picked from commit d107ee06f3e3c15fe119ea01b120d11bf87ef9f0)

3 years agocxgbe(4): Fix minor nit in the display of MPS TCAM entries.
Navdeep Parhar [Thu, 22 Apr 2021 22:36:51 +0000 (15:36 -0700)]
cxgbe(4): Fix minor nit in the display of MPS TCAM entries.

(cherry picked from commit dc77e7929644b87c0aa3f8f5e8d57fd10f49df54)

3 years agocxgbe(4): make the logging helpers a little more robust.
Navdeep Parhar [Thu, 22 Apr 2021 22:28:43 +0000 (15:28 -0700)]
cxgbe(4): make the logging helpers a little more robust.

Sponsored by: Chelsio Communications

(cherry picked from commit 8f1bc78ef79bc13d88d15cdc5b1bf2f7361ded6d)

3 years agocxgbe/tom: Fix potential leak in t4_aiotx_process_job.
Navdeep Parhar [Sun, 4 Apr 2021 22:04:31 +0000 (15:04 -0700)]
cxgbe/tom: Fix potential leak in t4_aiotx_process_job.

The mbuf allocated could be a chain and must be freed with m_freem.

Reviewed by: jhb@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29579

(cherry picked from commit bf5057691bb0d1160d729772cdb4c449e366f5b4)

3 years agocxgbe(4): Always use the per-VI callout to read interface stats.
Navdeep Parhar [Thu, 1 Apr 2021 07:57:19 +0000 (00:57 -0700)]
cxgbe(4): Always use the per-VI callout to read interface stats.

There is no change in the source of the stats (t4_get_port_stats or
t4_get_vi_stats) but the per-port callout is gone.

Sponsored by: Chelsio Communications
Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D29527

(cherry picked from commit 516fe911a6b7a2d2f245ebbc7837e5dc2e353703)

3 years agocxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT.
Navdeep Parhar [Tue, 30 Mar 2021 04:35:05 +0000 (21:35 -0700)]
cxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT.

This fixes a panic due to stale so->so_proto if t4_tom is unloaded and
one or more connections that were previously offloaded are still around
in TIME_WAIT state.

Reviewed by: jhb@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29503

(cherry picked from commit 539489326947f2873f21b292941f8e5551f7c17b)

3 years agocxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.
Navdeep Parhar [Wed, 24 Mar 2021 01:01:01 +0000 (18:01 -0700)]
cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.

The hw.cxgbe.kern_tls tunable was used for this in the past and if it
was set then all T6 adapters would be configured for NIC TLS operation
and could not be reconfigured for TOE without a reload.  With this
change ifconfig can be used to manipulate toe and txtls caps like any
other caps.  hw.cxgbe.kern_tls continues to work as usual but its
effects are not permanent any more.

* Enable nic_ktls_ofld in the default configuration file and use the
  firmware instead of direct register manipulation to apply/rollback
  NIC TLS configuration.  This allows the driver to switch the hardware
  between TOE and NIC TLS mode in a safe manner.  Note that the
  configuration is adapter-wide and not per-port.

* Remove the kern_tls config file as it works with 100G T6 cards only
  and leads to firmware crashes with 25G cards.  The configurations
  included with the driver (with the exception of the FPGA configs) are
  supposed to work with all adapters.

Reported by: Veeresh U.K. at Chelsio
Sponsored by: Chelsio Communications
Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D29291

(cherry picked from commit 15f33555678300953858f6ed98dfc72c399a9139)

3 years agocxgbe(4): create a separate helper routine to write the global RSS key.
Navdeep Parhar [Fri, 19 Mar 2021 20:28:11 +0000 (13:28 -0700)]
cxgbe(4): create a separate helper routine to write the global RSS key.

While here, make sure only the PF driver attempts to program the global
RSS key (with options RSS).  The VF driver doesn't have access to those
device registers.

Sponsored by: Chelsio Communications

(cherry picked from commit 3cc6f777befc2e494b39a4c0dcd91aaf99267f40)

3 years agocxgbe(4): make it safe to call setup_memwin repeatedly.
Navdeep Parhar [Fri, 19 Mar 2021 19:30:57 +0000 (12:30 -0700)]
cxgbe(4): make it safe to call setup_memwin repeatedly.

A repeat call will recreate the memory windows in the hardware and move
them to their last-known positions without repeating any of the software
initialization.

Sponsored by: Chelsio Communications

(cherry picked from commit a1d803c162067b6cd334fc8a44a89f26cc82d83b)

3 years agocxgbe(4): use standard sysctl routines to deal with 16b values.
Navdeep Parhar [Fri, 19 Mar 2021 17:56:24 +0000 (10:56 -0700)]
cxgbe(4): use standard sysctl routines to deal with 16b values.

These routines to handle 8b and 16b types were added in r289773 5+ years
ago.

Sponsored by: Chelsio Communications

(cherry picked from commit 473f6163e310b773dfd7e500e255d01d7328dd16)

3 years agocxgbe(4): catch up with the latest cryptocaps.
Navdeep Parhar [Mon, 15 Mar 2021 19:54:34 +0000 (12:54 -0700)]
cxgbe(4): catch up with the latest cryptocaps.

There are two crypto capabilities that the driver didn't know about.

Sponsored by: Chelsio Communications

(cherry picked from commit 0b373f26bea17e4b569531b94df30e1af6a0327b)

3 years agocxgbe(4): Remove extra blank line.
Navdeep Parhar [Fri, 5 Mar 2021 20:48:39 +0000 (12:48 -0800)]
cxgbe(4): Remove extra blank line.

No functional change.

(cherry picked from commit 765d623d606c0800f2f2689c03edecac473e30a9)

3 years agocxgbe(4): Fix an assertion that is not valid during attach.
Navdeep Parhar [Fri, 5 Mar 2021 19:28:18 +0000 (11:28 -0800)]
cxgbe(4): Fix an assertion that is not valid during attach.

Firmware access from t4_attach takes place without any synchronization.
The driver should not panic (debug kernels) if something goes wrong in
early communication with the firmware.  It should still load so that
it's possible to poke around with cxgbetool.

Sponsored by: Chelsio Communications

(cherry picked from commit 4a4e9c516cfc54181264c92276301a45ea4680d4)

3 years agocxgbetool(8): Add support for setting the hashfilter mode (filter mask).
Navdeep Parhar [Fri, 19 Feb 2021 22:22:08 +0000 (14:22 -0800)]
cxgbetool(8): Add support for setting the hashfilter mode (filter mask).

Tighten up the validation of filter modes while here.  Unrecognized
keywords will be now be flagged as errors instead of being ignored.

(cherry picked from commit 038148c108c4e7251c52364616273eec72b0c061)

3 years agocxgbe(4): Use the correct filter width for T5+.
Navdeep Parhar [Fri, 19 Feb 2021 22:18:08 +0000 (14:18 -0800)]
cxgbe(4): Use the correct filter width for T5+.

T5 and above have extra bits for the optional filter fields.  This is a
correctness issue and not just a waste because a filter mode valid on a
T4 (36b) may not be valid on a T5+ (40b).

Sponsored by: Chelsio Communications

(cherry picked from commit 0460a45062dfeb98b1f1f7a3a7b9268662b61545)

3 years agocxgbe(4): Add a driver ioctl to set the filter mask.
Navdeep Parhar [Fri, 19 Feb 2021 21:47:18 +0000 (13:47 -0800)]
cxgbe(4): Add a driver ioctl to set the filter mask.

Allow the filter mask (aka the hashfilter mode when hashfilters are
in use) to be set any time it is safe to do so.  The requested mask
must be a subset of the filter mode already.  The driver will not change
the mode or ingress config just to support a new mask.

Sponsored by: Chelsio Communications

(cherry picked from commit c91dda5ad923f24ef2e538b8dc180fa98598b4db)

3 years agocxgbe(4): Use firmware commands to get/set filter configuration.
Navdeep Parhar [Fri, 19 Feb 2021 21:05:19 +0000 (13:05 -0800)]
cxgbe(4): Use firmware commands to get/set filter configuration.

1. Query the firmware for filter mode, mask, and related ingress config
   instead of trying to figure them out from hardware registers.  Read
   configuration from the registers only when the firmware does not
   support this query.

2. Use the firmware to set the filter mode.  This is the correct way to
   do it and is more flexible as well.  The filter mode (and associated
   ingress config) can now be changed any time it is safe to do so.

   The user can specify a subset of a valid mode and the driver will
   enable enough bits to make sure that the mode is maxed out -- that
   is, it is not possible to set another bit without exceeding the
   total width for optional filter fields.  This is a hardware
   requirement that was not enforced by the driver previously.

Sponsored by: Chelsio Communications

(cherry picked from commit 7ac8040a99319456c3225cd5166390f5bd172fdf)

3 years agocxgbe(4): Break up t4_read_chip_settings.
Navdeep Parhar [Thu, 18 Feb 2021 09:15:46 +0000 (01:15 -0800)]
cxgbe(4): Break up t4_read_chip_settings.

Read the PF-only hardware settings directly in get_params__post_init.
Split the rest into two routines used by both the PF and VF drivers: one
that reads the SGE rx buffer configuration and another that verifies
miscellaneous hardware configuration.

Sponsored by: Chelsio Communications

(cherry picked from commit fae028dd97d8fc8f9ba5153408b177481dbefd70)

3 years agoImprove UMA cache reclamation.
Alexander Motin [Sun, 2 May 2021 23:35:28 +0000 (19:35 -0400)]
Improve UMA cache reclamation.

When estimating working set size, measure only allocation batches, not free
batches.  Allocation and free patterns can be very different.  For example,
ZFS on vm_lowmem event can free to UMA few gigabytes of memory in one call,
but it does not mean it will request the same amount back that fast too, in
fact it won't.

Update working set size on every reclamation call, shrinking caches faster
under pressure.  Lack of this caused repeating vm_lowmem events squeezing
more and more memory out of real consumers only to make it stuck in UMA
caches.  I saw ZFS drop ARC size in half before previous algorithm after
periodic WSS update decided to reclaim UMA caches.

Introduce voluntary reclamation of UMA caches not used for a long time. For
each zdom track longterm minimal cache size watermark, freeing some unused
items every UMA_TIMEOUT after first 15 minutes without cache misses. Freed
memory can get better use by other consumers.  For example, ZFS won't grow
its ARC unless it see free memory, since it does not know it is not really
used.  And even if memory is not really needed, periodic free during
inactivity periods should reduce its fragmentation.

Reviewed by: markj, jeff (previous version)
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29790

(cherry picked from commit 2760658b211c654bce1dbde597bc52b49fde5d7e)

3 years agocryptodev: Fix some input validation bugs
Mark Johnston [Tue, 11 May 2021 21:36:12 +0000 (17:36 -0400)]
cryptodev: Fix some input validation bugs

- When we do not have a separate IV, make sure that the IV length
  specified by the session is not larger than the payload size.
- Disallow AEAD requests without a separate IV.  crp_sanity() asserts
  that CRYPTO_F_IV_SEPARATE is set for AEAD requests, and some (but not
  all) drivers require it.
- Return EINVAL for AEAD requests if an IV is specified but the
  transform does not expect one.

Reported by: syzbot+c9e8f6ff5cb7fa6a1250@syzkaller.appspotmail.com
Reported by: syzbot+007341439ae295cee74f@syzkaller.appspotmail.com
Reported by: syzbot+46e0cc42a428b3b0a40d@syzkaller.appspotmail.com
Reported by: syzbot+2c4d670173b8bdb947df@syzkaller.appspotmail.com
Reported by: syzbot+220faa5eeb4d47b23877@syzkaller.appspotmail.com
Reported by: syzbot+e83434b40f05843722f7@syzkaller.appspotmail.com
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30154

(cherry picked from commit 1a04f0156c4e6abfc01d5841341a94179f317f31)

3 years agolibc: Some enhancements to syslog(3)
Dmitry Wagin [Tue, 23 Mar 2021 16:01:15 +0000 (12:01 -0400)]
libc: Some enhancements to syslog(3)

- Defined MAXLINE constant (8192 octets by default instead 2048) for
  centralized limit setting up. It sets maximum number of characters of
  the syslog message. RFC5424 doesn't limit maximum size of the message.
  Named after MAXLINE in syslogd(8).
- Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted
  (%m) messages.
- Introduced autoexpansion of sending socket buffer up to MAXLINE.

Differential Revision: https://reviews.freebsd.org/D27205

(cherry picked from commit 9bd7345212203924046009e29ce3f1515556f989)

3 years agosyslogd: Increase message size limits
Dmitry Wagin [Tue, 23 Mar 2021 16:15:28 +0000 (12:15 -0400)]
syslogd: Increase message size limits

Add a -M option to control the maximum length of forwarded messages.
syslogd(8) used to truncate forwarded messages to 1024 bytes, but after
commit 1a874a126a54 ("Add RFC 5424 syslog message output to syslogd.")
applies a more conservative limit of 480 bytes for IPv4 per RFC 5426
section 3.2.  Restore the old default behaviour of truncating to 1024
bytes.  RFC 5424 specifies no upper limit on the length of forwarded
messages, while for RFC 3164 the limit is 1024 bytes.

Increase MAXLINE to 8192 bytes to correspond to commit 672ef817a192.

Replaced bootfile[] size for MAXPATHLEN used in getbootfile(3) as a
returned value. Using (MAXLINE+1) as a size for bootfile[] is excessive.

PR: 241937
Differential Revision: https://reviews.freebsd.org/D27206

(cherry picked from commit 2d82b47a5b4ef18550565dd55628d51f54d0af2e)

3 years agopf tests: Test killing matching states
Kristof Provost [Mon, 3 May 2021 13:31:03 +0000 (15:31 +0200)]
pf tests: Test killing matching states

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30093

(cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6)