Commit Graph

12120 Commits

Author SHA1 Message Date
martin 85cbce96d9 Fix a few oversights from the renaming of dup3110 to dup3100 2024-05-20 09:37:34 +00:00
christos cf1b9a81ef regen 2024-05-20 01:40:44 +00:00
christos 679926ade6 Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
2024-05-20 01:30:33 +00:00
christos eafd8a950e regen 2024-05-19 22:27:15 +00:00
christos 381b1356d0 version dup3 2024-05-19 22:25:47 +00:00
christos dad623351c PR/58266: Collin Funk: Fail if from == to, like FreeBSD and Linux. The test
is done in dup3 before any other tests so even if a bad descriptor it is
passed we will return EINVAL not EBADFD like Linux does.
2024-05-19 15:56:55 +00:00
andvar e4ebea9efd fix recently committed typos by msaitoh in few more places, as well as few more.
mainly s/contigous/contiguous/ and s/miliseconds/milliseconds/ in comments.
2024-05-14 19:00:43 +00:00
msaitoh d40aaeae1e s/signficant/significant/ in comment. 2024-05-13 00:32:09 +00:00
msaitoh 8ae6144b33 s/of of/of/ in comment. 2024-05-13 00:01:52 +00:00
andvar 64e8b7a678 s/timetamp/timestamp/ in comment. 2024-05-11 06:34:45 +00:00
mlelstv 9272c79b76 Account for trailing NUL bytes when calculating userland buffer size. 2024-05-04 13:33:18 +00:00
thorpej 7ed2924faf vmem_init(): Ensure that the quantum is a power of 2, and that if private
tags are being used, they are added to the arena before the first span is
added.
2024-04-24 02:08:03 +00:00
riastradh b7772f668d dounmount: Avoid &((struct vnode_impl *)NULL)->vi_vnode.
Member access of a null pointer is undefined, even if the result
should also be null because vi_vnode is at the start of vnode_impl.

Reported-by: syzbot+a4b2d13c0d6d4dac2d07@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?extid=a4b2d13c0d6d4dac2d07
2024-04-19 00:45:41 +00:00
riastradh 7602e31d2a sys_futex.c: Fix illustration of futex(2).
In this illustration, we need to _set_ bit 1 to claim ownership, not
_clear_ bit 1 to claim ownership.

No functional change intended -- comment only.
2024-04-11 13:51:36 +00:00
riastradh c4eba877ac heartbeat(9): Return early if panicstr is set.
This way we avoid doing unnecessary work -- and print unnecessary
messages -- to _not_ trigger another panic anyway.

PR kern/58011
2024-03-08 23:34:03 +00:00
thorpej 7dff59c837 Revert previous until I can diagnose a failure reported by gson. 2024-03-05 20:59:41 +00:00
thorpej 3302173255 Early in main(), assert that curcpu() evaluates as the primary CPU and
stash away a pointer to it as the boot CPU for quick reference later.
2024-03-05 14:39:29 +00:00
thorpej f36002f244 Move the at-shutdown call to resettodr() from cpu_reboot() to kern_reboot().
It's a small step, but it's a step.
2024-03-05 14:15:28 +00:00
mlelstv 0ec00ddcf5 Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979
2024-03-02 08:59:47 +00:00
mrg 04615d5639 check that l_nopreempt (preemption count) doesn't change after callbacks
check that the idle loop, soft interrupt handlers, workqueue, and xcall
callbacks do not modify the preemption count, in most cases, knowing it
should be 0 currently.

this work was originally done by simonb.  cleaned up slightly and some
minor enhancement made by myself, and with discussion with riastradh@.

other callback call sites could check this as well (such as MD interrupt
handlers, or really anything that includes a callback registration.  x86
version to be commited separately.)
2024-03-01 04:32:38 +00:00
riastradh 69b2327d0b heartbeat(9): Restore still-applicable comment nixed in last commit.
The nesting depth is stored in ci_heartbeat_suspend which is 32-bit.
2024-02-28 04:14:47 +00:00
riastradh d6d810141e heartbeat(9): No kpreempt_disable/enable in heartbeat_suspend/resume.
This causes a leak of l_nopreempt in xc_thread when a CPU is offlined
and onlined again, because the offlining heartbeat_suspend and the
onlining heartbeat_resume happen in separate xcalls.

