summaryrefslogtreecommitdiffstats
path: root/sys/kern (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* regenanton2020-02-222-3/+3
|
* Unlock ioctl(2).anton2020-02-221-2/+2
| | | | ok kettenis@ mpi@ visa@
* In preparation for unlocking ioctl(2), grab the kernel lock as needed.anton2020-02-222-2/+8
| | | | ok kettenis@ mpi@ visa@
* Remove sigacts structure sharing. The only process that used sharing wasclaudio2020-02-214-46/+8
| | | | | | | proc0 which is used for kthreads and idle threads. proc0 and all those other kernel threads don't handle signals so there is no benefit in sharing. Simplifies the code a fair bit since the refcnt is gone. OK kettenis@
* Adjust a comment, no functional changeclaudio2020-02-211-2/+2
|
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-208-32/+32
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Relax the grip the dead hand of QBUS (a.k.a. MAXPHYS) has on thekrw2020-02-201-2/+1
| | | | | | | | | | | throat of physio(). Allows individual devices to eventually be modified to support larger physio() (a.k.a. 'raw') i/o's if they prove capable of them. No immediate functional change. Tested for many weeks by and ok robert@.
* Remove the indirection via timeout for proc_stop_sweep(). Using a softclaudio2020-02-191-13/+13
| | | | | | | | interrupt is enough to defer the signal handling. This is a leftover from the times where not all archs had generic soft interrupts. It is possible that the defer signal handling to a soft interrupt will be removed at a later stage. Input anton@, mpi@ OK kettenis@
* Cleanup <sys/kthread.h> and <sys/proc.h> includes.mpi2020-02-181-1/+2
| | | | | | | Do not include <sys/kthread.h> where it is not needed and stop including <sys/proc.h> in it. ok visa@, anton@
* Move setting of UF_EXCLOSE file descriptor flag inside finishdup().visa2020-02-181-11/+21
| | | | | | This makes it easier to release fdplock before calling closef(). OK mpi@, anton@
* Raise SPL when updating kn_status. Otherwise the field can becomevisa2020-02-171-8/+33
| | | | | | | | | inconsistent if knote_acquire() or knote_release() is preempted by an interrupt that modifies the same knote. OK mpi@ Reported-by: syzbot+8c174edc00da365121d7@syzkaller.appspotmail.com
* Rework vn_ioctl() to only have a single point of return. This will makeanton2020-02-161-11/+13
| | | | | | | | it easier to grab the kernel lock once ioctl() is unlocked. Thanks to semarie@ who came up with an improved diff. ok mpi@ semarie@ visa@
* Unconditionally acquiring a write lock in pipe_ioctl() is quiteanton2020-02-161-5/+5
| | | | | | | | excessive as only one command actually modifies the pipe. The sigio subsystem is already internally protected using its own lock. This is similar to what soo_ioctl() already does. ok mpi@ visa@
* Consistently perform atomic writes to the ps_flags field of structanton2020-02-153-9/+9
| | | | | | process. ok bluhm@ claudio@ visa@
* Defer chained activation of kqueues. This makes easier to introduce newvisa2020-02-141-3/+22
| | | | | | | locks. The deferring also prevents kernel stack exhaustion with deep kqueue hierarchies. OK anton@, mpi@
* Push the KERNEL_LOCK() insidge pgsigio() and selwakeup().mpi2020-02-145-17/+25
| | | | | | | | | | | The 3 subsystems: signal, poll/select and kqueue can now be addressed separatly. Note that bpf(4) and audio(4) currently delay the wakeups to a separate context in order to respect the KERNEL_LOCK() requirement. Sockets (UDP, TCP) and pipes spin to grab the lock for the sames reasons. ok anton@, visa@
* The v_inflight counter was added to mark vnodes that currently do an operationclaudio2020-02-141-6/+2
| | | | | | | | | | that modifies the filesystem as inflight. This is used in the sync calls (on suspend and hibernate) to mark filesystems clean if no work is in flight. VOP_UNLOCK() also got the v_inflight dance but VOP_UNLOCK does not alter filesystem space and so it does not matter if VOP_UNLOCK() is currently run. Also VOP_UNLOCK() does not sleep so there is no way for the sync code to see an inflight VOP_UNLOCK(). OK visa@
* Move the LK_DRAIN logic from VOP_LOCK() to vclean() the only caller ofclaudio2020-02-132-14/+13
| | | | | VOP_LOCK with LK_DRAIN. This simplifies VOP_LOCK() a fair bit. OK visa@
* Do not reparent a traced child to ourself inside wait(2).mpi2020-02-121-2/+3
| | | | | | | | | | | | When a traced process _exit(2)s, its (tracing) parent tries to give it back to the old parent. In the case where the old parent is the same as the tracing parent, there's no need to do this dance, so simply remove it from the list of zombies and free its descriptors. Fix a double report via wait(2) exposed by recent changes in make and newly imported ptrace(2) regression from NetBSD. Diagnosed with espie@ and guenther@, ok claudio@
* the pledge_ioctl() rule checker is written in a style which could readderaadt2020-02-111-18/+19
| | | | | | | ps_pledge more than once. That will cause problems if sys_ioctl is changed to be unlocked (in at least some cases), so switch to a read-once local variable. discussed with a few, ok mpi
* Zero struct knote on allocation. This makes the code less pronevisa2020-02-091-2/+2
| | | | | | to errors. OK deraadt@, cheloha@, anton@
* Replace ttkqflush() with klist_invalidate() to handle knote listvisa2020-02-081-46/+11
| | | | | | | | invalidation in one place. Store struct tty pointer in kn_hook directly to simplify the code. OK mpi@
* Move kernel locking inside knote_fdclose() from finishdup() andvisa2020-02-052-15/+8
| | | | | | | | | | | | fdrelease(). This makes the upper layer of file descriptor closing free of KERNEL_LOCK() when the process does not use kqueue. The kernel locking around fdremove() and knote_fdclose() is no longer needed because kqueue_register() checks if there has been a race with file descriptor close. Moreover, the locking became ineffective against these races when filterops callbacks were allowed to sleep. OK anton@, mpi@
* Allow programs with the "audio" promise to use the AUDIO_MIXER_xxx ioctls.ratchov2020-02-051-1/+4
| | | | ok semarie, deraadt
* Remove dead store, from Amit Kulkarni.mpi2020-02-051-2/+1
|
* allow reading of sysctl kern.somaxconn in "inet", due toderaadt2020-02-041-1/+7
| | | | | operational behaviour of "go" which is not unreasonable from Jimmy Brush
* Back out previous. Nothing wrong with the diff per se but I should haveanton2020-02-012-6/+7
| | | | asked for more oks; my bad!
* Grab the kernel lock in pgsigio() as it's strictly needed whileanton2020-02-012-7/+6
| | | | | | | | | | operating on the process structure and issuing signals. This is similar to what sigio_setown() already does. With this in place, the pipe subsystem is no longer required to grab the kernel lock before calling pgsigio(). ok visa@
* Make writes to the f_flag field of `struct file' MP-safe using atomicanton2020-02-012-10/+13
| | | | | | | | operations. Since the type of f_flag must change in order to use the atomic(9) API, reorder the struct in order to avoid padding; as pointed out by tedu@. ok mpi@ visa@
* Acquire fdplock when updating fd_cmask. This moves the codevisa2020-01-301-3/+4
| | | | | | toward MP-safety. OK mpi@, anton@
* regenvisa2020-01-302-9/+9
|
* Unlock close*(2) and dup*(2).visa2020-01-301-6/+6
| | | | | Tested by krw@, anton@ OK mpi@, anton@
* Split `p_priority' into `p_runpri' and `p_slppri'.mpi2020-01-306-28/+28
| | | | | | | | | | | Using different fields to remember in which runqueue or sleepqueue threads currently are will make it easier to split the SCHED_LOCK(). With this change, the (potentially boosted) sleeping priority is no longer overwriting the thread priority. This let us get rids of the logic required to synchronize `p_priority' with `p_usrpri'. Tested by many, ok visa@
* Use long for temporary variables handling b_bcount values in physio().krw2020-01-261-2/+4
| | | | | | | Add a KASSERTMSG() to check that strategy functions didn't screw b_resid up too much. ok beck@ tedu@
* regentedu2020-01-262-7/+7
|
* add a new __tmpfd system call that creates a new unnamed file in /tmp.tedu2020-01-262-3/+87
| | | | | | intended for shm/fd passing, but for programs that may otherwise like filesystem access. ok beck deraadt kettenis
* invert some if logic to shortcircuit some loops and reduce nesting.tedu2020-01-261-110/+111
| | | | no function change.
* physio() just needs to check for b_bcount overflow. Let the providedkrw2020-01-251-6/+7
| | | | | | | | minphys() function check for MAXPHYS. Feedback from tedu@ kettenis@ dlg@ ok cheloha@, robert@, jmatthew@ as part of larger diff
* The ELF NOTE parser would only inspect the first NOTE for 'OpenBSD'.deraadt2020-01-251-55/+77
| | | | | | | | | | | | | | | | | | | | | | | | Furthermore the parser was unaware a NOTE could contain multiple records. The scanner has been rewritten. Another bonus bug: if the binary was labelled as OPENBSD ABI, NOTE parsing was completely skipped so WXNEEDED wasn't learned either... Now that NOTEs are scanned correctly, search for the 'Go' NOTE. (During this work found the Go linker produces slightly broken NOTEs - Go team will probably fix that). Work is happening for our Go dynamic-binaries to use libc syscall stubs, but the change isn't ready. Go (and reportedly free-pascal also?) binaries are the only dynamic programs which require syscalls in the main-program. Since Go binaries are now identifiable, we can disable syscalls in all other regular dynamic-main-programs, gaining the strict enforcement we want. When the the Go-libc-stub change arrives we'll delete the Go NOTE scan and treat Go binaries same as regular binaries. This change probably breaks free-pascal, a lower priority item to repair. some discussion with jsing, ok kettenis
* *sleep_nsec(9): log process name and pid when nsecs == 0cheloha2020-01-241-7/+13
| | | | | | | | | | | | | | We included DIAGNOSTIC in *sleep_nsec(9) when they were first committed to help us sniff out divison-to-zero bugs when converting *sleep(9) callers to the new interfaces. Recently we exposed the new interface to userland callers. This has yielded some warnings. This diff adds a process name and pid to the warnings to help determine the source of the zero-length sleeps. ok mpi@
* New `kern.allowdt' button must be set to open(2) /dev/dt.mpi2020-01-241-5/+8
| | | | | | | | dt(4) exposes kernel internals, addresses and content of states to userland. As such its interface shouldn't be available without enabling it consciously. ok millert@, deraadt@
* pool(9): replace custom TAILQ concatenation loops with TAILQ_CONCAT(3)cheloha2020-01-241-11/+3
| | | | | | | TAILQ_CONCAT(3) apparently wasn't in-tree when this code was written. Using it leaves us with less code *and* better performance. ok tedu@
* pool(9): pl_sleep(): drop unused timeout argumentcheloha2020-01-231-9/+9
| | | | | | | | | | All sleeps have been indefinite since introduction of this interface ~5 years ago, so remove the timeout argument and make indefinite sleeps implicit. While here: *sleep(9) -> *sleep_nsec(9) "i don't think we're going to use timeouts [here]" tedu@, ok mpi@
* add /etc/protocols to the magic unveil whitelist that the dns pledge hasdlg2020-01-231-2/+6
| | | | "i get it" deraadt@
* add ml_hdatalen and mq_hdatalen as workalikes of ifq_hdatalen.dlg2020-01-221-1/+26
| | | | | | this is so pppx(4) and the upcoming pppac(4) can give kq read data dn FIONREAD values that makes sense like the ones tun(4) and tap(4) provide with ifq_hdatalen.
* delete wasteful ;;deraadt2020-01-221-2/+2
| | | | ok tedu
* Import dt(4) a driver and framework for Dynamic Profiling.mpi2020-01-214-4/+28
| | | | | | | | | | | The design is fairly simple: events, in the form of descriptors on a ring, are being produced in any kernel context and being consumed by a userland process reading /dev/dt. Code and hooks are all guarded under '#if NDT > 0' so this commit shouldn't introduce any change as long as dt(4) is disable in GENERIC. ok kettenis@, visa@, jasper@, deraadt@
* regenvisa2020-01-212-6/+6
|
* Make __thrsleep(2) and __thrwakeup(2) MP-safevisa2020-01-213-35/+79
| | | | | | | | | | | | | | Threads in __thrsleep(2) are tracked using queues, one queue per each process for synchronization between threads of a process, and one system-wide queue for the special ident -1 handling. Each of these queues has an associated rwlock that serializes access. The queue lock is released when calling copyin() and copyout() in thrsleep(). This preserves the existing behaviour where a blocked copy operation does not prevent other threads from making progress. Tested by anton@, claudio@ OK anton@, claudio@, tedu@, mpi@
* struct vops is not modified during runtime so use const which moves eachclaudio2020-01-203-6/+6
| | | | | into read-only data segment. OK deraadt@ tedu@