summaryrefslogtreecommitdiffstats
path: root/lib/libprocstat
Commit message (Collapse)AuthorAgeFilesLines
* Use src.opts.mk in preference to bsd.own.mk except where we need stuffimp2014-05-061-1/+1
| | | | from the latter.
* Update most userspace consumers of capability.h to use capsicum.h instead.rwatson2014-03-161-1/+1
| | | | | | | auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. MFC after: 3 weeks
* When querying a process's umask via sysctl in libprocstat(), don'trwatson2014-03-021-1/+1
| | | | | | | | | print a warning if EPERM is returned as this is an expected failure mode rather than error -- similar to current handling of ESRCH. This makes the output of 'procstat -as' vastly more palatable. MFC after: 3 days Sponsored by: DARPA, AFRL
* MFV r259170:delphij2014-01-011-0/+1
| | | | | | | | | | | | | 4370 avoid transmitting holes during zfs send 4371 DMU code clean up illumos/illumos-gate@43466aae47bfcd2ad9bf501faec8e75c08095e4f NOTE: Make sure the boot code is updated if a zpool upgrade is done on boot zpool. MFC after: 2 weeks
* Handle the cases where NULL is passed as cap_rightsp to thepjd2013-10-091-10/+14
| | | | | | | filestat_new_entry() function. Reported by: Alex Kozlov <spam@rm-rf.kiev.ua> Approved by: re (gjb)
* Change the cap_rights_t type from uint64_t to a structure that we can extendpjd2013-09-052-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation
* - Trim an unused and bogus Makefile for mount_smbfs.davide2013-06-283-0/+3
| | | | | | - Reconnect with some minor modifications, in particular now selsocket() internals are adapted to use sbintime units after recent'ish calloutng switch.
* Borrow the algorithm from kvm_getprocs() to fix procstat_getprocs() tojhb2013-06-111-7/+11
| | | | | | | handle the case where the process tables grows in between the calls to fetch the size and fetch the table. MFC after: 1 week
* Make errbuf optional, so if a caller is not interested in an errortrociny2013-05-081-14/+30
| | | | | | message she can pass NULL (procstat(1) already does this). MFC after: 2 weeks
* Bump date.pluknet2013-05-041-1/+1
|
* Similar to 233760 and 236717, export some more useful info about thejhb2013-05-034-1/+110
| | | | | | | | | | | | | | | kernel-based POSIX semaphore descriptors to userland via procstat(1) and fstat(1): - Change sem file descriptors to track the pathname they are associated with and add a ksem_info() method to copy the path out to a caller-supplied buffer. - Use the fo_stat() method of shared memory objects and ksem_info() to export the path, mode, and value of a semaphore via struct kinfo_file. - Add a struct semstat to the libprocstat(3) interface along with a procstat_get_sem_info() to export the mode and value of a semaphore. - Teach fstat about semaphores and to display their path, mode, and value. MFC after: 2 weeks
* procstat_getpathname: for kvm method, instead of returning the errortrociny2013-05-011-2/+4
| | | | | | | | | that the method is not supported, return an empty string. This looks more handy for callers like procstat(1), which will not abort after the failed call and still output some useful information. MFC after: 3 weeks
* KVM method support for procstat_getgroups, procstat_getumask,trociny2013-05-011-8/+121
| | | | | | procstat_getrlimit, and procstat_getosrel. MFC after: 3 weeks
* Embed revision id in the library.trociny2013-04-211-2/+3
| | | | MFC after: 29 days
* mdoc: end function context properly.joel2013-04-201-1/+1
|
* Bump date.trociny2013-04-201-1/+1
|
* Add procstat_getkstack function to dump kernel stacks of a process.trociny2013-04-204-0/+106
| | | | MFC after: 1 month
* Add procstat_getauxv function to retrieve a process auxiliary vector.trociny2013-04-206-0/+200
| | | | MFC after: 1 month
* Extend libprocstat with functions to retrieve process command linetrociny2013-04-207-0/+413
| | | | | | | | arguments and environment variables. Suggested by: stas Reviewed by: jhb and stas (initial version) MFC after: 1 month
* Add procstat_getosrel function to retrieve a process osrel info.trociny2013-04-206-0/+74
| | | | MFC after: 1 month
* Add procstat_getpathname function to retrieve a process executable.trociny2013-04-204-2/+90
| | | | MFC after: 1 month
* Add procstat_getrlimit function to retrieve a process resource limits info.trociny2013-04-206-0/+94
| | | | MFC after: 1 month
* Add procstat_getumask function to retrieve a process umask.trociny2013-04-206-0/+80
| | | | MFC after: 1 month
* Add procstat_getgroups function to retrieve process groups.trociny2013-04-206-0/+104
| | | | MFC after: 1 month
* Add procstat_getvmmap function to get VM layout of a process.trociny2013-04-204-1/+118
| | | | MFC after: 1 month
* Make libprocstat(3) extract procstat notes from a process core file.trociny2013-04-208-17/+453
| | | | | | | PR: kern/173723 Suggested by: jhb Glanced by: kib MFC after: 1 month
* Garbage collect NWFS and NCP bits which are now completely disconnectedattilio2013-03-091-76/+0
| | | | | | from the tree since few months. This patch is not targeted for MFC.
* Garbage collect NTFS bits which are now completely disconnected fromattilio2013-03-021-71/+0
| | | | | | the tree since few months. This patch is not targeted for MFC.
* Merge Capsicum overhaul:pjd2013-03-022-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Capability is no longer separate descriptor type. Now every descriptor has set of its own capability rights. - The cap_new(2) system call is left, but it is no longer documented and should not be used in new code. - The new syscall cap_rights_limit(2) should be used instead of cap_new(2), which limits capability rights of the given descriptor without creating a new one. - The cap_getrights(2) syscall is renamed to cap_rights_get(2). - If CAP_IOCTL capability right is present we can further reduce allowed ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed ioctls can be retrived with cap_ioctls_get(2) syscall. - If CAP_FCNTL capability right is present we can further reduce fcntls that can be used with the new cap_fcntls_limit(2) syscall and retrive them with cap_fcntls_get(2). - To support ioctl and fcntl white-listing the filedesc structure was heavly modified. - The audit subsystem, kdump and procstat tools were updated to recognize new syscalls. - Capability rights were revised and eventhough I tried hard to provide backward API and ABI compatibility there are some incompatible changes that are described in detail below: CAP_CREATE old behaviour: - Allow for openat(2)+O_CREAT. - Allow for linkat(2). - Allow for symlinkat(2). CAP_CREATE new behaviour: - Allow for openat(2)+O_CREAT. Added CAP_LINKAT: - Allow for linkat(2). ABI: Reuses CAP_RMDIR bit. - Allow to be target for renameat(2). Added CAP_SYMLINKAT: - Allow for symlinkat(2). Removed CAP_DELETE. Old behaviour: - Allow for unlinkat(2) when removing non-directory object. - Allow to be source for renameat(2). Removed CAP_RMDIR. Old behaviour: - Allow for unlinkat(2) when removing directory. Added CAP_RENAMEAT: - Required for source directory for the renameat(2) syscall. Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR): - Allow for unlinkat(2) on any object. - Required if target of renameat(2) exists and will be removed by this call. Removed CAP_MAPEXEC. CAP_MMAP old behaviour: - Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and PROT_WRITE. CAP_MMAP new behaviour: - Allow for mmap(2)+PROT_NONE. Added CAP_MMAP_R: - Allow for mmap(PROT_READ). Added CAP_MMAP_W: - Allow for mmap(PROT_WRITE). Added CAP_MMAP_X: - Allow for mmap(PROT_EXEC). Added CAP_MMAP_RW: - Allow for mmap(PROT_READ | PROT_WRITE). Added CAP_MMAP_RX: - Allow for mmap(PROT_READ | PROT_EXEC). Added CAP_MMAP_WX: - Allow for mmap(PROT_WRITE | PROT_EXEC). Added CAP_MMAP_RWX: - Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC). Renamed CAP_MKDIR to CAP_MKDIRAT. Renamed CAP_MKFIFO to CAP_MKFIFOAT. Renamed CAP_MKNODE to CAP_MKNODEAT. CAP_READ old behaviour: - Allow pread(2). - Disallow read(2), readv(2) (if there is no CAP_SEEK). CAP_READ new behaviour: - Allow read(2), readv(2). - Disallow pread(2) (CAP_SEEK was also required). CAP_WRITE old behaviour: - Allow pwrite(2). - Disallow write(2), writev(2) (if there is no CAP_SEEK). CAP_WRITE new behaviour: - Allow write(2), writev(2). - Disallow pwrite(2) (CAP_SEEK was also required). Added convinient defines: #define CAP_PREAD (CAP_SEEK | CAP_READ) #define CAP_PWRITE (CAP_SEEK | CAP_WRITE) #define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ) #define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE) #define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL) #define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W) #define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X) #define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X) #define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X) #define CAP_RECV CAP_READ #define CAP_SEND CAP_WRITE #define CAP_SOCK_CLIENT \ (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \ CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN) #define CAP_SOCK_SERVER \ (CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \ CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \ CAP_SETSOCKOPT | CAP_SHUTDOWN) Added defines for backward API compatibility: #define CAP_MAPEXEC CAP_MMAP_X #define CAP_DELETE CAP_UNLINKAT #define CAP_MKDIR CAP_MKDIRAT #define CAP_RMDIR CAP_UNLINKAT #define CAP_MKFIFO CAP_MKFIFOAT #define CAP_MKNOD CAP_MKNODAT #define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER) Sponsored by: The FreeBSD Foundation Reviewed by: Christoph Mallon <christoph.mallon@gmx.de> Many aspects discussed with: rwatson, benl, jonathan ABI compatibility discussed with: kib
* Disconnect non-MPSAFE SMBFS from the build in preparation for droppingattilio2012-10-183-3/+0
| | | | | | | | | | | | | GIANT from VFS. In addition, disconnect also netsmb, which is a base requirement for SMBFS. In the while SMBFS regular users can use FUSE interface and smbnetfs port to work with their SMBFS partitions. Also, there are ongoing efforts by vendor to support in-kernel smbfs, so there are good chances that it will get relinked once properly locked. This is not targeted for MFC.
* Disconnect non-MPSAFE NTFS from the build in preparation for droppingattilio2012-10-173-3/+0
| | | | | | | | | | | | | | GIANT from VFS. This code is particulary broken and fragile and other in-kernel implementations around, found in other operating systems, don't really seem clean and solid enough to be imported at all. If someone wants to reconsider in-kernel NTFS implementation for inclusion again, a fair effort for completely fixing and cleaning it up is expected. In the while NTFS regular users can use FUSE interface and ntfs-3g port to work with their NTFS partitions. This is not targeted for MFC.
* Disconnect non-MPSAFE NWFS from the build in preparation for droppingattilio2012-10-173-9/+0
| | | | | | | | | | | | GIANT from VFS. In addition, disconnect also netncp, which is a base requirement for NWFS. In the possibility of a future maintenance of the code and later readd to the FreeBSD base, maybe we should think about a better location for netncp. I'm not entirely sure the / top location is actually right, however I will let network people to comment on that more specifically. This is not targeted for MFC.
* procstat_getprocs: honor kvm_getprocs interface - cnt is signedavg2012-10-061-2/+5
| | | | MFC after: 10 days
* Add __BEGIN_DECLS and __END_DECLS to make libprocstat more C++-friendly.trociny2012-09-041-0/+2
| | | | | Submitted by: Daniel Dettlaff <dmilith gmail com> MFC after: 1 week
* Teach procstat_get_shm_info_kvm() how to fetch the pathname of a SHM filejhb2012-06-071-0/+17
| | | | | | descriptor from a core and set it in fts->fs_path. MFC after: 1 week
* Don't cast inode number or file size down to long or unsigned.gleb2012-05-182-4/+4
| | | | | | | Since ino_t size is about to change to 64-bits, casts to long would truncate 64-bit numbers on 32-bit archs. Sponsored by: Google Summer of Code 2011
* General mdoc(7) and typo fixes.gjb2012-05-111-1/+1
| | | | | | PR: 167734 Submitted by: Nobuyuki Koganemaru (kogane!jp.freebsd.org) MFC after: 3 days
* Export some more useful info about shared memory objects to userlandjhb2012-04-015-1/+101
| | | | | | | | | | | | | | | | | | | via procstat(1) and fstat(1): - Change shm file descriptors to track the pathname they are associated with and add a shm_path() method to copy the path out to a caller-supplied buffer. - Use the fo_stat() method of shared memory objects and shm_path() to export the path, mode, and size of a shared memory object via struct kinfo_file. - Add a struct shmstat to the libprocstat(3) interface along with a procstat_get_shm_info() to export the mode and size of a shared memory object. - Change procstat to always print out the path for a given object if it is valid. - Teach fstat about shared memory objects and to display their path, mode, and size. MFC after: 2 weeks
* Unbreak build.ed2012-02-101-1/+1
| | | | libprocstat still uses __si_namebuf.
* Updates to libprocstat(3) and procstat(1) to allow monitoring Capsicumrwatson2011-08-142-11/+19
| | | | | | | | | | capability mode and capabilities. Right now no attempt is made to unwrap capabilities when operating on a crashdump, so further refinement is required. Approved by: re (bz) Sponsored by: Google Inc
* Mention myself in the AUTHORS section.pluknet2011-07-121-1/+8
| | | | Requested by: stas
* Provide a simple manual page for libprocstat(3).pluknet2011-07-122-2/+255
| | | | Reviewed by: jilles, gjb
* Add missing libkvm and libutil dependencies.pluknet2011-06-251-0/+2
| | | | | | | Now libprocstat takes care of its own dependencies and does not require applications to specify them. Reviewed by: stas, jilles
* libprocstat: For MAP_PRIVATE, do not consider the file open for writing.jilles2011-06-181-2/+4
| | | | | | | | | If a file is mapped with with MAP_PRIVATE, no write permission is required and changes do not end up in the file. Therefore, tools like fuser and fstat should not show the file as open for writing. The protection as displayed by procstat -v still includes write in this case, and shows 'C' for copy-on-write.
* libprocstat: Fix typo in error messages.jilles2011-06-181-5/+5
|
* libprocstat: Remove spaces between function name and open parenthesis.jilles2011-06-181-2/+2
|
* libprocstat: Correct format for size_t (should be %zu, not %zd).jilles2011-06-181-3/+3
|
* Fix clang warnings.benl2011-06-181-2/+2
| | | | Approved by: philip (mentor)
* Release allocated memory in procstat_close().pluknet2011-05-181-0/+1
| | | | Reviewed by: stass
* - Whitespace fix.stas2011-05-151-1/+1
|
OpenPOWER on IntegriCloud