]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoamd64: clear PSL.AC in the right frame
Konstantin Belousov [Sat, 22 May 2021 19:48:36 +0000 (22:48 +0300)]
amd64: clear PSL.AC in the right frame

If copyin family of routines fault, kernel does clear PSL.AC on the
fault entry, but the AC flag of the faulted frame is kept intact.  Since
onfault handler is effectively jump, AC survives until syscall exit.

Reported by: m00nbsd, via Sony
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
admbugs: 975

(cherry picked from commit 91aae953cb807d6fb7a70782b323bf9beb60d7c9)

3 years agoalc(4): add support for Mikrotik 10/25G NIC
Konstantin Belousov [Wed, 19 May 2021 22:14:18 +0000 (01:14 +0300)]
alc(4): add support for Mikrotik 10/25G NIC

PR: 256000

(cherry picked from commit 77b637338a3656d4ccedb9798a3f98ac283962f4)

3 years agoFix mbuf leaks in various pru_send implementations
Mark Johnston [Wed, 12 May 2021 13:39:36 +0000 (09:39 -0400)]
Fix mbuf leaks in various pru_send implementations

The various protocol implementations are not very consistent about
freeing mbufs in error paths.  In general, all protocols must free both
"m" and "control" upon an error, except if PRUS_NOTREADY is specified
(this is only implemented by TCP and unix(4) and requires further work
not handled in this diff), in which case "control" still must be freed.

This diff plugs various leaks in the pru_send implementations.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d8acd2681bcfb2ff7eb154df82f268b1cb191b4c)

3 years agodummynet: Fix mbuf tag allocation failure handling
Mark Johnston [Tue, 18 May 2021 19:22:21 +0000 (15:22 -0400)]
dummynet: Fix mbuf tag allocation failure handling

PR: 255875, 255878, 255879, 255880
Reviewed by: donner, kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4a6258d70f73c27d8f0c6233edbcc609791806b)

3 years agosocket: Release cred reference later in sodealloc()
Lv Yunlong [Tue, 18 May 2021 19:23:15 +0000 (15:23 -0400)]
socket: Release cred reference later in sodealloc()

We dereference so->so_cred to update the per-uid socket buffer
accounting, so the crfree() call must be deferred until after that
point.

PR: 255869

(cherry picked from commit b295c5ddcef4744ef7044d2327b4258b6ad055f0)

3 years agokern_descrip.c: Style
Konstantin Belousov [Fri, 14 May 2021 23:22:22 +0000 (02:22 +0300)]
kern_descrip.c: Style

(cherry picked from commit 70c05850e276624bb3eb928fa52160712909ec7b)

3 years agottydev_write: prevent stops while terminal is busied
Konstantin Belousov [Thu, 13 May 2021 01:35:06 +0000 (04:35 +0300)]
ttydev_write: prevent stops while terminal is busied

PR: 255816

(cherry picked from commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede)

3 years agoipfw.8: Fix table example
Lutz Donnerhacke [Mon, 10 May 2021 18:31:52 +0000 (20:31 +0200)]
ipfw.8: Fix table example

Fix some erronous lines in the example section.

PR: 248943
Submitted by: Jose Luis Duran
Reviewers: ae, manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D30191

(cherry picked from commit 802637be06457c7593692bdf79f8466fa5f54d4a)

3 years agodummynet: Remove unused code
Kristof Provost [Mon, 17 May 2021 11:41:39 +0000 (13:41 +0200)]
dummynet: Remove unused code

We never set 'busy' and never dequeue from the pending mq. Remove this
code.

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

(cherry picked from commit 02c44f40f984951fe34a1c5a43f40ff8147c52ca)

3 years agopf tests: More set skip on <ifgroup> tests
Kristof Provost [Sun, 16 May 2021 06:51:54 +0000 (08:51 +0200)]
pf tests: More set skip on <ifgroup> tests

Test the specific case reported in PR 255852. Clearing the skip flag
on groups was broken because pfctl couldn't work out if a kif was a
group or not, because the kernel no longer set the pfik_group pointer.

PR: 255852
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30285

(cherry picked from commit 45db38554517c7e1b0cc0265113c22f92a0eb494)

3 years agopf: Set the pfik_group for userspace
Kristof Provost [Sun, 16 May 2021 06:50:17 +0000 (08:50 +0200)]
pf: Set the pfik_group for userspace

Userspace relies on this pointer to work out if the kif is a group or
not. It can't use it for anything else, because it's a pointer to a
kernel address. Substitute 0xfeedc0de for 'true', so that we don't leak
kernel memory addresses to userspace.

