freebsd-skq/etc
Konrad Witaszczyk 480f31c214 Add support for encrypted kernel crash dumps.
Changes include modifications in kernel crash dump routines, dumpon(8) and
savecore(8). A new tool called decryptcore(8) was added.

A new DIOCSKERNELDUMP I/O control was added to send a kernel crash dump
configuration in the diocskerneldump_arg structure to the kernel.
The old DIOCSKERNELDUMP I/O control was renamed to DIOCSKERNELDUMP_FREEBSD11 for
backward ABI compatibility.

dumpon(8) generates an one-time random symmetric key and encrypts it using
an RSA public key in capability mode. Currently only AES-256-CBC is supported
but EKCD was designed to implement support for other algorithms in the future.
The public key is chosen using the -k flag. The dumpon rc(8) script can do this
automatically during startup using the dumppubkey rc.conf(5) variable.  Once the
keys are calculated dumpon sends them to the kernel via DIOCSKERNELDUMP I/O
control.

When the kernel receives the DIOCSKERNELDUMP I/O control it generates a random
IV and sets up the key schedule for the specified algorithm. Each time the
kernel tries to write a crash dump to the dump device, the IV is replaced by
a SHA-256 hash of the previous value. This is intended to make a possible
differential cryptanalysis harder since it is possible to write multiple crash
dumps without reboot by repeating the following commands:
# sysctl debug.kdb.enter=1
db> call doadump(0)
db> continue
# savecore

A kernel dump key consists of an algorithm identifier, an IV and an encrypted
symmetric key. The kernel dump key size is included in a kernel dump header.
The size is an unsigned 32-bit integer and it is aligned to a block size.
The header structure has 512 bytes to match the block size so it was required to
make a panic string 4 bytes shorter to add a new field to the header structure.
If the kernel dump key size in the header is nonzero it is assumed that the
kernel dump key is placed after the first header on the dump device and the core
dump is encrypted.

Separate functions were implemented to write the kernel dump header and the
kernel dump key as they need to be unencrypted. The dump_write function encrypts
data if the kernel was compiled with the EKCD option. Encrypted kernel textdumps
are not supported due to the way they are constructed which makes it impossible
to use the CBC mode for encryption. It should be also noted that textdumps don't
contain sensitive data by design as a user decides what information should be
dumped.

savecore(8) writes the kernel dump key to a key.# file if its size in the header
is nonzero. # is the number of the current core dump.

decryptcore(8) decrypts the core dump using a private RSA key and the kernel
dump key. This is performed by a child process in capability mode.
If the decryption was not successful the parent process removes a partially
decrypted core dump.

Description on how to encrypt crash dumps was added to the decryptcore(8),
dumpon(8), rc.conf(5) and savecore(8) manual pages.

EKCD was tested on amd64 using bhyve and i386, mipsel and sparc64 using QEMU.
The feature still has to be tested on arm and arm64 as it wasn't possible to run
FreeBSD due to the problems with QEMU emulation and lack of hardware.

