summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
Commit message (Collapse)AuthorAgeFilesLines
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-1/+1
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-102-2/+2
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* - Move all of the PS_ flags into either p_flag or td_flags.jeff2007-09-171-5/+3
| | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith)
* Eliminate now-unused SUSER_ALLOWJAIL arguments to priv_check_cred(); inrwatson2007-06-121-2/+1
| | | | | | | | | | | | | | | some cases, move to priv_check() if it was an operation on a thread and no other flags were present. Eliminate caller-side jail exception checking (also now-unused); jail privilege exception code now goes solely in kern_jail.c. We can't yet eliminate suser() due to some cases in the KAME code where a privilege check is performed and then used in many different deferred paths. Do, however, move those prototypes to priv.h. Reviewed by: csjp Obtained from: TrustedBSD Project
* rufetch and calcru sometimes should be called atomically together.attilio2007-06-091-1/+2
| | | | | | | | | | This patch fixes places where they should be called atomically changing their locking requirements (both assume per-proc spinlock held) and introducing rufetchcalc which wrappers both calls to be performed in atomic way. Reviewed by: jeff Approved by: jeff (mentor)
* Commit 14/14 of sched_lock decomposition.jeff2007-06-053-8/+8
| | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* The process lock is held when procfs_ioctl() is called. Assert that thisdes2007-05-011-2/+8
| | | | | is so, and PHOLD the process while sleeping since msleep() will release the lock.
* Add synchronization. Eliminate the acquisition and release of Giant.alc2007-04-231-23/+47
| | | | Reviewed by: tegge
* Instead of stating GIANT_REQUIRED, just acquire and release Giant wheredes2007-04-151-2/+5
| | | | | needed. This does not make a difference now, but will when procfs is marked MPSAFE.
* Fix the same bug as in procfs_doproc{,db}regs(): check that uio_offset isdes2007-04-151-1/+3
| | | | | | 0 upon entry, and don't reset it before returning. MFC after: 3 weeks
* Don't reset uio_offset to 0 before returning. Instead, refuse to servicedes2007-04-152-3/+7
| | | | | | | requests where uio_offset is not 0 to begin with. This fixes a long- standing bug where e.g. 'cat /proc/$$/regs' would loop forever. MFC after: 3 weeks
* Add a pn_destroy field to pfs_node. This field points to a destructordes2007-03-121-15/+15
| | | | | | | | | | | | | function which is called from pfs_destroy() before the node is reclaimed. Modify pfs_create_{dir,file,link}() to accept a pointer to a destructor function in addition to the usual attr / fill / vis pointers. This breaks both the programming and binary interfaces between pseudofs and its consumers. It is believed that there are no pseudofs consumers outside the source tree, so that the impact of this change is minimal. Submitted by: Aniruddha Bohra <bohra@cs.rutgers.edu>
* Do allow PIOCSFL in jail for setguid processes; this is more consistentrwatson2007-02-191-4/+2
| | | | | with other debugging checks elsewhere. XXX comment on the fact that p_candebug() is not being used here remains.
* Fix the race of dereferencing /proc/<pid>/file with execve(2) by cachingkib2007-02-071-4/+12
| | | | | | | | | the value of p_textvp. This way, we always unlock the locked vnode. While there, vhold() the vnode around the vn_lock(). Reported and tested by: Guy Helmer (ghelmer palisadesys com) Approved by: des (procfs maintainer) MFC after: 1 week
* Threading cleanup.. part 2 of several.julian2006-12-061-10/+3
| | | | | | | | | | | | | | | | | | | | | | Make part of John Birrell's KSE patch permanent.. Specifically, remove: Any reference of the ksegrp structure. This feature was never fully utilised and made things overly complicated. All code in the scheduler that tried to make threaded programs fair to unthreaded programs. Libpthread processes will already do this to some extent and libthr processes already disable it. Also: Since this makes such a big change to the scheduler(s), take the opportunity to rename some structures and elements that had to be moved anyhow. This makes the code a lot more readable. The ULE scheduler compiles again but I have no idea if it works. The 4bsd scheduler still reqires a little cleaning and some functions that now do ALMOST nothing will go away, but I thought I'd do that as a separate commit. Tested by David Xu, and Dan Eischen using libthr and libpthread.
* Wake up PIOCWAIT handler on the process exit in addition to the stopkib2006-11-171-2/+2
| | | | | | | | | | | events. &p->p_stype is explicitely woken up on process exit for us. Now, truss /nonexistent exits with error instead of waiting until killed by signal. Reported by: Nikos Vassiliadis nvass at teledomenet gr Reviewed by: jhb MFC after: 1 week
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-2/+14
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* Make KSE a kernel option, turned on by default in all GENERICjb2006-10-261-0/+10
| | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@
* Fix our ioctl(2) implementation when the argument is "int". Newru2006-09-271-4/+27
| | | | | | | | | | | | | ioctls passing integer arguments should use the _IOWINT() macro. This fixes a lot of ioctl's not working on sparc64, most notable being keyboard/syscons ioctls. Full ABI compatibility is provided, with the bonus of fixing the handling of old ioctls on sparc64. Reviewed by: bde (with contributions) Tested by: emax, marius MFC after: 1 week
* Upon further review, DES prefers this change over that in revision 1.13ghelmer2006-06-051-6/+4
| | | | | | | to resolve the directory access problem for processes with P_SUGID flag set. Suggested by: des
* Revision 1.4 set access for all sensitive files in /proc/<PID> to mode 0ghelmer2006-05-241-3/+6
| | | | | | | | | | if a process's uid or gid has changed, but the /proc/<PID> directory itself was also set to mode 0. Assuming this doesn't open any security holes, open access to the /proc/<PID> directory for users other than root to read or search the directory. Reviewed by: des (back in February) MFC after: 3 weeks
* Hold the proc lock while calling proc_sstep() since the function assertsjhb2006-02-221-2/+1
| | | | | | | it and remove a PRELE() that didn't have a matching PHOLD(). The calling code already has a PHOLD anyway. MFC after: 1 week
* Make tv_sec a time_t on all platforms but alpha. Brings us more in line withtrhodes2005-12-241-4/+4
| | | | | | | | | POSIX. This also makes the struct correct we ever implement an i386-time64 architecture. Not that we need too. Reviewed by: imp, brooks Approved by: njl (acpica), des (no objects, touches procfs) Tested with: make universe
* 1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, mostdavidxu2005-10-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changes in MD code are trivial, before this change, trapsignal and sendsig use discrete parameters, now they uses member fields of ksiginfo_t structure. For sendsig, this change allows us to pass POSIX realtime signal value to user code. 2. Remove cpu_thread_siginfo, it is no longer needed because we now always generate ksiginfo_t data and feed it to libpthread. 3. Add p_sigqueue to proc structure to hold shared signals which were blocked by all threads in the proc. 4. Add td_sigqueue to thread structure to hold all signals delivered to thread. 5. i386 and amd64 now return POSIX standard si_code, other arches will be fixed. 6. In this sigqueue implementation, pending signal set is kept as before, an extra siginfo list holds additional siginfo_t data for signals. kernel code uses psignal() still behavior as before, it won't be failed even under memory pressure, only exception is when deleting a signal, we should call sigqueue_delete to remove signal from sigqueue but not SIGDELSET. Current there is no kernel code will deliver a signal with additional data, so kernel should be as stable as before, a ksiginfo can carry more information, for example, allow signal to be delivered but throw away siginfo data if memory is not enough. SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can not be caught or masked. The sigqueue() syscall allows user code to queue a signal to target process, if resource is unavailable, EAGAIN will be returned as specification said. Just before thread exits, signal queue memory will be freed by sigqueue_flush. Current, all signals are allowed to be queued, not only realtime signals. Earlier patch reviewed by: jhb, deischen Tested on: i386, amd64
* Jumbo-commit to enhance 32 bit application support on 64 bit kernels.peter2005-06-305-10/+199
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Conditionally weaken sys_generic.c rev 1.136 to allow certain dubiouspeter2005-06-301-0/+14
| | | | | | | | | | | | | ioctl numbers in backwards compatability mode. eg: an IOC_IN ioctl with a size of zero. Traditionally this was what you did before IOC_VOID existed, and we had some established users of this in the tree, namely procfs. Certain 3rd party drivers with binary userland components also have this too. This is necessary to have 4.x and 5.x binaries use these ioctl's. We found this at work when trying to run 4.x binaries. Approved by: re
* Don't export major,minor, instead export tty name.phk2005-03-151-3/+3
|
* /* -> /*- 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.
OpenPOWER on IntegriCloud