PR: 255852
Reviewed by: donner
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30284

(cherry picked from commit d69cc040147284c414dfd1c9f498dcc7c8291a8b)

3 years agompr/mps(4): Make device mapping some more robust.
Alexander Motin [Sat, 24 Apr 2021 03:18:01 +0000 (23:18 -0400)]
mpr/mps(4): Make device mapping some more robust.

Allow new enclosure to replace previously existing one if there is
no completely unused table entry, same as it is done for devices.

If we can not process DPM due to corruption -- wipe it and restart
from scratch.  Otherwise I don't see a way to recover persistence if
something go wrong and there is no BIOS to recover it for us.

Together this solves a problem that appeared when 9300-8i firmware
update to 16.00.10.00 somehow switched its mapping mode from Device
Persistence to Enclosure/Slot without wiping the DPM table.  It made
HBA completely unusable, since overflowed and conflicting mapping
table was unable to map any of enclosures and so devices.

Also while there make some enclosure mapping errors more informative.

MFC after: 1 month
Sponsored by: iXsystems, Inc.

(cherry picked from commit b99419aee49e2cc53747730be4d0ec4f9b330eb2)

3 years agolinux: Fix a mistake in commit fb58045145
Mark Johnston [Mon, 17 May 2021 02:17:53 +0000 (22:17 -0400)]
linux: Fix a mistake in commit fb58045145

The change to futex_andl_smap() should have ordered stac before the
load from a user address, otherwise it does not fix anything.

Fixes: fb58045145 ("linux: Fix SMAP-enabled futex routines")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0)

3 years agoiwmbtfw(8): Add support for Intel 7260/7265 bluetooth adapter firmwares
Philippe Michaud-Boudreault [Tue, 4 May 2021 23:48:21 +0000 (02:48 +0300)]
iwmbtfw(8): Add support for Intel 7260/7265 bluetooth adapter firmwares

To use it comms/iwmbt-firmware port should be updated to 20210315 version.

Submitted by: Philippe Michaud-Boudreault <pitwuu@gmail.com>
Tested by: Helge Oldach <freebsd@oldach.net>
Reviewed by: wulf
PR: 228787

3 years agolinux: Fix SMAP-enabled futex routines
Mark Johnston [Sun, 16 May 2021 17:41:41 +0000 (13:41 -0400)]
linux: Fix SMAP-enabled futex routines

Some of them were dereferencing the user pointer before disabling SMAP.

PR: 255591
Reviewed by: kib
Tested by: pitwuu@gmail.com
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fb580451456aa769daa2f4b2f077e39692f80c62)

3 years agorpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen
Juraj Lutter [Fri, 7 May 2021 21:48:21 +0000 (23:48 +0200)]
rpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen

- Recognize raspberrypi,firmware-ts touchscreen
- Move the driver from ofwbus to simplebus

Reviewed by: manu
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30169

(cherry picked from commit c2c9ef3cedf6d83bdf27308e9e022658cc9b2a08)

3 years agonetgraph/ng_checksum: Fix double free error
Lutz Donnerhacke [Sat, 15 May 2021 09:32:57 +0000 (11:32 +0200)]
netgraph/ng_checksum: Fix double free error

m_pullup(9) frees the mbuf(9) chain in the case of an allocation error.
The mbuf chain must not be freed again in this case.

PR: 255874
Submitted by: <lylgood@foxmail.com>
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D30273

(cherry picked from commit 687e510e5ce32fddf46a9dc1d517ccc8a8e25581)

3 years agoloader: gfx_fb_drawrect should use GfxFbBltVideoFill
Toomas Soome [Tue, 11 May 2021 18:05:12 +0000 (21:05 +0300)]
loader: gfx_fb_drawrect should use GfxFbBltVideoFill

The gfx_fb_drawrect() is drawing rectangle by pixels, this can be very
slow on some systems. Use Blt() video fill primitive instead.

Testing done: Tested on mac mini 2012 where the issue was revealed

(cherry picked from commit 5365af662c78d7bded3bf83c7271d6bff17229a9)

Reviewed by: yuripv

3 years agoFix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode".
Kirk McKusick [Wed, 19 May 2021 21:38:21 +0000 (14:38 -0700)]
Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode".

(cherry picked from commit fe815b88b553667c40353c46b58f9779efa3570e)

PR:           255979
Sponsored by: Netflix

