freebsd-skq/lib/libprocstat
cem f96df638b8 Detect badly behaved coredump note helpers
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
2015-09-03 20:32:10 +00:00
..
zfs Add META_MODE support. 2015-06-13 19:20:56 +00:00
cd9660.c
common_kvm.c
common_kvm.h - Trim an unused and bogus Makefile for mount_smbfs. 2013-06-28 21:00:08 +00:00
core.c Embed revision id in the library. 2013-04-21 17:10:10 +00:00
core.h Add procstat_getauxv function to retrieve a process auxiliary vector. 2013-04-20 08:10:47 +00:00
libprocstat_internal.h Extend libprocstat with functions to retrieve process command line 2013-04-20 08:07:04 +00:00
libprocstat.3 Create links to the libprocstat man pages for all of the libprocstat functions so they can be looked up by name 2015-05-21 03:32:44 +00:00
libprocstat.c Detect badly behaved coredump note helpers 2015-09-03 20:32:10 +00:00
libprocstat.h Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
Makefile Create links to the libprocstat man pages for all of the libprocstat functions so they can be looked up by name 2015-05-21 03:32:44 +00:00
Makefile.depend Add META_MODE support. 2015-06-13 19:20:56 +00:00
msdosfs.c
smbfs.c
Symbol.map Similar to 233760 and 236717, export some more useful info about the 2013-05-03 21:11:57 +00:00
udf.c Do not include buf.h. 2014-11-23 10:26:28 +00:00
Versions.def
zfs.c