summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a signedness bug.cperciva2006-08-201-1/+1
| | | | | MFC after: 3 days Security: Local DoS
* Close some races between procfs/ptrace and exit(2):jhb2006-02-221-104/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reorder the events in exit(2) slightly so that we trigger the S_EXIT stop event earlier. After we have signalled that, we set P_WEXIT and then wait for any processes with a hold on the vmspace via PHOLD to release it. PHOLD now KASSERT()'s that P_WEXIT is clear when it is invoked, and PRELE now does a wakeup if P_WEXIT is set and p_lock drops to zero. - Change proc_rwmem() to require that the processing read from has its vmspace held via PHOLD by the caller and get rid of all the junk to screw around with the vmspace reference count as we no longer need it. - In ptrace() and pseudofs(), treat a process with P_WEXIT set as if it doesn't exist. - Only do one PHOLD in kern_ptrace() now, and do it earlier so it covers FIX_SSTEP() (since on alpha at least this can end up calling proc_rwmem() to clear an earlier single-step simualted via a breakpoint). We only do one to avoid races. Also, by making the EINVAL error for unknown requests be part of the default: case in the switch, the various switch cases can now just break out to return which removes a _lot_ of duplicated PRELE and proc unlocks, etc. Also, it fixes at least one bug where a LWP ptrace command could return EINVAL with the proc lock still held. - Changed the locking for ptrace_single_step(), ptrace_set_pc(), and ptrace_clear_single_step() to always be called with the proc lock held (it was a mixed bag previously). Alpha and arm have to drop the lock while the mess around with breakpoints, but other archs avoid extra lock release/acquires in ptrace(). I did have to fix a couple of other consumers in kern_kse and a few other places to hold the proc lock and PHOLD. Tested by: ps (1 mostly, but some bits of 2-4 as well) MFC after: 1 week
* Audit the arguments to the ptrace(2) system call.wsalamon2006-02-141-0/+7
| | | | | Obtained from: TrustedBSD Project Approved by: rwatson (mentor)
* Add members pl_sigmask and pl_siglist into ptrace_lwpinfo to get lwp'sdavidxu2006-02-061-0/+2
| | | | signal mask and pending signals.
* Avoid kernel panic when attaching a process which may not be stoppeddavidxu2005-12-241-26/+30
| | | | | | | | | | by debugger, e.g process is dumping core. Only access p_xthread if P_STOPPED_TRACE is set, this means thread is ready to exchange signal with debugger, print a warning if P_STOPPED_TRACE is not set due to some bugs in other code, if there is. The patch has been tested by Anish Mistry mistry.7 at osu dot edu, and is slightly adjusted.
* Make sure pending SIGCHLD is removed from previous parent when processdavidxu2005-11-081-1/+10
| | | | is attached or detached.
* Fix a LOR between sched_lock and sleep queue lock.davidxu2005-08-191-2/+4
|
* Jumbo-commit to enhance 32 bit application support on 64 bit kernels.peter2005-06-301-22/+178
| | | | | | | | | | | | | | | | | | | | | | | | This is good enough to be able to run a RELENG_4 gdb binary against a RELENG_4 application, along with various other tools (eg: 4.x gcore). We use this at work. ia32_reg.[ch]: handle the 32 bit register file format, used by ptrace, procfs and core dumps. procfs_*regs.c: vary the format of proc/XXX/*regs depending on the client and target application. procfs_map.c: Don't print a 64 bit value to 32 bit consumers, or their sscanf fails. They expect an unsigned long. imgact_elf.c: produce a valid 32 bit coredump for 32 bit apps. sys_process.c: handle 32 bit consumers debugging 32 bit targets. Note that 64 bit consumers can still debug 32 bit targets. IA64 has got stubs for ia32_reg.c. Known limitations: a 5.x/6.x gdb uses get/setcontext(), which isn't implemented in the 32/64 wrapper yet. We also make a tiny patch to gdb pacify it over conflicting formats of ld-elf.so.1. Approved by: re
* Add missing cases for PT_SYSCALL.das2005-03-181-0/+2
| | | | Found by: Coverity Prevent analysis tool
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Don't include sys/user.h merely for its side-effect of recursivelydas2004-11-271-1/+1
| | | | including other headers.
* Add pl_flags to ptrace_lwpinfo, two flags PL_FLAG_SA and PL_FLAG_BOUNDdavidxu2004-08-081-0/+7
| | | | | | | indicate that a thread is in UTS critical region. Reviewed by: deischen Approved by: marcel
* - Use atomic ops for updating the vmspace's refcnt and exitingcnt.alc2004-07-271-11/+7
| | | | | | | | - Push down Giant into shmexit(). (Giant is acquired only if the vmspace contains shm segments.) - Eliminate the acquisition of Giant from proc_rwmem(). - Reduce the scope of Giant in exit1(), uncovering the destruction of the address space.
* Fix typo.davidxu2004-07-171-1/+1
|
* Implement following commands: PT_CLEARSTEP, PT_SETSTEP, PT_SUSPENDdavidxu2004-07-131-10/+109
| | | | PT_RESUME, PT_GETNUMLWPS, PT_GETLWPLIST.
* Implement the PT_LWPINFO request. This request can be used by themarcel2004-07-121-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | tracing process to obtain information about the LWP that caused the traced process to stop. Debuggers can use this information to select the thread currently running on the LWP as the current thread. The request has been made compatible with NetBSD for as much as possible. This implementation differs from NetBSD in the following ways: 1. The data argument is allowed to be smaller than the size of the ptrace_lwpinfo structure known to the kernel, but not 0. This is opposite to what NetBSD allows. The reason for this is that we can extend the structure without affecting older binaries. 2. On NetBSD the tracing process is to set the pl_lwpid field to the Id of the LWP it wants information of. We don't do that. Our ptrace interface allows passing the LWP Id instead of the PID. The tracing process is to set the PID to the LWP Id it wants information of. 3. When the PID is actually the PID of the tracing process, this request returns the information about the LWP that caused the process to stop. This was the whole purpose of the request in the first place. When the traced process has exited, this request will return the LWP Id 0, indicating that the process state is not the result of an event specific to a LWP.
* Allow ptrace to deal with lwpid.davidxu2004-07-021-6/+36
| | | | Reviewed by: marcel
* Finish fixing up Alpha to work with an MP safe ptrace():jhb2004-04-011-8/+8
| | | | | | | | | | - ptrace_single_step() is no longer called with the proc lock held, so don't try to unlock it and then relock it. - Push Giant down into proc_rwmem() instead of forcing all the consumers (including Alpha breakpoint support) to explicitly wrap calls to proc_rwmem() with Giant. Tested by: kensmith
* Use uiomove_fromphys() instead of pmap_qenter() and pmap_qremove() inalc2004-03-241-9/+1
| | | | proc_rwmem().
* Drop the proc lock around calls to the MD functions ptrace_single_step(),jhb2004-03-151-6/+11
| | | | | | | | | | ptrace_set_pc(), and cpu_ptrace() so that those functions are free to acquire Giant, sleep, etc. We already do a PHOLD/PRELE around them so that it is safe to sleep inside of these routines if necessary. This allows ptrace() to be marked MP safe again as it no longer triggers lock order reversals on Alpha. Tested by: wilko
* When reparenting a process in the PT_DETACH code, only set p_sigparenttruckman2004-02-191-1/+2
| | | | | | to SIGCHLD if the new parent process is initproc. MFC after: 2 weeks
* When reparenting a process to init, make sure that p_sigparent istruckman2004-02-111-0/+1
| | | | | | | | | set to SIGCHLD. This avoids the creation of orphaned Linux-threaded zombies that init is unable to reap. This can occur when the parent process sets its SIGCHLD to SIG_IGN. Fix a similar situation in the PT_DETACH code. Tested by: "Steven Hartland" <killing AT multiplay.co.uk>
* Implement preliminary support for the PT_SYSCALL command to ptrace(2).robert2003-10-091-1/+16
|
* Add or finish support for machine dependent ptrace requests. When wemarcel2003-08-151-22/+13
| | | | | | | | | | | | | | | | | check for permissions, do it for all requests, not the known requests. Later when we actually service the request we deal with the invalid requests we previously caught earlier. This commit changes the behaviour of the ptrace(2) interface for boundary cases such as an unknown request without proper permissions. Previously we would return EINVAL. Now we return EBUSY or EPERM. Platforms need to define __HAVE_PTRACE_MACHDEP when they have MD requests. This makes the prototype of cpu_ptrace() visible and introduces a call to this function for all requests greater or equal to PT_FIRSTMACH. Silence on: audit
* Add or correct range checking of signal numbers in system calls andnectar2003-08-101-2/+2
| | | | | | | | | ioctls. In the particular case of ptrace(), this commit more-or-less reverts revision 1.53 of sys_process.c, which appears to have been erroneous. Reviewed by: iedowse, jhb
* Background: When proc_rwmem() wired and mapped a page, it also addedalc2003-08-091-30/+5
| | | | | | | | | | | | | | | | a reference to the containing object. The purpose of the reference being to prevent the destruction of the object and an attempt to free the wired page. (Wired pages can't be freed.) Unfortunately, this approach does not work. Some operations, like fork(2) that call vm_object_split(), can move the wired page to a difference object, thereby making the reference pointless and opening the possibility of the wired page being freed. A solution is to use vm_page_hold() in place of vm_page_wire(). Held pages can be freed. They are moved to a special hold queue until the hold is released. Submitted by: tegge
* Use kmem_alloc_nofault() rather than kmem_alloc_pageable() in proc_rwmem().alc2003-08-021-1/+1
| | | | | | See revision 1.140 of kern/sys_pipe.c for a detailed rationale. Submitted by: tegge
* Add vm object locking.alc2003-06-111-12/+12
|
* Use __FBSDID().obrien2003-06-111-2/+3
|
* Push down Giant around calls to proc_rwmem() in kern_ptrace. kern_ptrace()jhb2003-04-251-0/+7
| | | | should now be MP safe.
* Prefer the proc lock to sched_lock when testing PS_INMEM now that it isjhb2003-04-221-2/+1
| | | | safe to do so.
* The sched_lock is not needed while clearing two of the P_STOPPED bits injhb2003-04-171-3/+2
| | | | | p_flag. Also, the proc lock can't be recursed, so simplify an older proc lock assertion.
* Whitespace cleanup.des2003-03-191-5/+5
|
* Add a missing PROC_UNLOCK in ptrace() for the PT_IO case.jhb2002-10-161-0/+1
| | | | | PR: kern/44065 Submitted by: Mark Kettenis <kettenis@chello.nl>
* Completely redo thread states.julian2002-09-111-0/+1
| | | | Reviewed by: davidxu@freebsd.org
* Remove bogus fill_kinfo_proc() before ptrace_set_pc(). There was no needpeter2002-09-071-1/+0
| | | | | | for this. Submitted by: bde
* s/SGNL/SIG/davidxu2002-09-051-1/+1
| | | | | | | | | | s/SNGL/SINGLE/ s/SNGLE/SINGLE/ Fix abbreviation for P_STOPPED_* etc flags, in original code they were inconsistent and difficult to distinguish between them. Approved by: julian (mentor)
* Split up ptrace() into a wrapper that does the copying to and fromiedowse2002-09-051-68/+88
| | | | | | | user space and a kern_ptrace() implementation. Use the kern_*() version in the Linux emulation code to remove more stack gap uses. Approved by: des
* Replace various spelling with FALLTHROUGH which is lint()ablecharnier2002-08-251-1/+1
|
* Do preserve the error result from calling p_cansee() and use that whenrwatson2002-07-201-3/+1
| | | | | | | failing because of the error. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Lock accesses to the page queues.alc2002-07-121-0/+4
|
* Fix ptrace(PT_READ_*, ...) for non-little-endian architectures wheretmm2002-07-121-3/+5
| | | | sizeof(register_t) != sizeof(int).
* Part 1 of KSE-IIIjulian2002-06-291-2/+4
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* All signals can be sent to the inferior process when it's restarted,marcel2002-05-191-1/+1
| | | | | | | not just the legacy ones. PR: 33299 Submitted by: Alexander N. Kabaev <ak03@gte.com>
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-2/+2
| | | | | | | pointer instead of a proc pointer and require the process pointed to by the second argument to be locked. We now use the thread ucred reference for the credential checks in p_can*() as a result. p_canfoo() should now no longer need Giant.
* Remove trace_req().mini2002-05-091-7/+0
| | | | Reviewed by: alfred, jhb, peter
* GCC 3.x WARNS: Add a break to the default case.marcel2002-04-201-0/+1
|
* Don't allow one to trace an ancestor when already traced.alfred2002-04-141-1/+14
| | | | | | | PR: kern/29741 Submitted by: Dave Zarzycki <zarzycki@FreeBSD.org> Fix from: Tim J. Robbins <tim@robbins.dropbear.id.au> MFC After: 2 weeks
* Rework ptrace(2) to be more locking friendly. We do any needed copyin()'sjhb2002-04-121-86/+114
| | | | | | and acquire the proctree_lock if needed first. Then we lock the process if necessary and fiddle with it as appropriate. Finally we drop locks and do any needed copyout's. This greatly simplifies the locking.
* - Change fill_kinfo_proc() to require that the process is locked when itjhb2002-04-091-0/+2
| | | | | | | | | | | | | | is called. - Change sysctl_out_proc() to require that the process is locked when it is called and to drop the lock before it returns. If this proves too complex we can change sysctl_out_proc() to simply acquire the lock at the very end and have the calling code drop the lock right after it returns. - Lock the process we are going to export before the p_cansee() in the loop in sysctl_kern_proc() and hold the lock until we call sysctl_out_proc(). - Don't call p_cansee() on the process about to be exported twice in the aforementioned loop.
OpenPOWER on IntegriCloud