Commit graph

18350 commits

Author SHA1 Message Date
Konstantin Belousov
fb29b54a91 Regen 2021-08-03 12:52:36 +03:00
Konstantin Belousov
2fb281fa02 Revert most of ce42e79310
to restore ABI compatibility for pre-10.x binaries.

It restores _umtx_lock() and _umtx_unlock() syscalls, and UMTX_OP_LOCK/
UMTX_OP_UNLOCK umtx_op(2) operations. UMUTEX_ERROR_CHECK flag is left
out for now, I do not think it makes a difference.

PR:	218571
Reviewed by:	brooks (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31220

(cherry picked from commit 9b6b793bd7)
2021-08-03 12:52:36 +03:00
Mark Johnston
057275e4be ktrace: Zero request structures when populating the pool
Otherwise uninitialized pad bytes may be copied into the ktrace log
file.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5c18bf9d5f)
2021-07-29 20:32:59 -04:00
Mark Johnston
3e148d6029 select: Define select_flags[] as const
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cae3f9dd01)
2021-07-29 20:32:59 -04:00
Mark Johnston
9ac0aec3a3 lio_listio: Don't post a completion notification if none was requested
One is allowed to use LIO_NOWAIT without specifying a sigevent.  In this
case, lj->lioj_signal is left uninitialized, but several code paths
examine liov_signal.sigev_notify to figure out which notification to
post.  Unconditionally initialize that field to SIGEV_NONE.

Add a dumb test case which triggers the bug.

Reported by:	KMSAN+syzkaller
Reviewed by:	asomers
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e5f615295)
2021-07-29 20:32:58 -04:00
Mark Johnston
24c558ca3c imgact_elf: Avoid redefining suword()
Otherwise this interferes with the definition for sanitizer
interceptors.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ebf9886654)
2021-07-29 20:32:58 -04:00
Mark Johnston
fdeacf8fdf acct: Zero pad bytes in accounting records
Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 90959dd1e5)
2021-07-29 20:32:58 -04:00
Mark Johnston
a67749ac45 vfs: Initialize "lastfail" in vfs_mountroot_wait()
This variable is only used to rate-limit "Root mount waiting for: ..."
messages using ppsratecheck().

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 048cd371f3)
2021-07-29 20:32:58 -04:00
Mark Johnston
b76e41fca9 Add required sysctl name length checks to various handlers
Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0dcef81de9)
2021-07-29 20:32:58 -04:00
Mark Johnston
f065d0bb29 blist: Correct the node count computed in blist_create()
Commit bb4a27f927 added the ability to allocate a span of blocks
crossing a meta node boundary.  To ensure that blst_next_leaf_alloc()
does not walk past the end of the tree, an extra all-zero meta node
needs to be present at the end of the allocation, and
blst_next_leaf_alloc() is implemented such that the presence of this
node terminates the search.

blist_create() computes the number of nodes required.  It had two
problems:
1. When the size of the blist is a power of BLIST_RADIX, we would
   unnecessarily allocate an extra level in the tree.
2. When the size of the blist is a multiple of BLIST_RADIX, we would
   fail to allocate a terminator node.  In this case,
   blst_next_leaf_alloc() could scan beyond the bounds of the
   allocation.  This was found using KASAN.

Modify blist_create() to handle these cases correctly.

Reported by:	pho
Reviewed by:	dougm

(cherry picked from commit 2783335cae)
2021-07-26 21:47:20 -04:00
Mateusz Guzik
225b93b170 cache: add cache_enter_time_flags
(cherry picked from commit 844aa31c6d)
2021-07-25 06:59:56 +00:00
Mark Johnston
1ea187f8a1 callout: Make cc_cpu local to kern_timeout.c
No functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c1aff72cfa)
2021-07-23 07:49:49 -04:00
Konstantin Belousov
39f259b1d5 Do not call FreeBSD-ABI specific code for all ABIs
(cherry picked from commit 28a66fc3da)
2021-07-22 01:11:52 +03:00
Konstantin Belousov
cdb79e2e08 Move sv_onexit() sysentvec hook slightly later
(cherry picked from commit 55976ce11a)
2021-07-22 01:11:52 +03:00
Konstantin Belousov
855fb8944c Add sv_onexec_old() sysent hook for exec event
(cherry picked from commit 71ab344524)
2021-07-22 01:11:51 +03:00
Konstantin Belousov
b1381828c6 procctl(PROC_ASLR_STATUS): fix vmspace leak
(cherry picked from commit 0bdb2cbf9d)
2021-07-18 03:26:52 +03:00
Alexander Motin
4c78f4997a Use sleepq_signal(SLEEPQ_DROP) in cv_signal().
Same as wakeup_one()/wakeup_any() commit before it reduces the lock
hold time and so contention.

