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 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 inherently racy.
So:
- Detect badly behaved notes in putnote() and printf a warning as a weak assertion of correct behavior. No need to punish users for long- standing kernel bugs.
- 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().
- 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.
- Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the zero padding.
Sponsored by: EMC / Isilon Storage Division