Go to file
John Baldwin 78e6be6e43 MFC 287442,287537,288944:
Fix corruption of coredumps due to procstat notes changing size during
coredump generation.  The changes in r287442 required some reworking
since the 'fo_fill_kinfo' file op does not exist in stable/10.

287442:
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.

287537:
Follow-up to r287442: Move sysctl to compiled-once file

Avoid duplicate sysctl nodes.

288944:
Fix core corruption caused by race in note_procstat_vmmap

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.

Approved by:	re (gjb)
2016-02-10 00:08:51 +00:00
bin MFC r289677: 2016-01-07 00:40:51 +00:00
cddl MFC nv(3) and part of nv(9) to stable/10 2015-12-31 03:28:14 +00:00
contrib MFC r295202: 2016-02-07 22:53:03 +00:00
crypto MFH (r265214, r294333, r294407, r294467): misc prop fixes 2016-02-07 11:38:54 +00:00
etc MFC: r295032 2016-02-01 22:16:41 +00:00
games MFC r283929: Correct grdc(1) 12-hour display between 12:00 and 13:00 2015-09-24 19:37:34 +00:00
gnu Update stable/10 from 10.2-STABLE to 10.3-PRERELEASE, 2016-01-15 00:05:58 +00:00
include MFC r293491: 2016-01-13 01:32:04 +00:00
kerberos5 MFC r284289,r288267: 2015-12-04 18:59:20 +00:00
lib MFC 287442,287537,288944: 2016-02-10 00:08:51 +00:00
libexec MFC r292705: rtld: remove old XXX comment missed in r35529 2016-01-07 14:52:32 +00:00
release Document SA-16:11. 2016-02-01 03:24:38 +00:00
rescue MFC: xz 5.2.2. 2015-12-22 08:03:23 +00:00
sbin MFC r292573 2016-01-18 16:41:26 +00:00
secure MFH (r265214, r294333, r294407, r294467): misc prop fixes 2016-02-07 11:38:54 +00:00
share MFC 287442,287537,288944: 2016-02-10 00:08:51 +00:00
sys MFC 287442,287537,288944: 2016-02-10 00:08:51 +00:00
tests MFC r270228: 2016-01-06 20:50:23 +00:00
tools MFC r294565: sem: Don't free nameinfo that is still in list when open() 2016-01-27 22:56:04 +00:00
usr.bin MFC revisions 294861,294863 2016-02-01 00:58:07 +00:00
usr.sbin MFC: r295074 2016-02-04 15:46:12 +00:00
.arcconfig MFC r265842,r266120,r266121,r266959,r267148,r269985,r281789,r282261,r285064: 2015-12-29 18:22:06 +00:00
.arclint MFC r265842,r266120,r266121,r266959,r267148,r269985,r281789,r282261,r285064: 2015-12-29 18:22:06 +00:00
COPYRIGHT MFC r292983: 2015-12-31 11:23:39 +00:00
LOCKS Explicitly require Security Officer's approval for kernel PRNG bits. 2013-09-17 14:19:05 +00:00
MAINTAINERS MFH (r263160): remove lukemftpd 2014-08-23 15:07:09 +00:00
Makefile MFC r293342: 2016-01-14 21:59:43 +00:00
Makefile.inc1 Make it possible to override NO_INSTALLEXTRAKERNELS. 2016-01-22 18:38:52 +00:00
ObsoleteFiles.inc MFC: xz 5.2.2. 2015-12-22 08:03:23 +00:00
README
UPDATING MFH (r291198, r291260, r291261, r291375, r294325, r294335, r294563) 2016-01-24 22:28:18 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on:
$FreeBSD$

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel, the kernel-modules and the contents of /etc.  The ``world''
target should only be used in cases where the source tree has not
changed from the currently running version.  See:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.

The ``buildkernel'' and ``installkernel'' targets build and install
the kernel and the modules (see below).  Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.

Building a kernel is a somewhat more involved process, documentation
for which can be found at:
   http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
And in the config(8) man page.
Note: If you want to build and install the kernel with the
``buildkernel'' and ``installkernel'' targets, you might need to build
world before.  More information is available in the handbook.

The sample kernel configuration files reside in the sys/<arch>/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel.  The file NOTES contains entries and documentation for all possible
devices, not just those commonly used.  It is the successor of the ancient
LINT file, but in contrast to LINT, it is not buildable as a kernel but a
pure reference and documentation file.


Source Roadmap:
---------------
bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

sys		Kernel sources.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html