Commit graph

257605 commits

Author SHA1 Message Date
Mateusz Guzik
af68d00a20 pseudofs: use vget_prep + vget_finish instead of vget + the interlock
(cherry picked from commit 43999a5cba)
2021-05-22 18:22:35 +00:00
Mateusz Guzik
e9757b0c94 vfs: refactor vdrop
In particular move vunlazy into its own routine.

(cherry picked from commit cc6f46ac2f)
2021-05-22 18:22:30 +00:00
Mateusz Guzik
df6533f9b4 vfs: change vn_freevnodes_* prefix to idiomatic vfs_freevnodes_*
(cherry picked from commit 715fcc0d34)
2021-05-22 18:22:25 +00:00
Mateusz Guzik
de1b69aec2 vfs: add missing atomic conversion to writecount adjustment
Fixes:	("vfs: lockless writecount adjustment in set/unset text")
(cherry picked from commit 852088f6af)
2021-05-22 18:22:16 +00:00
Mateusz Guzik
2923b7015f 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 ca1ce50b2b)
2021-05-22 18:22:10 +00:00
Mateusz Guzik
4869c1571f vfs: lockless writecount adjustment in set/unset text
... for cases where this is not the first/last exec.

(cherry picked from commit b5fb9ae687)
2021-05-22 18:22:03 +00:00
Mateusz Guzik
0ef41997b3 cache: remove incomplete lockless lockout support during resize
This is already properly handled thanks to 2 step hash replacement.

(cherry picked from commit 074abaccfa)
2021-05-22 18:21:39 +00:00
Mateusz Guzik
400907c645 cache: extend mismatch vnode assert print to include the name
(cherry picked from commit 4f0279e064)
2021-05-22 18:21:28 +00:00
Konstantin Belousov
03aecce81c tmpfs: dynamically register tmpfs pager
(cherry picked from commit 28bc23ab92)
2021-05-22 12:38:30 +03:00
Konstantin Belousov
2f5321c170 vm: Add KPI to dynamically register pagers
(cherry picked from commit b730fd30b7)
2021-05-22 12:38:30 +03:00
Konstantin Belousov
bf9b8d2ae0 sys/vm: remove several other uses of OBJT_SWAP_TMPFS
(cherry picked from commit 7079449b0b)
2021-05-22 12:38:30 +03:00
Konstantin Belousov
324fbdb27a vm_object_set_memattr(): handle all object types without listing them explicitly
(cherry picked from commit 3e7a11ca21)
2021-05-22 12:38:30 +03:00
Konstantin Belousov
f3253c60b4 procfs_map: switch to use vm_object_kvme_type
(cherry picked from commit 8b99833ac2)
2021-05-22 12:38:30 +03:00
Konstantin Belousov
4c4bb6da85 vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops
(cherry picked from commit 00a3fe968b)
2021-05-22 12:38:30 +03:00
Ryan Libby
35d83ba235 Close races in vm object chain traversal for unlock
(cherry picked from commit d7671ad8d6)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
55b68c9ac1 Constify vm_pager-related virtual tables.
(cherry picked from commit d474440ab3)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
2daf5ac2e5 Add OBJT_SWAP_TMPFS pager
(cherry picked from commit 4b8365d752)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
f871a71a82 pagertab: use designated initializers
(cherry picked from commit 0d2dfc6fed)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
6ecea720f3 Style enum obj_type
(cherry picked from commit 838adc533f)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
da0e85f9eb Implement vm_object_vnode() using vm_pager_getvp()
(cherry picked from commit a7c198a24b)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
76674f6896 Add pgo_freespace method
(cherry picked from commit 1390a5cbeb)
2021-05-22 12:38:29 +03:00
Konstantin Belousov
9a311cf995 Add pgo_getvp method
(cherry picked from commit 192112b74f)
2021-05-22 12:38:28 +03:00
Konstantin Belousov
2ad6fea032 Add pgo_mightbedirty method
(cherry picked from commit c23c555bc1)
2021-05-22 12:38:28 +03:00
Konstantin Belousov
f3b6b7de3c vm_pager: add pgo_set_writeable_dirty method
(cherry picked from commit 180bcaa46c)
2021-05-22 12:38:28 +03:00
Konstantin Belousov
12e1d859a6 vm_pager: style some wrappers
(cherry picked from commit ee4211bca6)
2021-05-22 12:38:28 +03:00
Konstantin Belousov
951abff52f swappagerops: slightly more style-compliant formatting
(cherry picked from commit a0850dd057)
2021-05-22 12:38:28 +03:00
Rick Macklem
b7ef4b7eb2 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 dd02d9d605)
2021-05-21 18:16:01 -07:00
Robert Wing
942e69146e 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:          9e5787d228
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D30221