Designed by:	def, pjd
Reviewed by:	cem, oshogbo, pjd
Partial review:	delphij, emaste, jhb, kib
Approved by:	pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4712
2016-12-10 16:20:39 +00:00
..
autofs Fix -media to not mount ufs with "async"; it doesn't make sense when 2016-09-20 04:54:00 +00:00
bluetooth
casper
defaults Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
devd hyperv/vss: Add driver and tools for VSS 2016-11-15 02:36:12 +00:00
etc.aarch64 Update the arm64 ttys file to enable the correct uart based on which device 2015-10-01 09:36:18 +00:00
etc.amd64 Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
etc.arm Enable ttyu1, ttyu2, ttyu3 for arm installations. 2015-06-21 19:50:02 +00:00
etc.i386 Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
etc.mips Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
etc.pc98 Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
etc.powerpc Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
etc.riscv Start support for the RISC-V 64-bit architecture developed by UC Berkeley. 2015-12-11 22:55:23 +00:00
etc.sparc64 Enable all callin ttys if the tty is an available console. 2015-10-20 16:10:46 +00:00
gss
mail Add a ${CP} alias for copying files in the build. 2015-01-16 21:39:08 +00:00
mtree Merge ^/head r308491 through r308841. 2016-11-19 16:05:55 +00:00
newsyslog.conf.d META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
ntp Revert r298887 (spelling fix) and remove $FreeBSD$ because text changes 2016-08-25 02:40:14 +00:00
pam.d Create a rcmds package. 2016-01-21 17:33:31 +00:00
periodic Make 502.pfdenied find blacklistd/* filter names dynamically 2016-10-04 23:12:35 +00:00
pkg Give hint on how to disable the default repository. 2014-03-30 15:24:17 +00:00
rc.d Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
root Step 1 of eliminating the "games" distribution: Move binaries to /usr/bin; 2015-02-12 05:35:00 +00:00
sendmail If world is built with a custom sendmail.cf, use it for the distribution 2015-10-12 21:02:36 +00:00
amd.map
apmd.conf
auto_master Stop appending "noatime" in the autofs -media map, and instead add it 2016-09-20 04:52:01 +00:00
blacklistd.conf Add basic blacklist build support 2016-06-02 19:06:04 +00:00
crontab
csh.cshrc
csh.login
csh.logout
ddb.conf
devd.conf Fix device driver name if devd.conf + move it into appropriate place. 2016-11-06 19:51:01 +00:00
devfs.conf
dhclient.conf
disktab
fbtab
freebsd-update.conf
ftpusers
gettytab
group Fix regression introduced on r293801. 2016-01-27 06:28:56 +00:00
hosts
hosts.allow Allow info to display correctly in for varying tabstop settings 2014-12-24 01:50:44 +00:00
hosts.equiv
hosts.lpd
inetd.conf - Add IPv6 support in quota(1). While rpc.rquotad has supported PF_INET6 2015-07-07 20:15:09 +00:00
libalias.conf
libmap.conf
login.access
login.conf Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
mac.conf
Makefile Fix packaging /usr/share/examples/etc. 2016-10-31 21:11:46 +00:00
Makefile.depend META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
man.alias
master.passwd Capitalize "LDAP" in the description field of the _ypldap entry. 2016-05-10 12:47:36 +00:00
minfree
motd Add the less-ambiguous freebsd-version command. 2014-11-02 19:25:31 +00:00
netconfig
netstart Remove reference to mroute6d in /etc/netstart. 2016-06-25 12:54:27 +00:00
network.subr network.subr: avoid unnecessary reinitialization 2016-02-29 20:21:54 +00:00
networks
newsyslog.conf Increase the default rotation threshold of log files from 100kb to 1000kb 2016-08-24 23:02:20 +00:00
nls.alias
nscd.conf
nsmb.conf Remove IPX support. 2014-03-14 02:58:48 +00:00
nsswitch.conf Implement an NSS backend for netgroups and add getnetgrent_r(3). 2016-06-09 01:28:44 +00:00
ntp.conf Add support for automatic leap-second file updates. 2016-01-26 07:06:44 +00:00
opieaccess
pccard_ether Do not try to recreate wlan(4) interface if it already exists. 2016-12-04 15:58:34 +00:00
pf.os
phones
portsnap.conf Now that the portsnap buildbox is generating the raw bits for INDEX-12, 2016-08-14 05:18:38 +00:00
printcap
profile
protocols etc: minor spelling fixes. 2016-05-01 16:43:22 +00:00
rc Use checkyesno instead of rolling my own.. 2016-10-23 18:00:09 +00:00
rc.bsdextended
rc.firewall Slight tidy up of comments before MFC 2015-06-29 07:43:09 +00:00
rc.initdiskless etc: minor spelling fixes. 2016-05-01 16:43:22 +00:00
rc.resume
rc.sendmail
rc.shutdown Since r275359, there is no need to provide a bogus service name. 2015-10-26 15:16:27 +00:00
rc.subr Fix bug preventing limits(1) from being applied 2016-12-03 19:03:40 +00:00
rc.suspend
regdomain.xml
remote
rpc
services Replace all whitespaces between port name and number with tabs, 2015-12-24 16:35:28 +00:00
shells
snmpd.config Adds the bsnmp module to export the temperature data from lm75 sensors on 2014-06-01 03:14:03 +00:00
sysctl.conf
syslog.conf syslogd(8): add an 'include' keyword 2016-11-01 01:41:24 +00:00
termcap.small