summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
* Look for zombie process only if we were given process id.pjd2012-11-251-5/+6
| | | | | | Reviewed by: kib MFC after: 2 weeks X-MFC-after-or-with: 243142
* In pget(9), if PGET_NOTWEXIT flag is not specified, also search thekib2012-11-161-21/+46
| | | | | | | | | | | | zombie list for the pid. This allows several kern.proc sysctls to report useful information for zombies. Hold the allproc_lock around all searches instead of relocking it. Remove private pfind_locked() from the new nfs client code. Requested and reviewed by: pjd Tested by: pho MFC after: 3 weeks
* enterpgrp: get rid of pgrp2 variable and use KASSERT directly on pgfind result.mjg2012-11-131-5/+1
| | | | | | | pgrp2 was used only for debugging, but pgrp2 = pgfind(..) was present in compiled code even for kernels without INVARIANTS Approved by: trasz (mentor) MFC after: 1 week
* Remove the support for using non-mpsafe filesystem modules.kib2012-10-221-9/+2
| | | | | | | | | | | | In particular, do not lock Giant conditionally when calling into the filesystem module, remove the VFS_LOCK_GIANT() and related macros. Stop handling buffers belonging to non-mpsafe filesystems. The VFS_VERSION is bumped to indicate the interface change which does not result in the interface signatures changes. Conducted and reviewed by: attilio Tested by: pho
* Don't include opt_ddb.h & <ddb/ddb.h> twice.obrien2012-08-151-2/+0
|
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonkib2012-08-051-0/+1
| | | | | | | | | | | | | to pull vm_param.h was removed. Other big dependency of vm_page.h on vm_param.h are PA_LOCK* definitions, which are only needed for in-kernel code, because modules use KBI-safe functions to lock the pages. Stop including vm_param.h into vm_page.h. Include vm_param.h explicitely for the kernel code which needs it. Suggested and reviewed by: alc MFC after: 2 weeks
* - Add support for displaying process stack memory regions.pgj2012-07-161-0/+4
| | | | | Approved by: rwatson MFC after: 3 days
* Fix ki_cow for compat32 binaries.kib2012-05-271-0/+1
| | | | MFC after: 3 days
* Calculate the count of per-process cow faults. Export the count tokib2012-05-231-0/+4
| | | | | | | userspace using the obscure spare int field in struct kinfo_proc. Submitted by: Andrey Zonov <andrey zonov org> MFC after: 1 week
* Allow for the process information sysctls to accept a thread id in additionkib2012-04-231-1/+30
| | | | | | | | | | | | | to the process id. It follows the ptrace(2) interface and allows debugging libraries to use thread ids directly, without slow and verbose conversion of thread id into pid. The PGET_NOTID flag is provided to allow a specific sysctl to disallow this behaviour. All current callers of pget(9) have useful semantic to operate on tid and do not need this flag. Reviewed by: jhb, trocini MFC after: 1 week
* Add a sysctl to set and retrieve binary osreldate of another process.trociny2012-03-231-0/+50
| | | | | | Suggested by: kib Reviewed by: kib MFC after: 2 weeks
* Make kern.proc.umask sysctl readonly.trociny2012-03-031-21/+4
| | | | | Requested by: src MFC after: 1 week
* Add sysctl to retrieve or set umask of another process.trociny2012-02-261-0/+48
| | | | | | | Submitted by: Dmitry Banschikov <me ubique spb ru> Discussed with: kib, rwatson Reviewed by: kib MFC after: 2 weeks
* Fix CTL flags in the declarations of KERN_PROC_ENV, AUXV andtrociny2012-01-251-8/+6
| | | | | | PS_STRINGS sysctls: they are read only. MFC after: 1 week
* Change kern.proc.rlimit sysctl to:trociny2012-01-221-16/+40
| | | | | | | | | | | | | - retrive only one, specified limit for a process, not the whole array, as it was previously (the sysctl has been added recently and has not been backported to stable yet, so this change is ok); - allow to set a resource limit for another process. Submitted by: Andrey Zonov <andrey at zonov.org> Discussed with: kib Reviewed by: kib MFC after: 2 weeks
* Abrogate nchr argument in proc_getargv() and proc_getenvv(): we always wanttrociny2012-01-151-13/+12
| | | | | | | | | | | | | | | to read strings completely to know the actual size. As a side effect it fixes the issue with kern.proc.args and kern.proc.env sysctls, which didn't return the size of available data when calling sysctl(3) with the NULL argument for oldp. Note, in get_ps_strings(), which does actual work for proc_getargv() and proc_getenvv(), we still have a safety limit on the size of data read in case of a corrupted procces stack. Suggested by: kib MFC after: 3 days
* Fix style and white spaces.trociny2011-12-171-14/+14
| | | | MFC after: 1 week
* On start most of sysctl_kern_proc functions use the same pattern:trociny2011-12-171-112/+80
| | | | | | | | | | | | | locate a process calling pfind() and do some additional checks like p_candebug(). To reduce this code duplication a new function pget() is introduced and used. As the function may be useful not only in kern_proc.c it is in the kernel name space. Suggested by: kib Reviewed by: kib MFC after: 2 weeks
* Really protect kern.proc.ps_strings sysctls with p_candebug(). Thistrociny2011-12-061-1/+1
| | | | | | | was intended to be in r228288. Spotted by: many MFC after: 1 week
* Protect kern.proc.auxv and kern.proc.ps_strings sysctls with p_candebug().trociny2011-12-051-2/+4
| | | | | | | | | | | | | | | | | | Citing jilles: If we are ever going to do ASLR, the AUXV information tells an attacker where the stack, executable and RTLD are located, which defeats much of the point of randomizing the addresses in the first place. Given that the AUXV information seems to be used by debuggers only anyway, I think it would be good to move it to p_candebug() now. The full virtual memory maps (KERN_PROC_VMMAP, procstat -v) are already under p_candebug(). Suggested by: jilles Discussed with: rwatson MFC after: 1 week
* In sysctl_kern_proc_ps_strings() there is no much sense in checkingtrociny2011-12-041-8/+0
| | | | | | for P_WEXIT and P_SYSTEM flags. Reviewed by: kib
* Add sysctl to retrieve ps_strings structure location of another process.trociny2011-11-271-0/+57
| | | | | Suggested by: kib Reviewed by: kib
* In sysctl_kern_proc_auxv the process was released too early: we stilltrociny2011-11-271-5/+7
| | | | | | need to hold it when checking process sv_flags. MFC after: 2 weeks
* Add sysctl to get process resource limits.trociny2011-11-241-0/+46
| | | | | Reviewed by: kib MFC after: 2 weeks
* Fix build without INVARIANTS.trociny2011-11-231-0/+2
| | | | Discussed with: kib
* Add new sysctls, KERN_PROC_ENV and KERN_PROC_AUXV, to returntrociny2011-11-221-5/+402
| | | | | | | | | | | | | | | | environment strings and ELF auxiliary vectors from a process stack. Make sysctl_kern_proc_args to read not cached arguments from the process stack. Export proc_getargv() and proc_getenvv() so they can be reused by procfs and linprocfs. Suggested by: kib Reviewed by: kib Discussed with: kib, rwatson, jilles Tested by: pho MFC after: 2 weeks
* Remove no more relevant XXXRW comments since accessing the vmspace is nowpluknet2011-11-211-2/+2
| | | | | | properly done with the acquired vmspace reference. Pointed out by: kib
* Use the acquired reference to the vmspace instead of direct dereferencingpluknet2011-11-211-1/+1
| | | | of p->p_vmspace like it is done in sysctl_kern_proc_vmmap().
* Add KVME_FLAG_SUPER and use it in sysctl_kern_proc_vmmap for markingtrociny2011-11-071-2/+11
| | | | | | | entries with superpages. Submitted by: Mel Flynn <mel.flynn+fbsd.hackers@mailing.thruhere.net> Reviewed by: alc, rwatson
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-2/+2
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* One of the general principles of the sysctl(3) API is that a user canjhb2011-08-181-1/+1
| | | | | | | | | | query the needed size for a sysctl result by passing in a NULL old pointer and a valid oldsize. The kern.proc.args sysctl handler broke this assumption by not calling SYSCTL_OUT() if the old pointer was NULL. Approved by: re (kib) MFC after: 3 days
* Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.bz2011-07-181-2/+2
| | | | | | | | | Provide backward compatibility defines under BURN_BRIDGES. Suggested by: jhb Reviewed by: emaste Sponsored by: Sandvine Incorporated Approved by: re (kib)
* - Export each thread's individual resource usage in in struct kinfo_proc'sjhb2011-07-181-0/+5
| | | | | | | | | | | | ki_rusage member when KERN_PROC_INC_THREAD is passed to one of the process sysctls. - Correctly account for the current thread's cputime in the thread when doing the runtime fixup in calcru(). - Use TIDs as the key to lookup the previous thread to compute IO stat deltas in IO mode in top when thread display is enabled. Reviewed by: kib Approved by: re (kib)
* - Commit work from libprocstat project. These patches add support for runtimestas2011-05-121-4/+8
| | | | | | | | | | | | | | | | | | | | | | | file and processes information retrieval from the running kernel via sysctl in the form of new library, libprocstat. The library also supports KVM backend for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have been modified to take advantage of the library (as the bonus point the fstat(1) utility no longer need superuser privileges to operate), and the procstat(1) utility is now able to display information from memory dumps as well. The newly introduced fuser(1) utility also uses this library and able to operate via sysctl and kvm backends. The library is by no means complete (e.g. KVM backend is missing vnode name resolution routines, and there're no manpages for the library itself) so I plan to improve it further. I'm commiting it so it will get wider exposure and review. We won't be able to MFC this work as it relies on changes in HEAD, which was introduced some time ago, that break kernel ABI. OTOH we may be able to merge the library with KVM backend if we really need it there. Discussed with: rwatson
* Fix some locking nits with the p_state field of struct proc:jhb2011-03-241-10/+6
| | | | | | | | | | | | | | | | | | - Hold the proc lock while changing the state from PRS_NEW to PRS_NORMAL in fork to honor the locking requirements. While here, expand the scope of the PROC_LOCK() on the new process (p2) to avoid some LORs. Previously the code was locking the new child process (p2) after it had locked the parent process (p1). However, when locking two processes, the safe order is to lock the child first, then the parent. - Fix various places that were checking p_state against PRS_NEW without having the process locked to use PROC_LOCK(). Every place was already locking the process, just after the PRS_NEW check. - Remove or reduce the use of PROC_SLOCK() for places that were checking p_state against PRS_NEW. The PROC_LOCK() alone is sufficient for reading the current state. - Reorder fill_kinfo_proc() slightly so it only acquires PROC_SLOCK() once. MFC after: 1 week
* Export login class information via kinfo and make it possible to viewtrasz2011-03-051-0/+4
| | | | it using "ps -o class".
* Add initial support for Capsicum's Capability Mode to the FreeBSD kernel,rwatson2011-03-011-1/+3
| | | | | | | | | | | | | | | | | | compiled conditionally on options CAPABILITIES: Add a new credential flag, CRED_FLAG_CAPMODE, which indicates that a subject (typically a process) is in capability mode. Add two new system calls, cap_enter(2) and cap_getmode(2), which allow setting and querying (but never clearing) the flag. Export the capability mode flag via process information sysctls. Sponsored by: Google, Inc. Reviewed by: anderson Discussed with: benl, kris, pjd Obtained from: Capsicum Project MFC after: 3 months
* Allow debugger to specify that children of the traced process should bekib2011-01-251-0/+1
| | | | | | | | automatically traced. Extend the ptrace(PL_LWPINFO) to report that child just forked. Reviewed by: davidxu, jhb MFC after: 2 weeks
* Fix some more style(9) issues.brucec2010-11-141-1/+1
|
* Fix style(9) issues from r215281 and r215282.brucec2010-11-141-1/+2
| | | | MFC after: 1 week
* Add some descriptions to sys/kern sysctls.brucec2010-11-141-1/+1
| | | | | | PR: kern/148710 Tested by: Chip Camden <sterling at camdensoftware.com> MFC after: 1 week
* Fix style.trasz2010-11-111-2/+2
| | | | Submitted by: bde
* Remove unneeded conditional.trasz2010-11-111-12/+10
| | | | Discussed with: kib
* Make a thread's address available via the kern proc sysctl, just like theemaste2010-10-081-0/+1
| | | | | | | | process address. Add "tdaddr" keyword to ps(1) to display this thread address. Distilled from Sandvine's patch set by Mark Johnston.
* Add an extra comment to the SDT probes definition. This allows us to getrpaulo2010-08-221-6/+6
| | | | | | | | | use '-' in probe names, matching the probe names in Solaris.[1] Add userland SDT probes definitions to sys/sdt.h. Sponsored by: The FreeBSD Foundation Discussed with: rwaston [1]
* There isn't really a need to hold the ktrace mutex just to read the valuejhb2010-08-191-6/+0
| | | | | | of p_traceflag that is stored in the kinfo_proc structure. It is still racey even with the lock and the code will read a consistent snapshot of the flag without the lock.
* Add the support for reporting the NOCOREDUMP flag fromattilio2010-05-271-0/+4
| | | | | | | | sysctl_kern_proc_vmmap(). Sponsored by: Sandvine Incorporated Reviewed by: kib, emaste MFC after: 1 week
* Fix a mistake in r207603. td_rux.rux_runtime still needs conversion.kib2010-05-051-1/+1
| | | | | | Reported and tested by: nwhitehorn Pointy hat to: kib MFC after: 6 days
* Use td_rux.rux_runtime for ki_runtime instead of redoing calculation.kib2010-05-041-1/+1
| | | | | Submitted by: bde MFC after: 1 week
* Remove caddr_t casts.kib2010-04-291-5/+3
| | | | | Requested by: bde MFC after: 10 days
OpenPOWER on IntegriCloud