summaryrefslogtreecommitdiffstats
path: root/lib/libprocstat
Commit message (Collapse)AuthorAgeFilesLines
* Fix core corruption caused by race in note_procstat_vmmapcem2015-10-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix is spiritually similar to r287442 and was discovered thanks to the KASSERT added in that revision. NT_PROCSTAT_VMMAP output length, when packing kinfo structs, is tied to the length of filenames corresponding to vnodes in the process' vm map via vn_fullpath. As vnodes may move during coredump, this is racy. We do not remove the race, only prevent it from causing coredump corruption. - Add a sysctl, kern.coredump_pack_vmmapinfo, to allow users to disable kinfo packing for PROCSTAT_VMMAP notes. This avoids VMMAP corruption and truncation, even if names change, at the cost of up to PATH_MAX bytes per mapped object. The new sysctl is documented in core.5. - Fix note_procstat_vmmap to self-limit in the second pass. This addresses corruption, at the cost of sometimes producing a truncated result. - Fix PROCSTAT_VMMAP consumers libutil (and libprocstat, via copy-paste) to grok the new zero padding. Reported by: pho (https://people.freebsd.org/~pho/stress/log/datamove4-2.txt) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3824
* Detect badly behaved coredump note helperscem2015-09-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Coredump notes depend on being able to invoke dump routines twice; once in a dry-run mode to get the size of the note, and another to actually emit the note to the corefile. When a note helper emits a different length section the second time around than the length it requested the first time, the kernel produces a corrupt coredump. NT_PROCSTAT_FILES output length, when packing kinfo structs, is tied to the length of filenames corresponding to vnodes in the process' fd table via vn_fullpath. As vnodes may move around during dump, this is racy. So: - Detect badly behaved notes in putnote() and pad underfilled notes. - Add a fail point, debug.fail_point.fill_kinfo_vnode__random_path to exercise the NT_PROCSTAT_FILES corruption. It simply picks random lengths to expand or truncate paths to in fo_fill_kinfo_vnode(). - Add a sysctl, kern.coredump_pack_fileinfo, to allow users to disable kinfo packing for PROCSTAT_FILES notes. This should avoid both FILES note corruption and truncation, even if filenames change, at the cost of about 1 kiB in padding bloat per open fd. Document the new sysctl in core.5. - Fix note_procstat_files to self-limit in the 2nd pass. Since sometimes this will result in a short write, pad up to our advertised size. This addresses note corruption, at the risk of sometimes truncating the last several fd info entries. - Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the zero padding. With suggestions from: bjk, jhb, kib, wblock Approved by: markj (mentor) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3548
* Add META_MODE support.sjg2015-06-132-0/+38
|\ | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp
| * dirdeps.mk now sets DEP_RELDIRsjg2015-06-082-4/+0
| |
| * Merge sync of headsjg2015-05-273-29/+58
| |\
| * \ Merge head from 7/28sjg2014-08-193-3/+3
| |\ \
| * | | Updated dependenciessjg2014-05-162-1/+2
| | | |
| * | | Updated dependenciessjg2014-05-101-0/+2
| | | |
| * | | Merge from headsjg2014-05-081-1/+1
| |\ \ \
| * \ \ \ Merge headsjg2014-04-272-2/+3
| |\ \ \ \
| * \ \ \ \ Merge head@256284sjg2013-10-131-10/+14
| |\ \ \ \ \
| * | | | | | Updated dependenciessjg2013-10-131-0/+1
| | | | | | |
| * | | | | | Merge from headsjg2013-09-059-42/+2003
| |\ \ \ \ \ \
| * \ \ \ \ \ \ sync from headsjg2013-04-124-149/+0
| |\ \ \ \ \ \ \
| * | | | | | | | Updated dependenciessjg2013-03-111-0/+1
| | | | | | | | |
| * | | | | | | | Updated dependenciessjg2013-02-162-4/+0
| | | | | | | | |
| * | | | | | | | Updated/new Makefile.dependsjg2012-11-081-0/+3
| | | | | | | | |
| | | | | | | | |
| | \ \ \ \ \ \ \
| | \ \ \ \ \ \ \
| | \ \ \ \ \ \ \
| *---. \ \ \ \ \ \ \ Sync from headsjg2012-11-044-17/+24
| |\ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.marcel2012-08-222-0/+37
| | |_|/ / / / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net>
* | | | | | | | | | | Remove unused variable spotted by clang.araujo2015-06-011-2/+2
| |_|_|_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Differential Revision: D2685 Reviewed by: rodrigc, stas
* | | | | | | | | | Create links to the libprocstat man pages for all of the libprocstat ↵allanjude2015-05-212-26/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions so they can be looked up by name Add a cross refrence to libprocstat in the procstat.1 man page Differential Revision: https://reviews.freebsd.org/D2578 Suggested by: jmg Reviewed by: brueffer Approved by: wblock (mentor) MFC after: 1 week Sponsored by: ScaleEngine Inc.
* | | | | | | | | | Convert libraries to use LIBADDbapt2014-11-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While here reduce a bit overlinking
* | | | | | | | | | Do not include buf.h.glebius2014-11-231-1/+0
| |_|_|_|_|_|_|_|/ |/| | | | | | | |
* | | | | | | | | use .Mt to mark up email addresses consistently (part3)bapt2014-06-231-2/+2
| |_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de>
* | | | | | | | 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
OpenPOWER on IntegriCloud