(cherry picked from commit 91f251b2ab)
2021-05-21 07:21:00 -08:00
Mark Johnston
347ae5f345 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 2cca77ee01)
2021-05-21 08:45:34 -04:00
Andriy Gapon
4a7dcb174c 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 8afecefd57)
2021-05-21 13:32:13 +03:00
Daniel Austin
395bc3598b 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 e2ea6942ab)
2021-05-21 13:29:17 +03:00
Andriy Gapon
d7d4592ada 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 12588ce02d)
2021-05-21 13:28:06 +03:00
Colin Percival
3099792c87 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 330f110bf1)
(cherry picked from commit b6be9566d2)
2021-05-20 17:57:15 -07:00
Kirk McKusick
c910e015ba Correct assert added to dump program.
(cherry picked from commit efe145a745)
2021-05-20 15:57:37 -07:00
Mark Johnston
cf60931c32 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 9246b3090c)
2021-05-20 09:16:47 -04:00
Mark Johnston
ec00c33f81 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 8b3c4231ab)
2021-05-20 09:16:05 -04:00
Mark Johnston
b98b323813 sort: Hook NetBSD tests up to the build
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 186ba88a7c)
2021-05-20 09:15:49 -04:00
Cyril Zhang
f2f2413494 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 f9e565abca)
2021-05-20 09:15:46 -04:00
Cyril Zhang
df40dcbf7c 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 71ec05a212)
2021-05-20 09:15:43 -04:00
Cyril Zhang
f80d1c0035 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 fa43162c63)
2021-05-20 09:15:40 -04:00
Lutz Donnerhacke
e240dd0d50 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 a56e5ad690)
2021-05-20 07:52:21 +02:00
Ed Maste
6cd1cb27a9 regen syscall files after 0bd5d81f1e 2021-05-19 20:32:47 -04:00
Ed Maste
0bd5d81f1e 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 ad385f7b46)
2021-05-19 20:31:54 -04:00
Guangyuan Yang
024a9aa701 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 80ba60f643)
2021-05-19 17:22:44 -04:00
Mateusz Guzik
b3e8bfd771 cache: fix lockless absolute symlink traversal to non-fp mounts
Said lookups would incorrectly fail with EOPNOTSUP.

Reported by:	kib

(cherry picked from commit 12288bd999)
2021-05-19 15:53:34 +00:00
Mark Johnston
8aed0580e4 truss: Decode FreeBSD 11 mknod(2) and mknodat(2)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cd497bd40b)
2021-05-19 09:32:40 -04:00
Mark Johnston
010f197770 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 c1dd4d642f)
2021-05-19 09:32:28 -04:00
Mark Johnston
4a6c5c8f59 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 06d1fd9f42)
2021-05-19 09:32:18 -04:00
Mark Johnston
178633e282 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 ad22ba2b9f)
2021-05-19 09:32:11 -04:00
Konstantin Belousov
eea4a0b81a vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH
(cherry picked from commit 6de3cf14c4)
2021-05-19 06:13:15 +03:00