summaryrefslogtreecommitdiff
path: root/sys/kern
AgeCommit message (Collapse)Author
2024-11-03Need to call unsleep before doing the SSTOP check. We need to ensure thatClaudio Jeker
if a sleep is interrupted but the thread is also stopped that on a wakeup the thread runs again. OK mpi@
2024-11-03add powerpc64 and riscv64 to tags arch listJonathan Gray
2024-11-02Always use new_vmcmd() from exec_subr.c, remove the macro whichJonathan Gray
duplicated code with no benefit. ok mpi@ miod@ deraadt@
2024-11-01In sleep_finish() is the process state is SSTOP force a mi_switch().Claudio Jeker
A SIGSTOP delivered between sleep_setup() and sleep_finish() will just change the proc state to SSTOP and sleep_finis() needs to respect that and make sure the thread stays stopped until a SIGCONT is issued. OK mpi@
2024-10-31No need to set pkthdr fields to 0 that are already 0. MGETHDR() does that.Claudio Jeker
OK dlg@
2024-10-31Unlock fs_sysctl(). It is the only `suid_clear' variable - atomicallyVitaliy Makkoveev
accessed integer. ok bluhm
2024-10-30directly use dev_t for swdevt[], remove struct swdevtJonathan Gray
ok mpi@ miod@
2024-10-28Unlock KERN_ALLOWKMEM. The `allowkmem' is atomically accessed integer.Vitaliy Makkoveev
Also use atomic_load_int(9) to load `securelevel'. sysctl_securelevel() is mp-safe, but will be under kernel lock until all existing `securelevel' loading became mp-safe too. ok mpi
2024-10-27Remove KERNEL_LOCK() dance around km_alloc(9) & km_free(9).Martin Pieuchot
Allocating VAs is done via uvm_map(9) which is safe to call without KERNEL_LOCK() since mmap(2) & friends have been marked NOLOCK. ok mvs@
2024-10-25Unlock timeout_sysctl(). `tostat' timeout(9) statistics is alreadyVitaliy Makkoveev
protected by `timeout_mtx' mutex(9). ok kettenis
2024-10-22Protect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.Claudio Jeker
This should be enough to be on the safe side when unlocking ptsignal where a pr->ps_pgrp->pg_jobc == 0 check happens. OK mpi@ kettenis@
2024-10-18Put the bowels of the various VOP_PRINT routines underMiod Vallat
defined(DEBUG) || defined(DIAGNOSTIC) || defined(VFSLCKDEBUG) as they won't be used otherwise. Shaves a few bytes off installation kernels. ok kn@ semarie@
2024-10-17use rw_status instead of interpreting RWL_OWNER to see if a lock is busy.David Gwynne
ok claudio@
2024-10-17Shortcut cursig when called during sleep setup.Claudio Jeker
Add deep flag as function argument which is used by the sleep API but nowhere else. Both calls to sleep_signal_check() should skip the ugly bits of cursig(). In cursig() if deep once it is clear a signal will be taken keep the signal on the thread siglist and return. sleep_signal_check() will then return EINTR or ERESTART based on the signal context. There is no reason to do more in this special case. Especially stop/cont and the ptrace trap must be skipped here. Once the call makes it to userret the signal will be picked up again and handled in a safe location. Stopping singals need some additional logic since we don't want to abort the sleep just to stop a process. Since our SIGSTOP handling requires a major rewrite this will be posponed until then. OK mpi@
2024-10-15Indicate that a process has stopped by setting PS_STOPPED flagClaudio Jeker
The checks in dowait6 and orphanpg using ps_mainproc are flawed and fail if the mainproc called pthread_exit before the other threads. Adding the flag in proc_stop_sweep is racy but the best we have right now. This fixes regress/sys/kern/signal/sig-stop3. OK mpi@
2024-10-15Fix runtime calculation. Assiging ts to spc_runtime does not work if tsClaudio Jeker
is modified. OK tb@ jca@
2024-10-15Use pr instead of p->p_p like everywhere else in exit1.Claudio Jeker
2024-10-09Clear ps_xsig when continuing after a PS_TRACED stop.Claudio Jeker
Also remove the ps_xsig handling in setrunnable() it is in the wrong spot and causes signals to be delivered over and over again. Attaching to an already stopped process is affected by this. The SIGSTOP sent by ptrace is now ignored in ptsignal() and as a result gdb will hang in wait4() until a SIGCONT is delivered to the process. After that all works as usual. OK mpi@
2024-10-09Convert prsignal() into a real functionClaudio Jeker
Also do not use ps_mainproc as the thread the signal is send to. Sending a signal to ps_mainproc may not work reliably if it already exited. Use TAILQ_FIRST(&pr->ps_threads) instead but first check that the process has not yet entered exit1(). OK mpi@
2024-10-08Replace ps_oppid (old parent pid) with ps_opptr (a pointer to the old parent ↵Claudio Jeker
process struct). This simplifies some code and removes the no need to call prfind in process_untrace(). OK mpi@
2024-10-08Move common code to update the proc runtime into tuagg_add_runtime().Claudio Jeker
OK mpi@ kn@
2024-10-08Adjust lock requirements for ps_pptr, ps_ppid and ps_oppid.Claudio Jeker
ps_pptr, ps_ppid and ps_oppid require the KERNEL_LOCK and the process mutex to be modified. At the same time either KERNEL_LOCK or process mutex needs to be taken to read the values. This is needed to further unlock ptsignal(). OK kettenis@, mvs@
2024-10-07Tweak genassym code generation to force preprocessor conditional directivesMiod Vallat
to always be put inside functions. This allows such statements to appear anywhere in assym.cf; without this change they would require at least one `export' or `define' stanza to occur first. Problem noticed by & ok jsg@
2024-10-06remove unused DEBUG_PLEDGE lines; ok deraadt@Jonathan Gray
2024-10-06remove unused sched_cost_load variableJonathan Gray
2024-10-03In rucheck() sum up the tusage from all threads to get the real currentClaudio Jeker
runtime of the process. Also this no longer needs the SCHED_LOCK(). OK mpi@
2024-10-03Fix the clock_gettime() handler for pthread_getcpuclockid() toClaudio Jeker
use the proper way to read tu_runtime. OK mpi@
2024-10-01Make it more obvious which ruadd argument is the source and which one isClaudio Jeker
the destination by adding const to the source pointer. OK tb@
2024-10-01Adjust ptrace interface to properly suport single threaded continue.Claudio Jeker
Introduce P_TRACESINGLE flag to instruct the trapped thread to not wakeup the other threads (via single_thread_clear). This must be done like this since ptrace must wake just the single thread to ensure it runs first and gets the ps_xsig value from ptrace. Modern gdb depends on this for multi-threaded processes, when a breakpoint is hit gdb fixes up the trapping instruction and then single steps over it with only that thread. After that single step gdb continues with all threads. If all threads are run like now it is possible that one of the other threads hits a breakpoint before the single step is done which results in an assertion in gdb (because that is not expected). OK mpi@
2024-09-30Use ps_ppid instead of ps_pptr->ps_pid in all places.Claudio Jeker
OK mpi@
2024-09-30Remove code after exit1() and NOTREACHED comment. Nothing will ever get there.Claudio Jeker
OK mpi@
2024-09-25Do not crash in witness code if interrupt fires early.Alexander Bluhm
It can happen that an interrupt handler is called immediately on a secondary CPU when it is spun up during boot. At that moment no process is schduled yet, so curproc is NULL. To prevent a crash when p->p_sleeplocks is dereferenced, skip witness check in this case. OK visa@
2024-09-24Fix sleeping race during malloc in sysctl hw.disknames.Alexander Bluhm
When mallocarray(9) sleeps, disk_count can change, and diskstatslen gets inconsistent. This caused free(9) to panic. Reported-by: syzbot+36e1f3b306f721f90c72@syzkaller.appspotmail.com OK deraadt@ mpi@
2024-09-24for sysctl on arm64, handle CPU_ID_AA64ISAR1 same as CPU_ID_AA64ISAR0Theo de Raadt
ok sthen
2024-09-22Increase the default buffer size for AF_UNIX from 8192 to 32768.Claudio Jeker
Using 8k for socketpairs was always on the low end side. Also this avoid a fatal error in sshd that can be triggered when the network stack is pushed hard enough to consume most of the allowed memory. By increasing the default buffer size a bit the error in sshd is avoided which is good enough for now. Long term a better solution for sonewconn() and especially sbchecklowmem() needs to be found. m_pool_used() returns not the right information for them. OK deraadt@ otto@
2024-09-15Invalid pintables in ELF binaries can crash the kernel.Theo de Raadt
Fix from yufeng.gao@uq.edu.au
2024-09-10Fix build of m_print_chain() on sparc64.Alexander Bluhm
Use %zu to print mbuf MHLEN and MLEN in ddb, otherwise gcc complains. found by claudio@
2024-09-09Print mbuf size also for non cluster.Alexander Bluhm
Command "ddb> show /c mbuf" always prints mbuf data size. In uipc_mbuf.c include db_interface.h as it contains prototype for m_print_chain(). OK mvs@
2024-09-06Fix KUBSAN by adding invalid builtin detection, as needed by our current clang.Moritz Buhl
ok anton@
2024-09-06Remove incorrect increment of the context switch counter.Martin Pieuchot
From Christian Ludwig. ok claudio@
2024-09-05In ddb(4) print mbuf chain and packet list.Alexander Bluhm
For debugging hardware offloading, DMA requirements, bounce buffers, and performance optimizations, knowing the memory layout of mbuf content helps. Implement /c and /p modifiers in ddb show mbuf. It traverses the pointer m_next for mbuf chain or m_nextpkt for packet list. Show mbuf type, data offset, mbuf length, packet length, cluster size, and total number of elements, length and size. OK claudio@ mvs@
2024-09-04make psp attach to ccp as a different driverJonathan Gray
'fine with me' hshoexer, ok bluhm@
2024-09-02simplify ccp ifdef; ok bluhm@Jonathan Gray
2024-09-01Regarding previous commit, X_OK on unveil-permitted directories doesTheo de Raadt
not map nicely to UNVEIL_EXEC. But we don't know before calling namei() if the path is a directory. Oh well, stick to UNVEIL_READ for that case, it is going to be good enough for the typical case. Worked out with jeremy after chrome/firefox Downloads directory issue.
2024-09-01Pledge "vmm" for ccp(4) ioctl(2).Alexander Bluhm
Limit ccp ioctls to processes that pledge vmm. Specific psp device ioctls for AMD SEV will allowed for vmd(8). from hshoexer@; input deraadt@ jsg@
2024-08-31jeremy observed that access() on unveiled space was returning errorsTheo de Raadt
for valid requests. This is because the nd.ni_unveil to namei() was always UNVEIL_READ, regardless of the request amode. Building a correct ni_unveil passes a new regression test, producing expected results. ok beck jeremy
2024-08-29In m_pulldown() replace memmove() with memcpy().Alexander Bluhm
The memmove() in m_pulldown() copied memory between different mbufs. So data cannot overlap and memcpy() is enough. OK claudio@ deraadt@
2024-08-29Show expensive mbuf operations in netstat(1) statistics.Alexander Bluhm
If the memory layout is not optimal, m_defrag(), m_prepend(), m_pullup(), and m_pulldown() will allocate mbufs or copy memory. Count these operations to find possible optimizations. input dhill@; OK mvs@
2024-08-26style(9) fix. No functional changes.Vitaliy Makkoveev
2024-08-23Fix KERN_AUDIO broken in rev 1.440.Vitaliy Makkoveev