summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
Commit message (Collapse)AuthorAgeFilesLines
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-068-8/+8
|
* Fix unvalidated pointer dereference. This is FreeBSD-SA-04:17.procfs.cperciva2004-12-011-1/+13
|
* Rework how we store process times in the kernel such that we always storejhb2004-10-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month
* Don't PHOLD() the target process in procfs, since this is already donedas2004-10-013-6/+3
| | | | | in pseudofs. Moreover, PHOLD() may block between the p_candebug() access check and the actual operation.
* Remove advertising clause from University of California Regent'simp2004-04-0710-41/+1
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
* Remove ps_argsopen from this check, because of two reasons:pjd2004-04-011-1/+1
| | | | | | 1. This check if wrong, because it is true by default (kern.ps_argsopen is 1 by default) (p_cansee() is not even checked). 2. Sysctl kern.ps_argsopen is going away.
* Locking for the per-process resource limits structure.jhb2004-02-041-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64
* Lock p->p_textvp before calling vn_fullpath() on it. Note therwatson2004-01-071-0/+2
| | | | | | | | potential lock order concern due to the vnode lock held simultaneously by the caller into procfs. Reported by: kuriyama Approved by: des
* Minor whitespace and style issues.des2003-12-077-21/+16
|
* Remove debug printf().mux2003-10-191-1/+0
|
* Introduce a uiomove_frombuf helper routine that handles computing andnectar2003-10-023-45/+9
| | | | | | | | | | | | | | | validating the offset within a given memory buffer before handing the real work off to uiomove(9). Use uiomove_frombuf in procfs to correct several issues with integer arithmetic that could result in underflows/overflows. As a side-effect, the code is significantly simplified. Add additional sanity checks when computing a memory allocation size in pfs_read. Submitted by: rwatson (original uiomove_frombuf -- bugs are mine :-) Reported by: Joost Pol <joost@pine.nl> (integer underflows/overflows)
* Add a new column to the procfs map to hold the name of the mappedrwatson2003-09-291-2/+16
| | | | | | | | | file for vnode mappings. Note that this uses vn_fullpath() and may be somewhat unreliable, although not too unreliable for shared libraries. For non-vnode mappings, just print "-" for the field. Obtained from: TrustedBSD Projects Sponsored by: DARPA, AFRL, Network Associates Laboratories
* Add p_candebug() check to access a process map file in procfs; limitrwatson2003-08-141-0/+6
| | | | | | | access to map information for processes that you wouldn't otherwise have debug rights on. Tested by: bms
* Rename P_THREADED to P_SA. P_SA means a process is using schedulerdavidxu2003-06-151-1/+1
| | | | activations.
* Clean up proc locking in procfs: make sure the proc lock is held beforerwatson2003-05-053-5/+12
| | | | | | | | | | | entering sys_process.c debugging primitives, or we violate assertions. Also, be more careful about releasing the process lock around calls to uiomove() which may sleep waiting for paging machinations or related notions. We may want to defer the uiomove() in at least one case, but jhb will look into that at a later date. Reported by: Philippe Charnier <charnier@xp11.frmug.org> Reviewed by: jhb
* Instead of recording the Unix time in a process when it starts, record thedes2003-05-011-4/+6
| | | | | | | uptime. Where necessary, convert it back to Unix time by adding boottime to it. This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process.
* - Always call faultin() in _PHOLD() if PS_INMEM is clear. This closes ajhb2003-04-221-2/+0
| | | | | | | | | | | | | | | | | | | | | | race where a thread could assume that a process was swapped in by PHOLD() when it actually wasn't fully swapped in yet. - In faultin(), always msleep() if PS_SWAPPINGIN is set instead of doing this check after bumping p_lock in the PS_INMEM == 0 case. Also, sched_lock is only needed for setting and clearning swapping PS_* flags and the swap thread inhibitor. - Don't set and clear the thread swap inhibitor in the same loops as the pmap_swapin/out_thread() since we have to do it under sched_lock. Instead, mimic the treatment of the PS_INMEM flag and use separate loops to set the inhibitors when clearing PS_INMEM and clear the inhibitors when setting PS_INMEM. - swapout() now returns with the proc lock held as it holds the lock while adjusting the swapping-related PS_* flags so that the proc lock can be used to test those flags. - Only use the proc lock to check the swapping-related PS_* flags in several places. - faultin() no longer requires sched_lock to be held by callers. - Rename PS_SWAPPING to PS_SWAPPINGOUT to be less ambiguous now that we have PS_SWAPPINGIN.
* - Use a local variable to close a minor race when determining if the wmesgjhb2003-04-171-9/+15
| | | | | | printed out needs a prefix such as when a thread is blocked on a lock. - Use another local variable to close another race for the td_wmesg and td_wchan members of struct thread.
* Protect p_flag with the proc lock. The sched_lock is not needed to turnjhb2003-04-171-2/+2
| | | | off P_STOPPED_SIG in p_flag.
* - P_SHOULDSTOP just needs proc lock now, so don't acquire sched_lock unlessjhb2003-04-171-6/+4
| | | | | it is needed. - Add a proc lock assertion.
* Add a proc lock assertion and move another assertion up to the top of thejhb2003-04-171-2/+4
| | | | function.
* wakeup(9) and msleep(9) take void * arguments, not caddr_t.des2003-03-021-3/+3
|
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-1/+1
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Slightly change the semantics of vnode labels for MAC: rather thanrwatson2002-10-263-72/+0
| | | | | | | | | | | | | | | | | | | | | "refreshing" the label on the vnode before use, just get the label right from inception. For single-label file systems, set the label in the generic VFS getnewvnode() code; for multi-label file systems, leave the labeling up to the file system. With UFS1/2, this means reading the extended attribute during vfs_vget() as the inode is pulled off disk, rather than hitting the extended attributes frequently during operations later, improving performance. This also corrects sematics for shared vnode locks, which were not previously present in the system. This chances the cache coherrency properties WRT out-of-band access to label data, but in an acceptable form. With UFS1, there is a small race condition during automatic extended attribute start -- this is not present with UFS2, and occurs because EAs aren't available at vnode inception. We'll introduce a work around for this shortly. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Remove even more '&' from pointers to functions.phk2002-10-201-26/+26
| | | | Spotted by: FlexeLint
* Back our kernel support for reliable signal queues.jmallett2002-10-011-2/+1
| | | | Requested by: rwatson, phk, and many others
* First half of implementation of ksiginfo, signal queues, and such. Thisjmallett2002-09-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | gets signals operating based on a TailQ, and is good enough to run X11, GNOME, and do job control. There are some intricate parts which could be more refined to match the sigset_t versions, but those require further evaluation of directions in which our signal system can expand and contract to fit our needs. After this has been in the tree for a while, I will make in kernel API changes, most notably to trapsignal(9) and sendsig(9), to use ksiginfo more robustly, such that we can actually pass information with our (queued) signals to the userland. That will also result in using a struct ksiginfo pointer, rather than a signal number, in a lot of kern_sig.c, to refer to an individual pending signal queue member, but right now there is no defined behaviour for such. CODAFS is unfinished in this regard because the logic is unclear in some places. Sponsored by: New Gold Technology Reviewed by: bde, tjr, jake [an older version, logic similar]
* Use the fields in the sysentvec and in the vm map header in place of thejake2002-09-211-1/+3
| | | | | | | | constants VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK and PS_STRINGS. This is mainly so that they can be variable even for the native abi, based on different machine types. Get stack protections from the sysentvec too. This makes it trivial to map the stack non-executable for certain abis, on machines that support it.
* Completely redo thread states.julian2002-09-112-3/+2
| | | | Reviewed by: davidxu@freebsd.org
* s/SGNL/SIG/davidxu2002-09-052-3/+3
| | | | | | | | | | 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)
* Fixed 64bit big endian bugs relating to abuse of ioctl argument passing.jake2002-08-151-4/+4
| | | | This makes truss work on sparc64.
* Introduce support for Mandatory Access Control and extensiblerwatson2002-08-013-0/+72
| | | | | | | | | | | kernel access control. Modify procfs so that (when mounted multilabel) it exports process MAC labels as the vnode labels of procfs vnodes associated with processes. Approved by: des Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Create a new thread state to describe threads that would be ready to runjulian2002-07-291-0/+2
| | | | | | | | | | | except for the fact tha they are presently swapped out. Also add a process flag to indicate that the process has started the struggle to swap back in. This will be needed for the case where multiple threads start the swapin action top a collision. Also add code to stop a process fropm being swapped out if one of the threads in this process is actually off running on another CPU.. that might hurt... Submitted by: Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
* Part 1 of KSE-IIIjulian2002-06-295-12/+15
| | | | | | | | | | | | | 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..
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-197-8/+10
| | | | | | | 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.
* Include <sys/systm.h> for (at least) the definition of atomic functionsbde2002-04-211-0/+1
| | | | | which are sometimes used by the macros in <sys/mutex.h>; don't depend on not-quite-necessary namespace pollution in <sys/mutex.h>.
* Spelling fix for comment.rwatson2002-04-201-1/+1
|
* - Change procfs_control()'s first argument to be a thread pointer insteadjhb2002-04-131-47/+32
| | | | | | | | | | | of a process pointer. - Move the p_candebug() at the start of procfs_control() a bit to make locking feasible. We still perform the access check before doing anything, we just now perform it after acquiring locks. - Don't lock the sched_lock for TRACE_WAIT_P() and when checking to see if p_stat is SSTOP. We lock the process while setting p_stat to SSTOP so locking the process is sufficient to do a read to see if p_stat is SSTOP or not.
* Lock the target process for p_candebug().jhb2002-04-131-3/+4
|
* Lock the target process in procfs_doproc*regs() for p_candebug and whilejhb2002-04-133-9/+23
| | | | reading/writing the registers.
* - p_cansee() needs the target process locked.jhb2002-04-131-18/+17
| | | | - We need the proc lock held for more of procfs_doprocstatus().
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Protect proc struct (p_args and p_comm) when doing procfs IO that pullsalfred2002-03-291-11/+17
| | | | | | data from it. Submitted by: Jonathan Mini <mini@haikugeek.com>
* Remove __P.alfred2002-03-191-1/+1
|
* Lock struct pgrp, session and sigio.tanimura2002-02-232-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Paranoia: if the process is setugid, set all sensitive files mode 0.des2002-02-181-1/+3
|
* FIxed the following style bugs:bde2002-02-162-10/+16
| | | | | | | | | | - clobbering of jsp's $Id$ by FreeBSD's old $Id$. - long lines in recent KSE changes (procfs_ctl.c). - other style bugs in KSE changes (most related to an shadowed variable in procfs_status.c -- the td in the outer scope is obfuscated by PFS_FILL_ARGS). Approved by: des
* FIxed the following style bugs:bde2002-02-163-11/+21
| | | | | | | - clobbering of jsp's $Id$ by FreeBSD's old $Id$. - lost Berkeley id in procfs_dbregs.c - long lines in recent KSE changes. - various gratuitous differences between procfs_*regs.c.
* Fixed missing PHOLD()/PRELE().bde2002-02-161-0/+2
| | | | | Obtained from: procfs_dbregs.c Approved by: des
* Pre-KSE/M3 commit.julian2002-02-076-14/+19
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
OpenPOWER on IntegriCloud