summaryrefslogtreecommitdiff
path: root/sys/kern/sys_process.c
Commit message (Collapse)AuthorAgeFilesLines
* Convert the allproc and proctree locks from lockmgr locks to sx locks.John Baldwin2001-03-281-6/+7
| | | | Notes: svn path=/head/; revision=74927
* - Proc locking.John Baldwin2001-03-071-17/+29
| | | | | | | - Remove some unneeded spl()'s. Notes: svn path=/head/; revision=73917
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* - Catch up to proc flag changes.John Baldwin2001-01-241-4/+18
| | | | | | | | | - Update stopevent() to assert that the proc lock is held when it is held and is not recursed. Note that the STOPEVENT() macro obtains the proc lock when calling this function. Notes: svn path=/head/; revision=71567
* Backout rev 1.57 & 1.58. While the previous revisions fixedPaul Saab2000-12-311-1/+0
| | | | | | | | | attaching to running processes, it completely breaks normal debugging. A better fix is in the works, but cannot be properly tested until the problem with gdb hanging the system in -current is solved. Notes: svn path=/head/; revision=70530
* Pass me the pointy hat. Do not hold sched_lock over psignal.Paul Saab2000-12-301-1/+1
| | | | | | | Submitted by: alfred Notes: svn path=/head/; revision=70503
* Send a SIGCONT when detaching or continuing the excution of a tracedPaul Saab2000-12-281-0/+1
| | | | | | | | | | | process. This fixes a problem when attaching to a process in gdb and the process staying in the STOP'd state after quiting gdb. This whole process seems a bit suspect, but this seems to work. Reviewed by: peter Notes: svn path=/head/; revision=70418
* Protect proc.p_pptr and proc.p_children/p_sibling with theJake Burkholder2000-12-231-1/+11
| | | | | | | | | | | proctree_lock. linprocfs not locked pending response from informal maintainer. Reviewed by: jhb, -smp@ Notes: svn path=/head/; revision=70317
* Change the proc information returned from the kernel so that itKirk McKusick2000-12-121-5/+3
| | | | | | | | | | | | | | | no longer contains kernel specific data structures, but rather only scalar values and structures that are already part of the kernel/user interface, specifically rusage and rtprio. It no longer contains proc, session, pcred, ucred, procsig, vmspace, pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If any of these changed in size, ps, w, fstat, gcore, systat, and top would all stop working. The new structure has over 200 bytes of unassigned space for future values to be added, yet is nearly 100 bytes smaller per entry than the structure that it replaced. Notes: svn path=/head/; revision=69896
* Protect p_stat with sched_lock.John Baldwin2000-12-021-3/+13
| | | | Notes: svn path=/head/; revision=69506
* Remove the signal value check from the PT_STEP codepath. ItJohn W. De Boskey2000-10-141-1/+1
| | | | | | | | | | can cause an bogus failure. Reviewed by: Sean Eric Fagan <sef@kithrup.com> and no other response to the review request. Notes: svn path=/head/; revision=67107
* o Centralize inter-process access control, introducing:Robert Watson2000-08-301-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | int p_can(p1, p2, operation, privused) which allows specification of subject process, object process, inter-process operation, and an optional call-by-reference privused flag, allowing the caller to determine if privilege was required for the call to succeed. This allows jail, kern.ps_showallprocs and regular credential-based interaction checks to occur in one block of code. Possible operations are P_CAN_SEE, P_CAN_SCHED, P_CAN_KILL, and P_CAN_DEBUG. p_can currently breaks out as a wrapper to a series of static function checks in kern_prot, which should not be invoked directly. o Commented out capabilities entries are included for some checks. o Update most inter-process authorization to make use of p_can() instead of manual checks, PRISON_CHECK(), P_TRESPASS(), and kern.ps_showallprocs. o Modify suser{,_xxx} to use const arguments, as it no longer modifies process flags due to the disabling of ASU. o Modify some checks/errors in procfs so that ENOENT is returned instead of ESRCH, further improving concealment of processes that should not be visible to other processes. Also introduce new access checks to improve hiding of processes for procfs_lookup(), procfs_getattr(), procfs_readdir(). Correct a bug reported by bp concerning not handling the CREATE case in procfs_lookup(). Remove volatile flag in procfs that caused apparently spurious qualifier warnigns (approved by bde). o Add comment noting that ktrace() has not been updated, as its access control checks are different from ptrace(), whereas they should probably be the same. Further discussion should happen on this topic. Reviewed by: bde, green, phk, freebsd-security, others Approved by: bde Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=65237
* Introduce the new functionPoul-Henning Kamp1999-11-211-2/+1
| | | | | | | | | | | | | | | | | p_trespass(struct proc *p1, struct proc *p2) which returns zero or an errno depending on the legality of p1 trespassing on p2. Replace kern_sig.c:CANSIGNAL() with call to p_trespass() and one extra signal related check. Replace procfs.h:CHECKIO() macros with calls to p_trespass(). Only show command lines to process which can trespass on the target process. Notes: svn path=/head/; revision=53518
* useracc() the prequel:Poul-Henning Kamp1999-10-291-1/+0
| | | | | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument. Notes: svn path=/head/; revision=52635
* Trim unused options (or #ifdef for undoc options).Peter Wemm1999-10-111-1/+0
| | | | | | | Submitted by: phk Notes: svn path=/head/; revision=52128
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Implement support for hardware debug registers on the i386.Jonathan Lemon1999-07-091-1/+33
| | | | | | | Submitted by: Brian Dean <brdean@unx.sas.com> Notes: svn path=/head/; revision=48691
* Moving the initialization for write sooner quiets a warning.Peter Wemm1999-07-011-2/+2
| | | | Notes: svn path=/head/; revision=48430
* This Implements the mumbled about "Jail" feature.Poul-Henning Kamp1999-04-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a seriously beefed up chroot kind of thing. The process is jailed along the same lines as a chroot does it, but with additional tough restrictions imposed on what the superuser can do. For all I know, it is safe to hand over the root bit inside a prison to the customer living in that prison, this is what it was developed for in fact: "real virtual servers". Each prison has an ip number associated with it, which all IP communications will be coerced to use and each prison has its own hostname. Needless to say, you need more RAM this way, but the advantage is that each customer can run their own particular version of apache and not stomp on the toes of their neighbors. It generally does what one would expect, but setting up a jail still takes a little knowledge. A few notes: I have no scripts for setting up a jail, don't ask me for them. The IP number should be an alias on one of the interfaces. mount a /proc in each jail, it will make ps more useable. /proc/<pid>/status tells the hostname of the prison for jailed processes. Quotas are only sensible if you have a mountpoint per prison. There are no privisions for stopping resource-hogging. Some "#ifdef INET" and similar may be missing (send patches!) If somebody wants to take it from here and develop it into more of a "virtual machine" they should be most welcome! Tools, comments, patches & documentation most welcome. Have fun... Sponsored by: http://www.rndassociates.com/ Run for almost a year by: http://www.servetheweb.com/ Notes: svn path=/head/; revision=46155
* Suser() simplification:Poul-Henning Kamp1999-04-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | 1: s/suser/suser_xxx/ 2: Add new function: suser(struct proc *), prototyped in <sys/proc.h>. 3: s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/ The remaining suser_xxx() calls will be scrutinized and dealt with later. There may be some unneeded #include <sys/cred.h>, but they are left as an exercise for Bruce. More changes to the suser() API will come along with the "jail" code. Notes: svn path=/head/; revision=46112
* Call ptrace_u_check with the right size.Doug Rabson1999-03-291-2/+2
| | | | Notes: svn path=/head/; revision=45105
* Fix warnings in preparation for adding -Wall -Wcast-qual to theMatthew Dillon1999-01-271-2/+2
| | | | | | | kernel compile Notes: svn path=/head/; revision=43301
* Tweak ptrace(PT_READ_U) so that the last alpha register can be read.Doug Rabson1998-12-261-2/+5
| | | | Notes: svn path=/head/; revision=42067
* Only access an int for READU/WRITEU since that is what ptrace is declared toDoug Rabson1998-07-291-2/+2
| | | | | | | return. Notes: svn path=/head/; revision=37958
* Cast function pointers to uintfptr_t before casting them to u_long.Bruce Evans1998-07-151-5/+7
| | | | | | | | | | | | Hopefully caddr_t is large enough to hold function pointers. Cast object pointers to uintptr_t before casting them to u_long. Types are wronger than usual for the PT_READ_U case. ptrace() can only return ints, but longs are accessed. Notes: svn path=/head/; revision=37655
* This commit fixes various 64bit portability problems required forDoug Rabson1998-06-071-5/+5
| | | | | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time. Notes: svn path=/head/; revision=36735
* Disallow reading the current kernel stack. Only the user structure andTor Egge1998-05-191-1/+6
| | | | | | | | the current registers should be accessible. Reviewed by: David Greenman <dg@root.com> Notes: svn path=/head/; revision=36168
* Back out DIAGNOSTIC changes.Eivind Eklund1998-02-061-3/+1
| | | | Notes: svn path=/head/; revision=33134
* Turn DIAGNOSTIC into a new-style option.Eivind Eklund1998-02-041-1/+3
| | | | Notes: svn path=/head/; revision=33108
* VM level code cleanups.John Dyson1998-01-221-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) Start using TSM. Struct procs continue to point to upages structure, after being freed. Struct vmspace continues to point to pte object and kva space for kstack. u_map is now superfluous. 2) vm_map's don't need to be reference counted. They always exist either in the kernel or in a vmspace. The vmspaces are managed by reference counts. 3) Remove the "wired" vm_map nonsense. 4) No need to keep a cache of kernel stack kva's. 5) Get rid of strange looking ++var, and change to var++. 6) Change more data structures to use our "zone" allocator. Added struct proc, struct vmspace and struct vnode. This saves a significant amount of kva space and physical memory. Additionally, this enables TSM for the zone managed memory. 7) Keep ioopt disabled for now. 8) Remove the now bogus "single use" map concept. 9) Use generation counts or id's for data structures residing in TSM, where it allows us to avoid unneeded restart overhead during traversals, where blocking might occur. 10) Account better for memory deficits, so the pageout daemon will be able to make enough memory available (experimental.) 11) Fix some vnode locking problems. (From Tor, I think.) 12) Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp. (experimental.) 13) Significantly shrink, cleanup, and make slightly faster the vm_fault.c code. Use generation counts, get rid of unneded collpase operations, and clean up the cluster code. 14) Make vm_zone more suitable for TSM. This commit is partially as a result of discussions and contributions from other people, including DG, Tor Egge, PHK, and probably others that I have forgotten to attribute (so let me know, if I forgot.) This is not the infamous, final cleanup of the vnode stuff, but a necessary step. Vnode mgmt should be correct, but things might still change, and there is still some missing stuff (like ioopt, and physical backing of non-merged cache files, debugging of layering concepts.) Notes: svn path=/head/; revision=32702
* Changes to allow event-based process monitoring and control.Sean Eric Fagan1997-12-061-1/+20
| | | | Notes: svn path=/head/; revision=31564
* Set return value for the correct process in ptrace().Tor Egge1997-11-121-5/+5
| | | | Notes: svn path=/head/; revision=31138
* Move the "retval" (3rd) parameter from all syscall functions and putPoul-Henning Kamp1997-11-061-7/+6
| | | | | | | | | | | | | | | it in struct proc instead. This fixes a boatload of compiler warning, and removes a lot of cruft from the sources. I have not removed the /*ARGSUSED*/, they will require some looking at. libkvm, ps and other userland struct proc frobbing programs will need recompiled. Notes: svn path=/head/; revision=30994
* Removed unused #includes.Bruce Evans1997-09-021-7/+1
| | | | Notes: svn path=/head/; revision=29041
* Remove bogon from previous commit: doubly included sys/systm.h.Alexander Langer1997-04-271-2/+1
| | | | Notes: svn path=/head/; revision=25206
* Prevent debugger attachment to init when securelevel > 0.Alexander Langer1997-04-271-1/+6
| | | | | | | Noticed by: Brian Buchanan <brian@wasteland.calbbs.com> Notes: svn path=/head/; revision=25200
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* This is the kernel Lite/2 commit. There are some requisite userlandJohn Dyson1997-02-101-1/+1
| | | | | | | | | | | | | | | | | | changes, so don't expect to be able to run the kernel as-is (very well) without the appropriate Lite/2 userland changes. The system boots and can mount UFS filesystems. Untested: ext2fs, msdosfs, NFS Known problems: Incorrect Berkeley ID strings in some files. Mount_std mounts will not work until the getfsent library routine is changed. Reviewed by: various people Submitted by: Jeffery Hsu <hsu@freebsd.org> Notes: svn path=/head/; revision=22521
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Remove the now-unnecessary and incorrect wiring of the "other" processesJohn Dyson1996-06-021-5/+1
| | | | | | | page table pages. The pmap layer now handles that fully. Notes: svn path=/head/; revision=16066
* removed:Poul-Henning Kamp1996-05-021-2/+2
| | | | | | | | | | | | CLBYTES PD_SHIFT PGSHIFT NBPG PGOFSET CLSIZELOG2 CLSIZE pdei() ptei() kvtopte() ptetov() ispt() ptetoav() &c &c new: NPDEPG Major macro cleanup. Notes: svn path=/head/; revision=15543
* Because of the way that ptrace() now calls procfs routines to read/writePeter Wemm1996-03-301-2/+16
| | | | | | | | | | | | | the process's memory, it was possible for the procfs_domem() call to return a residual leftover, but with no errno. Since this is no good for ptrace which ignored the the residual, remap a leftover amount into an errno rather than fooling the caller into thinking it was successful when in fact it was not. Submitted by: bde (a very long time ago :-) Notes: svn path=/head/; revision=14925
* Major fixes for ptrace()...Peter Wemm1996-01-241-99/+226
| | | | | | | | | | | | | | | | | | | PT_ATTACH/PT_DETACH implemented now and fully operational. PT_{GET|SET}{REGS|FPREFS} implemented now, using code shared with procfs PT_{READ|WRITE}_{I|D} now uses code shared with procfs ptrace opcodes now fully permission checked, including ownerships. doing an operation to the u-area on a swapped process should no longer panic. running gdb as root works for me now, where it didn't before. general cleanup.. Note, that this has some tightening of permissions/access checks etc. Some of these may be going too far.. In particular, the "owner" of the traced process is enforced. The process that created or attached to the traced process is now the only one that can "do" things to it. Notes: svn path=/head/; revision=13607
* Eliminated many redundant vm_map_lookup operations for vm_mmap.John Dyson1996-01-191-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Speed up for vfs_bio -- addition of a routine bqrelse to greatly diminish overhead for merged cache. Efficiency improvement for vfs_cluster. It used to do alot of redundant calls to cluster_rbuild. Correct the ordering for vrele of .text and release of credentials. Use the selective tlb update for 486/586/P6. Numerous fixes to the size of objects allocated for files. Additionally, fixes in the various pagers. Fixes for proper positioning of vnode_pager_setsize in msdosfs and ext2fs. Fixes in the swap pager for exhausted resources. The pageout code will not as readily thrash. Change the page queue flags (PG_ACTIVE, PG_INACTIVE, PG_FREE, PG_CACHE) into page queue indices (PQ_ACTIVE, PQ_INACTIVE, PQ_FREE, PQ_CACHE), thereby improving efficiency of several routines. Eliminate even more unnecessary vm_page_protect operations. Significantly speed up process forks. Make vm_object_page_clean more efficient, thereby eliminating the pause that happens every 30seconds. Make sequential clustered writes B_ASYNC instead of B_DELWRI even in the case of filesystems mounted async. Fix a panic with busy pages when write clustering is done for non-VMIO buffers. Notes: svn path=/head/; revision=13490
* Updated to match 1TB filesize changes. Some pindexes were still offsetsBruce Evans1995-12-171-7/+9
| | | | | | | and weren't converted. ptrace() was broken. Notes: svn path=/head/; revision=12903
* Removed dead debugging code.Bruce Evans1995-12-161-7/+1
| | | | Notes: svn path=/head/; revision=12899
* Untangled the vm.h include file spaghetti.David Greenman1995-12-071-1/+9
| | | | Notes: svn path=/head/; revision=12662
* Move the process-table stuff to a more suitable file.Poul-Henning Kamp1995-11-141-1/+7
| | | | | | | Remove filetable stuff from kern_sysctl.c Notes: svn path=/head/; revision=12278
* Included <sys/sysproto.h> to get central declarations for syscall argsBruce Evans1995-11-121-1/+4
| | | | | | | | | | | | | structs and prototypes for syscalls. Ifdefed duplicated decentralized declarations of args structs. It's convenient to have this visible but they are hard to maintain. Some are already different from the central declarations. 4.4lite2 puts them in comments in the function headers but I wanted to avoid the large changes for that. Notes: svn path=/head/; revision=12221
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-9/+9
| | | | Notes: svn path=/head/; revision=8876