MFC after:	1 week

(cherry picked from commit 63ca9ea4f3)
2021-07-17 18:10:25 -04:00
Randall Stewart
deb3c279d1 tcp: HPTS performance enhancements
HPTS drives both rack and bbr, and yet there have been many complaints
about performance. This bit of work restructures hpts to help reduce CPU
overhead. It does this by now instead of relying on the timer/callout to
drive it instead use user return from a system call as well as lro flushes
to drive hpts. The timer becomes a backstop that dynamically adjusts
based on how "late" we are.

Reviewed by:		tuexen, glebius
Sponsored by:		Netflix Inc.
Differential Revision:	https://reviews.freebsd.org/D31083

(cherry picked from commit d7955cc0ff)
2021-07-13 21:58:30 +02:00
Warner Losh
d765d5c2c3 config_intrhook: provide config_intrhook_drain
config_intrhook_drain will remove the hook from the list as
config_intrhook_disestablish does if the hook hasn't been called.  If it has,
config_intrhook_drain will wait for the hook to be disestablished in the normal
course (or expedited, it's up to the driver to decide how and when
to call config_intrhook_disestablish).

This is intended for removable devices that use config_intrhook and might be
attached early in boot, but that may be removed before the kernel can call the
config_intrhook or before it ends. To prevent all races, the detach routine will
need to call config_intrhook_train.

Sponsored by:		Netflix, Inc
Reviewed by:		jhb, mav, gde (in D29006 for man page)
Differential Revision:	https://reviews.freebsd.org/D29005

(cherry picked from commit e52368365d)
2021-07-12 13:30:55 -06:00
Alexander Motin
4a58aca40d Allow sleepq_signal() to drop the lock.
Introduce SLEEPQ_DROP sleepq_signal() flag, allowing one to drop the
sleep queue chain lock before returning.  Reduced lock scope allows
significantly reduce lock contention inside taskqueue_enqueue() for
ZFS worker threads doing ~350K disk reads/s on 40-thread system.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 6df35af4d8)
2021-07-08 21:38:32 -04:00
Moritz Buhl
e991afea1e kern: fail getgroup and setgroup with negative int
Found using
https://github.com/NetBSD/src/blob/trunk/tests/lib/libc/sys/t_getgroups.c

getgroups/setgroups want an int and therefore casting it to u_int
resulted in `getgroups(-1, ...)` not returning -1 / errno = EINVAL.

imp@ updated syscall.master and made changes markj@ suggested

PR:			189941
Tested by:		imp@
Reviewed by:		markj@
Pull Request:		https://github.com/freebsd/freebsd-src/pull/407
Differential Revision:	https://reviews.freebsd.org/D30617

(cherry picked from commit 4bc2174a1b)
2021-07-07 14:09:44 -06:00
Konstantin Belousov
893aecc35a namei: add NDPREINIT() macro
(cherry picked from commit 802cf4ab0e)
2021-07-07 13:23:25 +03:00
Mateusz Guzik
8413d2a786 ktls: switch bare zone_mbuf use to m_free_raw
Reviewed by:	gallatin
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30955

(cherry picked from commit 904a08f342)
2021-07-05 12:05:01 +00:00
Mateusz Guzik
f1c39eb170 mbuf: add m_free_raw to be used instead of directly calling uma_zfree
The intent is to remove all direct zone_mbuf consumers so that ctor/dtor
from that zone can be reimplemented as wrappers around uma, avoiding an
indirect function call.

Reviewed by:	kbowling
Discussed with:	gallatin
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30959

(cherry picked from commit 05462babd4)
2021-07-05 12:04:59 +00:00
Konstantin Belousov
2ea2987d14 Add a knob to disable dequeueing SIGCHLD on waiting for live process
(cherry picked from commit a12e901a5a)
2021-06-22 04:45:32 +03:00
Konstantin Belousov
4f88de7e09 Add a knob to not drop signal with default ignored or ignored actions
(cherry picked from commit bc38762474)
2021-06-22 04:45:31 +03:00
Konstantin Belousov
fc13cbaf69 sigwait: add comment explaining EINTR/ERESTART details
(cherry picked from commit acced8b043)
2021-06-22 04:45:31 +03:00
Konstantin Belousov
299912abf2 sigwait(2) and sigtimedwait(2) must not be restarted.
(cherry picked from commit afb36e289c)
2021-06-22 04:45:31 +03:00
Mark Johnston
d77e57f125 Consistently use the SOCKBUF_MTX() and SOCK_MTX() macros
This makes it easier to change the socket locking protocols.  No
functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a100217489)
2021-06-21 09:14:48 -04:00
Mark Johnston
46d8116cae Consistently use the SOLISTENING() macro
Some code was using it already, but in many places we were testing
SO_ACCEPTCONN directly.  As a small step towards fixing some bugs
involving synchronization with listen(2), make the kernel consistently
use SOLISTENING().  No functional change intended.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f4bb1869dd)
2021-06-21 09:14:40 -04:00
Mark Johnston
129fb0fb02 Fix handling of D_GIANTOK
It was meant to suppress only the printf(), not the subsequent injection
of Giant-protected thunks for various file operations.

