summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Revert the convertion of per-process thread into a SMR_TAILQ.mpi2021-02-081-5/+5
| | | | | We did not reach a consensus about using SMR to unlock single_thread_set() so there's no point in keeping this change.
* Convert the per-process thread list into a SMR_TAILQ.mpi2020-12-071-5/+5
| | | | | | | Currently all iterations are done under KERNEL_LOCK() and therefor use the *_LOCKED() variant. From and ok claudio@
* Serialize accesses to "struct vmspace" and document its refcounting.mpi2020-10-191-4/+3
| | | | | | | The underlying vm_space lock is used as a substitute to the KERNEL_LOCK() in uvm_grow() to make sure `vm_ssize' is not corrupted. ok anton@, kettenis@
* Keep track of traced child under a list of orphans while they are beingmpi2020-03-161-14/+4
| | | | | | | | | | | | | | reparented to a debugger process. Also re-parent exiting traced processes to their original parent, if it is still alive, after the debugger has seen the exit status. Logic comes from FreeBSD pointed out by guenther@. While here rename proc_reparent() into process_reparent() and get rid of superfluous checks. ok visa@
* Replace p_xstat with ps_xexit and ps_xsigguenther2019-12-111-2/+2
| | | | | | | | | Convert those to a consolidated status when needed in wait4(), kevent(), and sysctl() Pass exit code and signal separately to exit1() (This also serves as prep for adding waitid(2)) ok mpi@
* Return EBUSY for successive PT_TRACE_ME calls.mpi2019-11-291-1/+3
| | | | | | Match FreeBSD and NetBSD. ok bluhm@, deraadt@, kettenis@
* Change some returns into gotos, will help keeping the unlocking pathmpi2018-02-191-25/+44
| | | | | | simpler. No functional change. Extracted from a larger diff from guenther@, ok kettenis@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-4/+4
| | | | | | | The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
* Split sys_ptrace() by request type:guenther2017-10-141-359/+477
| | | | | | | | | | | | | | | | | - control operations: trace_me, attach, detach, step, kill, continue. Manipulate process relation/state or send a signal - kernel-state get/set: thread list, event mask, trace state. About the process and don't require target to be stopped, need copyin/out - user-state get/set: memory, register, window cookie. Often thread-specific, require target to be stopped, need copyin/out sys_ptrace() changes to handle request checking, copyin/out to kernel buffers with size check and zeroing, and dispatching to the routines above for the real work. This simplfies the permission checks and copyin/out handling and will simplify lock handling in the future. Inspired in part by FreeBSD. ok mpi@ visa@
* Uninitialized variable can leak kernel memory.deraadt2017-07-191-2/+2
| | | | | Found by Ilja Van Sprundel ok kettenis
* deSCARGize sys_ptrace()guenther2017-01-251-42/+40
| | | | ok mpi@
* Rename pfind(9) into tfind(9) to reflect that it deals with threads.mpi2017-01-241-3/+3
| | | | | | While here document prfind(9. with and ok guenther@
* Split PID from TID, giving processes a PID unrelated to the TID of theirguenther2016-11-071-11/+13
| | | | | | initial thread ok jsing@ kettenis@
* Change process_{domem,auxv_offset}() to take a process instead of a proc.guenther2016-10-191-27/+35
| | | | | | | Make process_auxv_offset() take and release a reference of the vmspace like process_domem() does. ok kettenis@
* Change pmap_proc_iflush() to take a process instead of a procguenther2016-10-191-2/+2
| | | | | | powerpc: rename second argument of pmap_proc_iflush() to match other archs ok kettenis@
* With systrace and procfs gone, process_checkioperm() and process_domem()guenther2016-10-091-3/+1
| | | | | | are for option PTRACE only ok kettenis@
* Get rid of 'relebad:'.akfaew2016-09-011-7/+4
| | | | OK natano@ guenther@
* Fix ptrace PT_WRITE_D that returned EFAULT.jca2016-05-311-2/+2
| | | | | | | Broken in r.1.33. After discussion from kettenis@, don't attempt to make PT_WRITE_D and PT_WRITE_I equivalent again. From Mathieu (naabed at poolp dot org)
* buglet: there's no way for req to be STEP in the DETACH case.tedu2015-09-241-3/+3
| | | | also fix the confusing comment. ok guethner.
* Move ps_strings "after" the random stackgap. This makes its location akettenis2015-01-201-6/+7
| | | | | | | | per-process value, and therefpore turns the VM_PSSTRINGS sysctl into a per-process one as well. This gets rid of a pointer to the bottom of the stack at a fixed location. Also clears the road for unmapping the stackgap. ok deraadt@
* sysctl kern.global_ptrace.tedu2014-12-121-1/+9
| | | | | | controls whether you can ptrace any process with appropriate privileges or only one own's children. ok deraadt
* Delete procfs; it's always had races and is now unused: no one noticed forguenther2014-09-081-2/+2
| | | | | | months that I broke it before the 5.5 release. confirmed as not being required by ports by sthen@, ajacoutot@, dcoppa@
* pass the size to free in some of the obvious casestedu2014-07-131-7/+7
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-7/+7
| | | | after discussions with beck deraadt kettenis.
* It's init as a process that's special, not init's original thread.guenther2014-07-111-2/+2
| | | | | | Remember initprocess instead of initproc. ok matthew@ blambert@
* Add PS_SYSTEM, the process-level mirror of the thread-level P_SYSTEM,guenther2014-05-041-2/+2
| | | | | | | and FORK_SYSTEM as a flag to set them. This eliminates needing to peek into other processes threads in various places. Inspired by NetBSD ok miod@ matthew@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-3/+3
| | | | | | | | | struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
* Move p_emul and p_sigcode from proc to process.guenther2014-03-261-2/+2
| | | | | | | | | Tweak the handling of ktrace EMUL when changing ktracing: only generate one per process (not one per thread) and pass the correct proc pointer down to the VFS layer. Permit generating of NAMI and CSW records inside ktrace(2) itself. ok deraadt@ millert@
* bzero -> memsettedu2014-01-211-4/+4
|
* For now, direct the kill signal sent by PT_KILL to the thread that made uskettenis2012-04-131-1/+4
| | | | | stop, just like we do for PT_CONTINUE/PT_STEP. The current code isn't ready for directing signals to other threads yet.
* First stab at making ptrace(2) usable for debugging multi-threaded programs.kettenis2012-04-131-9/+13
| | | | | | | | | | It implements a full-stop model where all threads are stopped before handing over control to the debugger. Events are reported as before through wait(2); you will have to call ptrace(PT_GET_PROCESS_STATE, ...) to find out which thread hit the event. Since this changes the size of struct ptrace_state, you will have to recompile gdb. ok guenther@
* If the "main" thread exits it stays around but unlinks itself from thekettenis2012-04-121-2/+4
| | | | | | | | | | threads list. Calling TAILQ_NEXT on them is a bad idea and will panic the kernel. So check the P_WEXIT flag and pretend the thread doesn't exist if it is set. Also make PT_GET_THREAD_FIRST return the first thread on the threads list instead of the "main" thread, such that you can actually keep enumerating the threads in this case. ok guenther@, miod@
* PT_GETXMMREGS and PT_SETXMMREGS can take a TID.kettenis2012-04-121-1/+7
|
* Move the P_WAITED flag from struct proc to struct process.kettenis2012-04-111-5/+3
| | | | ok guenther@
* Implement PT_GET_THREAD_FIRS and PT_GET_THREAD_NEXT.kettenis2012-04-061-5/+23
| | | | ok miod@
* Add PS_EXITING to better differentiate between the process exiting andguenther2012-03-101-2/+2
| | | | the main thread exiting. c.f. regress/sys/kern/main-thread-exited/
* Allow this to build on platforms lacking PT_GETFPREGS or PT_SETFPREGS; brokenmiod2012-02-251-1/+5
| | | | in previous rev.
* First steps for making ptrace work with rthreads:guenther2012-02-201-53/+129
| | | | | | | | | | - move the P_TRACED and P_INEXEC flags, and p_oppid, p_ptmask, and p_ptstat member from struct proc to struct process - sort the PT_* requests into those that take a PID vs those that can also take a TID - stub in PT_GET_THREAD_FIRST and PT_GET_THREAD_NEXT ok kettenis@
* Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, soguenther2011-04-021-6/+4
| | | | | | that you can't evade the checks by doing the dirty work in an rthread ok blambert@, deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-11/+11
| | | | | | | | | so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots
* Don't #include <sys/user.h> into files that don't need the stuffguenther2010-06-261-2/+1
| | | | | | | | it defines. In some cases, this means pulling in uvm.h or pcb.h instead, but most of the inclusions were just noise. Tested on alpha, amd64, armish, hppa, i386, macpcc, sgi, sparc64, and vax, mostly by krw and naddy. ok krw@
* Use intermediate vaddr_t cast when casting a pointer to off_t. Preventskettenis2010-05-021-9/+9
| | | | | | | gcc4 from complaining about casting a pointer to an integer type of different size. ok guenther@, jsg@
* Make sure the process tree is is loop-free by forbidding ptrace()guenther2010-01-281-1/+9
| | | | | | | | of a direct ancestor, closing a localhost DoS. As an exception, do permit ptrace() of pid 1 and have inferiors() stop climbing if it hits that. ok tedu@ hpux_compat suggestion from miod@
* Do not assume that a pointer to another process will live over a set ofderaadt2008-10-311-4/+9
| | | | | | | sleeping calls. Since we are simply operating on another process' vmspace, grab a (refcounted) copy of that pointer and use that instead. Similar to the bug just fixed in sysctl_proc_args. discussed with art
* accidental commit ... backoutderaadt2008-10-311-9/+4
|
* kern_sysctl.cderaadt2008-10-311-4/+9
|
* Add PIOD_READ_AUXV, a way to get the ELF auxilliary vector through ptrace(2).kettenis2008-09-161-1/+57
| | | | ok miod@
* ``it's'' -> ``its'' when the grammar gods require this change.miod2007-04-101-2/+2
|
* Since p_flag is often manipulated in interrupts and without biglockart2007-03-151-4/+4
| | | | | | | | | | | | it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
* Kernel stack can be swapped. This means that stuff that's on the stackmiod2006-11-291-18/+1
| | | | | | | | | | should never be referenced outside the context of the process to which this stack belongs unless we do the PHOLD/PRELE dance. Loads of code doesn't follow the rules here. Instead of trying to track down all offenders and fix this hairy situation, it makes much more sense to not swap kernel stacks. From art@, tested by many some time ago.