No change to callers because they are already bound to the CPU:

1. cnpollc does kpreempt_disable/enable itself around the calls to
   heartbeat_suspend/resume anyway

2. cpu_xc_offline/online run in the xcall thread, which is always
   bound to the CPU that is being offlined or onlined
2024-02-28 04:12:59 +00:00
jdolecek 652e3ff5e3 make kqfilter() behave the same for PIPE_SOCKETPAIR pipe as it does
for standard one - refuse EVFILT_WRITE if the reader is already disconnected

fixes test failure for kernel/kqueue/write/t_pipe.c on PIPE_SOCKETPAIR kernel

PR kern/55690
2024-02-11 13:01:29 +00:00
andvar 7715c10d42 s/musn't/mustn't/ in comments. 2024-02-10 09:24:17 +00:00
andvar a10c2cec39 fix various typos in comments and log messages. 2024-02-10 09:21:51 +00:00
andvar 100a3398b8 fix spelling mistakes, mainly in comments and log messages. 2024-02-09 22:08:30 +00:00
jdolecek a1cbbc9c1f fix PIPE_SOCKETPAIR variant of pipe1() to apply correctly the 'flags'
passed when called via pipe2(2), fixing repeatable process hang during
compilation with 'gcc -pipe'

refactor fsocreate() to return the new socket and file pointers,
expect the caller to call fd_affix() once initialization is fully complete

use the new fsocreate() to replace the duplicate open-coded 'flags' handling
in makesocket() used for socketpair(2), and in the PIPE_SOCKETPAIR pipe1()

this also fixes lib/libc/sys/t_pipe2 pipe2_cloexec test to succeed
on PIPE_SOCKETPAIR kernel

fixes PR kern/55690
2024-02-03 19:05:14 +00:00
christos a91d6c6d0a Unbreak sched_m2 (died because lwp_eproc() KASSERT in DIAGNOSTIC) and explain
what is going on. This has been broken since the introduction of l_mutex
5 months ago.
2024-01-24 16:11:48 +00:00
christos e0dbe8aaa6 add lint comments 2024-01-19 19:07:38 +00:00
hannken 29964953ba Protect kernel hooks exechook, exithook and forkhook with rwlock.
Lock as writer on establish/disestablish and as reader on list traverse.

For exechook ride "exec_lock" as it is already take as reader when
traversing the list.  Add local locks for exithook and forkhook.

Move exec_init before signal_init as signal_init calls exechook_establish()
that needs "exec_lock".

PR kern/39913 "exec, fork, exit hooks need locking"
2024-01-17 10:18:41 +00:00
hannken ca4932dc6d Print dangling vnode before panic() to help debug.
PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"
2024-01-17 10:17:29 +00:00
andvar 91f7c6c821 Surround db_stacktrace() with "#ifdef DDB" check.
Fixes LOCKDEBUG enabled build without DDB option.
2024-01-14 11:46:05 +00:00
mlelstv 5238b8a351 dump topology information with aprint_debug instead of requiring to build
a DEBUG kernel.
2024-01-04 11:18:19 +00:00
andvar 13c9a1af85 s/addreseses/addresses/ in comments (and one missing whitespace). 2024-01-03 18:10:42 +00:00
hannken 9db8c230ae Initialize mutex fileassoc_global.lock. 2023-12-28 12:49:06 +00:00
hannken a5288eef9a Include "veriexec.h" and <sys/verified_exec.h> to run
veriexec_unmountchk() on "NVERIEXEC > 0".
2023-12-28 12:48:08 +00:00
andvar bcfabd50d9 s/deatched/detached/ in comment. While here, fix an article before annoyance. 2023-12-20 21:03:50 +00:00
andvar 4b34a91875 fix tripple n typos in "running"/"domainname", also one missing n in comments. 2023-12-20 20:35:37 +00:00
pgoyette 4be362dba2 Modularize the COMPAT_90 code that resulted from the removal of
netinet6/nd6 from the kernel.  Now, the minimal compat code can
be successfully loaded and unloaded along with the rest of the
COMPAT_90 code.