Fixes:		fbeb4ccac9
Reported by:	pho
Tested by:	pho
Pointy hat:	markj

(cherry picked from commit 887c753c9f)
2021-06-14 16:25:15 -04:00
Mark Johnston
5346c8bc54 Suppress D_NEEDGIANT warnings for some drivers
During boot we warn that the kbd and openfirm drivers are Giant-locked
and may be deleted.  Generally, the warning helps signal that certain
old drivers are not being maintained and are subject to removal, but
this doesn't really apply to certain drivers which are harder to
detangle from Giant.

Add a flag, D_GIANTOK, that devices can specify to suppress the
misleading warning.  Use it in the kbd and openfirm drivers.

Reviewed by:	imp, jhb
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit fbeb4ccac9)
2021-06-14 16:25:14 -04:00
Andrew Turner
ade8b810b0 Create VM_MEMATTR_DEVICE on all architectures
This is intended to be used with memory mapped IO, e.g. from
bus_space_map with no flags, or pmap_mapdev.

Use this new memory type in the map request configured by
resource_init_map_request, and in pciconf.

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

(cherry picked from commit 5d2d599d3f)
2021-06-13 16:49:36 +01:00
Mateusz Guzik
cfd6c9b99f vfs: slightly rework vn_rlimit_fsize
(cherry picked from commit 478c52f1e3)
2021-06-13 02:15:25 +00:00
Mark Johnston
35e0ffef8e ktrace: Remove vrele() at the end of ktr_writerequest()
(cherry picked from commit 6f6cd1e8e8)
2021-06-13 04:22:34 +03:00
Konstantin Belousov
cad10e50dc ktrace: fix a race between writes and close
(cherry picked from commit fc369a353b)
2021-06-13 04:22:34 +03:00
Mateusz Guzik
1fef441079 Fix limit testing after 1762f674cc ktrace commit.
(cherry picked from commit e71d5c7331)
2021-06-13 04:22:34 +03:00
Mateusz Guzik
e7d3020603 Fix a braino in previous.
(cherry picked from commit 48235c377f)
2021-06-13 04:22:34 +03:00
Mateusz Guzik
c1cbdaa22a Fix tinderbox build after 1762f674cc ktrace commit.
(cherry picked from commit 154f0ecc10)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
a34a4807c9 ktrace: add a kern.ktrace.filesize_limit_signal knob
(cherry picked from commit ea2b64c241)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
66200d3218 ktrace: use the limit of the trace initiator for file size limit on writes
(cherry picked from commit 02645b886b)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
ce0cef608e ktrace: pack all ktrace parameters into allocated structure ktr_io_params
(cherry picked from commit 1762f674cc)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
31df316c10 ktrace: do not stop tracing other processes if our cannot write to this vnode
(cherry picked from commit a6144f713c)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
11cfede1e6 accounting: explicitly mark the exiting thread as doing accounting
(cherry picked from commit 9bb84c23e7)
2021-06-13 04:22:33 +03:00
Konstantin Belousov
ff59c9de32 sysent: allow ABI to disable setid on exec.
(cherry picked from commit 2d423f7671)
2021-06-13 04:22:32 +03:00
Konstantin Belousov
0379dc900e kern_exec.c: Add execve_nosetid() helper
(cherry picked from commit 19e6043a44)
2021-06-13 04:22:32 +03:00
Konstantin Belousov
8c30192804 Add thread_reap_barrier()
(cherry picked from commit f62c7e54e9)
(cherry picked from commit d3f7975fcb)
2021-06-07 19:32:42 +03:00
Konstantin Belousov
b25cbead39 quisce_cpus(): add special handling for PDROP
(cherry picked from commit 3a68546d23)
2021-06-07 19:32:42 +03:00
Konstantin Belousov
664aff03fa kern_thread.c: wrap too long lines
(cherry picked from commit 845d77974b)
2021-06-07 19:32:42 +03:00
Konstantin Belousov
620a48f64d kern linker: do not allow more than one kldload and kldunload syscalls simultaneously
(cherry picked from commit e266a0f7f0)
2021-06-07 19:32:42 +03:00