aboutsummaryrefslogtreecommitdiff
path: root/lib/libprocstat
Commit message (Collapse)AuthorAgeFilesLines
* META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host.Bryan Drewery2015-11-251-1/+0
| | | | | | | | | | | This both avoids some dependencies on xinstall.host and allows bootstrapping on older releases to work due to lack of at least 'install -l' support. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291307
* Fix core corruption caused by race in note_procstat_vmmapConrad Meyer2015-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 Notes: svn path=/head/; revision=288944
* Detect badly behaved coredump note helpersConrad Meyer2015-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 Notes: svn path=/head/; revision=287442
* Add META_MODE support.Simon J. Gerraty2015-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 Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-082-4/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-273-29/+58
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=283595
| * \ Merge head from 7/28Simon J. Gerraty2014-08-193-3/+3
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=270164
| * | | Updated dependenciesSimon J. Gerraty2014-05-162-1/+2
| | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | | Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | | Merge from headSimon J. Gerraty2014-05-081-1/+1
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265720
| * \ \ \ Merge headSimon J. Gerraty2014-04-272-2/+3
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265006
| * \ \ \ \ Merge head@256284Simon J. Gerraty2013-10-131-10/+14
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=256424
| * | | | | | Updated dependenciesSimon J. Gerraty2013-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=256419
| * | | | | | Merge from headSimon J. Gerraty2013-09-059-42/+2003
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255263
| * \ \ \ \ \ \ sync from headSimon J. Gerraty2013-04-124-149/+0
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=249429
| * | | | | | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | | | | | Updated dependenciesSimon J. Gerraty2013-02-162-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | | | | | Updated/new Makefile.dependSimon J. Gerraty2012-11-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242788
| * | | | | | | | Sync from headSimon J. Gerraty2012-11-044-17/+24
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-222-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | | | | | Remove unused variable spotted by clang.Marcelo Araujo2015-06-011-2/+2
| |_|_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Differential Revision: D2685 Reviewed by: rodrigc, stas Notes: svn path=/head/; revision=283868
* | | | | | | | | Create links to the libprocstat man pages for all of the libprocstat ↵Allan Jude2015-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. Notes: svn path=/head/; revision=283167
* | | | | | | | | Convert libraries to use LIBADDBaptiste Daroussin2014-11-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While here reduce a bit overlinking Notes: svn path=/head/; revision=275024
* | | | | | | | | Do not include buf.h.Gleb Smirnoff2014-11-231-1/+0
| |_|_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=274913
* | | | | | | | use .Mt to mark up email addresses consistently (part3)Baptiste Daroussin2014-06-231-2/+2
| |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de> Notes: svn path=/head/; revision=267773
* | | | | | | Use src.opts.mk in preference to bsd.own.mk except where we need stuffWarner Losh2014-05-061-1/+1
| |_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the latter. Notes: svn path=/head/; revision=265420
* | | | | | Update most userspace consumers of capability.h to use capsicum.h instead.Robert Watson2014-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 Notes: svn path=/head/; revision=263234
* | | | | | When querying a process's umask via sysctl in libprocstat(), don'tRobert Watson2014-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 Notes: svn path=/head/; revision=262690
* | | | | | MFV r259170:Xin LI2014-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 Notes: svn path=/head/; revision=260150
* | | | | Handle the cases where NULL is passed as cap_rightsp to thePawel Jakub Dawidek2013-10-091-10/+14
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | filestat_new_entry() function. Reported by: Alex Kozlov <spam@rm-rf.kiev.ua> Approved by: re (gjb) Notes: svn path=/head/; revision=256242
* | | | Change the cap_rights_t type from uint64_t to a structure that we can extendPawel Jakub Dawidek2013-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 Notes: svn path=/head/; revision=255219
* | | | - Trim an unused and bogus Makefile for mount_smbfs.Davide Italiano2013-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. Notes: svn path=/head/; revision=252356
* | | | Borrow the algorithm from kvm_getprocs() to fix procstat_getprocs() toJohn Baldwin2013-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 Notes: svn path=/head/; revision=251637
* | | | Make errbuf optional, so if a caller is not interested in an errorMikolaj Golub2013-05-081-14/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | message she can pass NULL (procstat(1) already does this). MFC after: 2 weeks Notes: svn path=/head/; revision=250378
* | | | Bump date.Sergey Kandaurov2013-05-041-1/+1
| | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=250233
* | | | Similar to 233760 and 236717, export some more useful info about theJohn Baldwin2013-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 Notes: svn path=/head/; revision=250223
* | | | procstat_getpathname: for kvm method, instead of returning the errorMikolaj Golub2013-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 Notes: svn path=/head/; revision=250147
* | | | KVM method support for procstat_getgroups, procstat_getumask,Mikolaj Golub2013-05-011-8/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | procstat_getrlimit, and procstat_getosrel. MFC after: 3 weeks Notes: svn path=/head/; revision=250146
* | | | Embed revision id in the library.Mikolaj Golub2013-04-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 29 days Notes: svn path=/head/; revision=249731
* | | | mdoc: end function context properly.Joel Dahl2013-04-201-1/+1
| | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=249711
* | | | Bump date.Mikolaj Golub2013-04-201-1/+1
| | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=249688
* | | | Add procstat_getkstack function to dump kernel stacks of a process.Mikolaj Golub2013-04-204-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249684
* | | | Add procstat_getauxv function to retrieve a process auxiliary vector.Mikolaj Golub2013-04-206-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249681
* | | | Extend libprocstat with functions to retrieve process command lineMikolaj Golub2013-04-207-0/+413
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arguments and environment variables. Suggested by: stas Reviewed by: jhb and stas (initial version) MFC after: 1 month Notes: svn path=/head/; revision=249679
* | | | Add procstat_getosrel function to retrieve a process osrel info.Mikolaj Golub2013-04-206-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249677
* | | | Add procstat_getpathname function to retrieve a process executable.Mikolaj Golub2013-04-204-2/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249676
* | | | Add procstat_getrlimit function to retrieve a process resource limits info.Mikolaj Golub2013-04-206-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249674
* | | | Add procstat_getumask function to retrieve a process umask.Mikolaj Golub2013-04-206-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249672
* | | | Add procstat_getgroups function to retrieve process groups.Mikolaj Golub2013-04-206-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249670
* | | | Add procstat_getvmmap function to get VM layout of a process.Mikolaj Golub2013-04-204-1/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249667