opnsense-src/lib/libutil
Conrad Meyer 14bdbaf2e4 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
..
tests On arm64 disable three tests that hang or panic 2015-08-17 23:19:36 +00:00
_secure_path.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
_secure_path.c Grammar in a comment. 2004-12-18 12:31:12 +00:00
auth.c Finally nuke auth.conf, nine years after it was deprecated. The only 2012-06-12 17:02:53 +00:00
expand_number.3 Indicate that expand_number is case-insensitive. 2013-11-12 00:56:22 +00:00
expand_number.c The round of expand_number() cleanups. 2013-08-30 11:21:52 +00:00
flopen.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
flopen.c Revert (once again, and hopefully for the last time) to flock(2) locks. 2009-06-06 18:47:03 +00:00
fparseln.3 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
fparseln.c fparseln(3): Update from NetBSD sources. 2014-07-23 14:57:15 +00:00
gr_util.c When passwd or group information is changed (by pw, vipw, chpass, ...) 2015-07-02 17:30:59 +00:00
hexdump.3 Add support for reading MAM attributes to camcontrol(8) and libcam(3). 2015-06-09 21:39:38 +00:00
hexdump.c Merge hexdump(9) to userland as hexdump(3) in libutil. I'm tired of doing 2008-07-01 22:30:57 +00:00
humanize_number.3 don't assert on bad args, instead return an error.. 2013-10-07 22:22:57 +00:00
humanize_number.c don't assert on bad args, instead return an error.. 2013-10-07 22:22:57 +00:00
kinfo_getallproc.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getallproc.c - Commit work from libprocstat project. These patches add support for runtime 2011-05-12 10:11:39 +00:00
kinfo_getfile.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getfile.c Detect badly behaved coredump note helpers 2015-09-03 20:32:10 +00:00
kinfo_getproc.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getproc.c - Commit work from libprocstat project. These patches add support for runtime 2011-05-12 10:11:39 +00:00
kinfo_getvmmap.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getvmmap.c Include param.h instead of types.h when using user.h. Otherwise there is 2008-12-27 11:12:23 +00:00
kinfo_getvmobject.3 Export a list of VM objects in the system via a sysctl. The list can be 2015-05-27 18:11:05 +00:00
kinfo_getvmobject.c Export a list of VM objects in the system via a sysctl. The list can be 2015-05-27 18:11:05 +00:00
kld.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
kld.c UTFize my name. 2010-08-22 11:48:32 +00:00
libutil.h revert r283969,283970 not needed anymore after r283981 2015-06-04 08:00:11 +00:00
login.conf.5 Mention in login.conf.5 which fields may be infinite and how to specifify infinity. 2013-10-27 04:59:18 +00:00
login_auth.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
login_auth.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
login_cap.3 Remove trailing whitespace per mdoc lint warning 2012-03-29 05:02:12 +00:00
login_cap.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
login_cap.h Add two new system calls, setloginclass(2) and getloginclass(2). This makes 2011-03-05 12:40:35 +00:00
login_class.3 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
login_class.c Fix a clang 3.5 warning about abs(3) being given an argument of type 2014-10-29 20:18:37 +00:00
login_crypt.c
login_ok.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
login_ok.c Fix typo in comment. 2006-01-16 00:28:11 +00:00
login_times.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
login_times.c Fix -Wunsequenced warning 2013-06-29 15:52:48 +00:00
login_tty.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
login_tty.c Fix a regression that was introduced in r191882. 2010-01-17 17:52:35 +00:00
Makefile Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
pidfile.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
pidfile.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
property.3 Finally nuke auth.conf, nine years after it was deprecated. The only 2012-06-12 17:02:53 +00:00
property.c Restore the previous state after a FILL operation in properties_read() 2005-11-28 16:30:16 +00:00
pty.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
pty.c Add missing header. 2008-11-04 13:50:50 +00:00
pw_util.3 Bump .Dd due to changes made in r285050 and r285053 2015-07-02 19:41:08 +00:00
pw_util.c When passwd or group information is changed (by pw, vipw, chpass, ...) 2015-07-02 17:30:59 +00:00
quotafile.3 mdoc: improvements to SEE ALSO. 2014-12-27 08:31:52 +00:00
quotafile.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
realhostname.3 Remove unnecessary includes from these libutil man pages. 2012-01-16 21:25:41 +00:00
realhostname.c Fixing !INET6 builds. 2008-11-25 02:15:09 +00:00
realhostname_sa.3 mdoc: drop redundant .Pp and .LP calls 2010-10-08 12:40:16 +00:00
stub.c
trimdomain.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
trimdomain.c When removing the local domain, only do so when the result will be a 2005-10-05 04:42:20 +00:00
uucplock.3 mdoc: order prologue macros consistently by Dd/Dt/Os 2010-04-14 19:08:06 +00:00
uucplock.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00