summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c
AgeCommit message (Collapse)AuthorFilesLines
2020-03-16Keep track of traced child under a list of orphans while they are beingmpi1-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@
2019-12-11Replace p_xstat with ps_xexit and ps_xsigguenther1-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@
2019-11-29Return EBUSY for successive PT_TRACE_ME calls.mpi1-1/+3
Match FreeBSD and NetBSD. ok bluhm@, deraadt@, kettenis@
2018-02-19Change some returns into gotos, will help keeping the unlocking pathmpi1-25/+44
simpler. No functional change. Extracted from a larger diff from guenther@, ok kettenis@
2018-02-19Remove almost unused `flags' argument of suser().mpi1-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@
2017-10-14Split sys_ptrace() by request type:guenther1-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@
2017-07-19Uninitialized variable can leak kernel memory.deraadt1-2/+2
Found by Ilja Van Sprundel ok kettenis
2017-01-25deSCARGize sys_ptrace()guenther1-42/+40
ok mpi@
2017-01-24Rename pfind(9) into tfind(9) to reflect that it deals with threads.mpi1-3/+3
While here document prfind(9. with and ok guenther@
2016-11-07Split PID from TID, giving processes a PID unrelated to the TID of theirguenther1-11/+13
initial thread ok jsing@ kettenis@
2016-10-19Change process_{domem,auxv_offset}() to take a process instead of a proc.guenther1-27/+35
Make process_auxv_offset() take and release a reference of the vmspace like process_domem() does. ok kettenis@
2016-10-19Change pmap_proc_iflush() to take a process instead of a procguenther1-2/+2
powerpc: rename second argument of pmap_proc_iflush() to match other archs ok kettenis@
2016-10-09With systrace and procfs gone, process_checkioperm() and process_domem()guenther1-3/+1
are for option PTRACE only ok kettenis@
2016-09-01Get rid of 'relebad:'.akfaew1-7/+4
OK natano@ guenther@
2016-05-31Fix ptrace PT_WRITE_D that returned EFAULT.jca1-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)
2015-09-24buglet: there's no way for req to be STEP in the DETACH case.tedu1-3/+3
also fix the confusing comment. ok guethner.
2015-01-20Move ps_strings "after" the random stackgap. This makes its location akettenis1-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@
2014-12-12sysctl kern.global_ptrace.tedu1-1/+9
controls whether you can ptrace any process with appropriate privileges or only one own's children. ok deraadt
2014-09-08Delete procfs; it's always had races and is now unused: no one noticed forguenther1-2/+2
months that I broke it before the 5.5 release. confirmed as not being required by ports by sthen@, ajacoutot@, dcoppa@
2014-07-13pass the size to free in some of the obvious casestedu1-7/+7
2014-07-12add a size argument to free. will be used soon, but for now default to 0.tedu1-7/+7
after discussions with beck deraadt kettenis.
2014-07-11It's init as a process that's special, not init's original thread.guenther1-2/+2
Remember initprocess instead of initproc. ok matthew@ blambert@
2014-05-04Add PS_SYSTEM, the process-level mirror of the thread-level P_SYSTEM,guenther1-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@
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoguenther1-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@
2014-03-26Move p_emul and p_sigcode from proc to process.guenther1-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@
2014-01-21bzero -> memsettedu1-4/+4
2012-04-13For now, direct the kill signal sent by PT_KILL to the thread that made uskettenis1-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.
2012-04-13First stab at making ptrace(2) usable for debugging multi-threaded programs.kettenis1-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@
2012-04-12If the "main" thread exits it stays around but unlinks itself from thekettenis1-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@
2012-04-12PT_GETXMMREGS and PT_SETXMMREGS can take a TID.kettenis1-1/+7
2012-04-11Move the P_WAITED flag from struct proc to struct process.kettenis1-5/+3
ok guenther@
2012-04-06Implement PT_GET_THREAD_FIRS and PT_GET_THREAD_NEXT.kettenis1-5/+23
ok miod@
2012-03-10Add PS_EXITING to better differentiate between the process exiting andguenther1-2/+2
the main thread exiting. c.f. regress/sys/kern/main-thread-exited/
2012-02-25Allow this to build on platforms lacking PT_GETFPREGS or PT_SETFPREGS; brokenmiod1-1/+5
in previous rev.
2012-02-20First steps for making ptrace work with rthreads:guenther1-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@
2011-04-02Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, soguenther1-6/+4
that you can't evade the checks by doing the dirty work in an rthread ok blambert@, deraadt@
2010-07-26Correct the links between threads, processes, pgrps, and sessions,guenther1-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
2010-06-26Don't #include <sys/user.h> into files that don't need the stuffguenther1-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@
2010-05-02Use intermediate vaddr_t cast when casting a pointer to off_t. Preventskettenis1-9/+9
gcc4 from complaining about casting a pointer to an integer type of different size. ok guenther@, jsg@
2010-01-28Make sure the process tree is is loop-free by forbidding ptrace()guenther1-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@
2008-10-31Do not assume that a pointer to another process will live over a set ofderaadt1-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
2008-10-31accidental commit ... backoutderaadt1-9/+4
2008-10-31kern_sysctl.cderaadt1-4/+9
2008-09-16Add PIOD_READ_AUXV, a way to get the ELF auxilliary vector through ptrace(2).kettenis1-1/+57
ok miod@
2007-04-10``it's'' -> ``its'' when the grammar gods require this change.miod1-2/+2
2007-03-15Since p_flag is often manipulated in interrupts and without biglockart1-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
2006-11-29Kernel stack can be swapped. This means that stuff that's on the stackmiod1-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.
2006-07-19make kernels w/o PTRACE compile again.grunk1-1/+3
help from mickey@, "commit it" miod@
2006-05-18paramter -> parametermiod1-2/+2
2005-12-13ansi/deregister. No binary change.jsg1-5/+2