3 years agozfs: avoid memory allocation in arc_prune_async
Mateusz Guzik [Sun, 11 Apr 2021 05:15:41 +0000 (07:15 +0200)]
zfs: avoid memory allocation in arc_prune_async

(cherry picked from commit 97ed4babb51636d8a4b11bc7b207c3219ffcd0e3)

3 years agozfs: make vnlru_free_vfsops use conditional on version
Mateusz Guzik [Sun, 11 Apr 2021 04:49:24 +0000 (06:49 +0200)]
zfs: make vnlru_free_vfsops use conditional on version

Diff reduction against upstream.

(cherry picked from commit feea35bed0dd7a029b70b700cc3c0d2139e3deb8)

3 years agozfs: change format string in zio_fini to get rid of the cast
Mateusz Guzik [Sat, 10 Apr 2021 19:12:00 +0000 (19:12 +0000)]
zfs: change format string in zio_fini to get rid of the cast

(cherry picked from commit a7fbfdee732bd8728d0e642016bf8b6548cfa1bb)

3 years agozfs: make seqc asserts conditional on replay
Mateusz Guzik [Sat, 13 Mar 2021 09:10:16 +0000 (10:10 +0100)]
zfs: make seqc asserts conditional on replay

Avoids tripping on asserts when doing pool recovery.

(cherry picked from commit 59146a6921d06d5cf4320dc8ed82810363ffe7c4)

3 years agovfs: Fix error handling in vn_fullpath_hardlink()
Mark Johnston [Tue, 11 May 2021 00:18:00 +0000 (20:18 -0400)]
vfs: Fix error handling in vn_fullpath_hardlink()

vn_fullpath_any_smr() will return a positive error number if the
caller-supplied buffer isn't big enough.  In this case the error must be
propagated up, otherwise we may copy out uninitialized bytes.

Reported by: syzkaller+KMSAN
Reviewed by: mjg, kib
MFC aftr: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30198

(cherry picked from commit c8bbb1272c8bc103cfaa42c7a1639f42b62483dd)

3 years agozfs: use vn_seqc_read_notmodify for racing .. lookups
Mateusz Guzik [Thu, 22 Apr 2021 13:18:39 +0000 (13:18 +0000)]
zfs: use vn_seqc_read_notmodify for racing .. lookups

Catching an in-flight unlocked vnode is fine here.

Reported by; pho

(cherry picked from commit 7ea3223c7822d20acfc907683fd0153d623185b3)

3 years agozfs: damage control racing .. lookups in face of mkdir/rmdir
Mateusz Guzik [Thu, 15 Apr 2021 07:54:18 +0000 (09:54 +0200)]
zfs: damage control racing .. lookups in face of mkdir/rmdir

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29769

(cherry picked from commit 9c651561a2a31fcb08390d37947afc27ec03d87b)

3 years agotmpfs: reimplement the mtime scan to use the lazy list
Mateusz Guzik [Fri, 7 May 2021 14:43:43 +0000 (14:43 +0000)]
tmpfs: reimplement the mtime scan to use the lazy list

Tested by: pho
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D30065

(cherry picked from commit eec2e4ef7f964d18fcec3dc2cdcd7530be490835)

3 years agovm: add another pager private flag
Mateusz Guzik [Fri, 14 May 2021 07:50:10 +0000 (09:50 +0200)]
vm: add another pager private flag

Contrary to what was done in main, skip the following in order to not
disrupt KBI:
Move OBJ_SHADOWLIST around to let pager flags be next to each other.

(cherry picked from commit 128e25842ef510b39815d784e1d2af0d4afd584f)

3 years agofdescfs: allow shared locking of root vnode
Mateusz Guzik [Wed, 19 May 2021 15:59:20 +0000 (17:59 +0200)]
fdescfs: allow shared locking of root vnode

Eliminates fdescfs from lock profile when running poudriere.

(cherry picked from commit 4fe925b81e75b5885ec6d504c6217f848439164a)

3 years agopseudofs: use vget_prep + vget_finish instead of vget + the interlock
Mateusz Guzik [Wed, 19 May 2021 14:20:23 +0000 (14:20 +0000)]
pseudofs: use vget_prep + vget_finish instead of vget + the interlock

(cherry picked from commit 43999a5cba3cfbf0a0f6244c76a3cd548b6925e8)

3 years agovfs: refactor vdrop
Mateusz Guzik [Fri, 14 May 2021 19:01:32 +0000 (21:01 +0200)]
vfs: refactor vdrop

In particular move vunlazy into its own routine.

(cherry picked from commit cc6f46ac2fd5d910e632fced3f21d0b0f53030d8)

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)