XXX  pullup-10 - hopefully before RC2
2023-12-09 15:21:01 +00:00
pgoyette e512fb100a There's no COMPAT_60 code left here, so no need for conditional
inclusion of header file.
2023-12-07 09:00:32 +00:00
thorpej bf9518a62c Add the notion of "private boundary tags" to vmem. This allows vmem to
be used VERY early in boot; such consumers statically allocate the vmem
arena and boundary tags, and then explicitly add those static, private
boundary tags to the arena tag free list using the new function vmem_add_bts().

Vmem arenas that use private boundary tags will NOT consume the statically
allocated bootstrap tags used by the vmem system itself; the assumption is
that the consumer of such an arena knows what they're doing, and is responsible
for all necessary resource management.  A macro, VMEM_EST_BTCOUNT(), is
provided to help such consumers size the static boundary tag store based
on the expected number of spans and early allocations.  Once the private
tags are exhausted, the arena will dynamically allocate tags as usual.
2023-12-03 19:34:08 +00:00
thorpej 06f1a2dac8 Split the boundary tag "type" field into "type" and "flags" fields.
Initialize the flags field to 0 before inserting into an arena's free
tag list.

NFC, but makes diff for a future enhancement smaller.
2023-12-03 15:06:45 +00:00
thorpej 4a50480344 bt_freetrim(): Restructure the loop as a LIST_FOREACH_SAFE() rather
than a while().  No real change in behavior now, but makes upcoming
enhancements easier.
2023-12-03 14:35:54 +00:00
thorpej 6da7222657 Assert that the vmem_btag_pool has been initialized before we attempt
to allocate from it.
2023-12-03 02:50:09 +00:00
thorpej 7f2518835c Add a vmem_xalloc_addr() function, which allocates a specific address
from an arena.  This is just a convenience wrapper around vmem_xalloc(),
that's just a bit more obvious how to use and performs some additional
sanity checks.
2023-12-02 21:02:12 +00:00
thorpej 7abe897db3 Minor changes to let this build as the "subr_vmem" test program again. 2023-12-02 19:06:17 +00:00
hannken c15cfd474f Restore kpause() accidentially removed with last commit. 2023-11-27 16:13:59 +00:00
hannken 6f60ad1b6a Implement and use an iterator over LRU lists.
Replace the vdrain kernel thread with two threadpool jobs,
one to process deferred vrele and
one to keep the number of allocated vnodes below limit.
2023-11-27 10:03:40 +00:00
ozaki-r e629b37024 mbuf: avoid assertion failure when splitting mbuf cluster
From OpenBSD:

	commit 7b4d35e0a60ba1dd4daf4b1c2932020a22463a89
	Author: bluhm <bluhm@openbsd.org>
	Date:   Fri Oct 20 16:25:15 2023 +0000

	    Avoid assertion failure when splitting mbuf cluster.

	    m_split() calls m_align() to initialize the data pointer of newly
	    allocated mbuf.  If the new mbuf will be converted to a cluster,
	    this is not necessary.  If additionally the new mbuf is larger than
	    MLEN, this can lead to a panic.
	    Only call m_align() when a valid m_data is needed.  This is the
	    case if we do not refecence the existing cluster, but memcpy() the
	    data into the new mbuf.

	    Reported-by: syzbot+0e6817f5877926f0e96a@syzkaller.appspotmail.com
	    OK claudio@ deraadt@

The issue is harmless if DIAGNOSTIC is not enabled.

XXX pullup-10
XXX pullup-9
2023-11-27 02:50:27 +00:00
riastradh fdf689ec4f vfs(9): Make sure to kpause at least one tick, not zero.
kpause(9) forbids zero.

Local workaround for wider problem in PR kern/57718, to address
immediate symptom of crash on any system with hz=50, e.g. alpha in
qemu:

panic: kernel diagnostic assertion "timo != 0 || intr" failed: file "/usr/src/sys/kern/kern_synch.c", line 249

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-22 13:19:50 +00:00