freebsd-skq/sbin
def f63c437216 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
..
adjkerntz Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
atm Add history section for atmconfig(8) 2016-10-05 19:49:48 +00:00
badsect Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
bsdlabel Add history section for bsdlabel(8) 2016-10-05 19:56:10 +00:00
camcontrol [camcontrol] init ts=0 to quieten gcc. 2016-12-03 20:35:39 +00:00
ccdconfig ccdconfig first appeared in NetBSD 1.1 2016-10-02 23:19:05 +00:00
clri Add history section for clri(8) 2016-10-05 20:01:09 +00:00
comcontrol Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
conscontrol Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
ddb Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
decryptcore Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
devd Simplify test. 2016-12-01 04:35:38 +00:00
devfs Add history section for devfs(8) 2016-10-05 20:08:07 +00:00
dhclient Allocate a struct ifreq rather than using a (wrong) computed size for 2016-11-22 22:45:15 +00:00
dmesg dmesg(8) first appeared in 3BSD. 2016-10-02 23:26:41 +00:00
dump dump(8) first appeared in V4 UNIX 2016-10-02 23:30:28 +00:00
dumpfs Use MIN macro from sys/param.h. 2016-05-02 01:40:31 +00:00
dumpon Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
etherswitchcfg Zero etherswitch_vlangroup structure before doing partial assignments. 2016-11-17 19:02:25 +00:00
fdisk Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2.5 Installation notes [2]. 2016-10-05 20:21:06 +00:00
fdisk_pc98 Document the history of fdisk based on the original post to comp.unix.bsd by Julian Elischer [1] and the Mach 2.5 Installation notes [2]. 2016-10-05 20:28:04 +00:00
ffsinfo Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
fsck Add history section to fsck(8) 2016-10-05 20:31:44 +00:00
fsck_ffs Add history section to fsck_ffs(8) 2016-10-05 20:38:49 +00:00
fsck_msdosfs Mention the version of NetBSD the utility originated from. 2016-10-02 23:40:17 +00:00
fsdb Document which version of BSD first showed up in and add the version info 2016-10-02 23:44:52 +00:00
fsirand Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
gbde gbde first appeared in FreeBSD 5.0 2016-10-02 23:48:33 +00:00
geom Add gmirror create subcommand, alike to gstripe, gconcat, etc. 2016-11-30 09:27:08 +00:00
ggate Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
growfs Use bsdlabel as we don't have hardlink disklabel -> bsdlabel on MIPS. 2016-09-26 14:01:41 +00:00
gvinum Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
hastctl Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
hastd Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
ifconfig [ifconfig] remove now duplicate IEEE80211_C_BITS definition; it's now in _ieee80211.h . 2016-11-18 21:12:36 +00:00
init Add verbosity around failed reboot(2) call. 2016-10-07 13:43:38 +00:00
ipf MFH 2016-03-02 16:14:46 +00:00
ipfw Fix 'ipfw delete set N': 2016-11-29 10:43:58 +00:00
iscontrol Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
kldconfig Use nitems() from sys/param.h. 2016-04-19 04:52:13 +00:00
kldload Use nitems() from sys/param.h. 2016-04-19 04:52:51 +00:00
kldstat MFH 2016-04-04 23:55:32 +00:00
kldunload Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
ldconfig Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
md5 DIRDEPS_BUILD: Update dependencies. 2016-11-13 00:11:30 +00:00
mdconfig Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
mdmfs Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
mknod mknod appeared in V4 UNIX 2016-10-02 23:56:08 +00:00
mksnap_ffs mksnap_ffs appeared in FreeBSD 5.1. 2016-10-02 23:59:31 +00:00
mount mount(1): Simplify by using asprintf(3) 2016-09-19 18:42:58 +00:00
mount_cd9660 Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
mount_fusefs Note mount_fusefs appeared in FreeBSD 10. 2016-10-03 00:16:16 +00:00
mount_msdosfs Amend history to mention predecessor originated from 386BSD[1] & current implementation from NetBSD[2]. 2016-10-03 00:25:15 +00:00
mount_nfs Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
mount_nullfs Note the name change from mount_null to mount_nullfs in FreeBSD 5.0. 2016-10-03 00:28:42 +00:00
mount_udf Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
mount_unionfs Note the change of name in FreeBSD 5.0. 2016-10-03 00:31:58 +00:00
nandfs Add missing history sections to a number of storage related man pages 2016-09-16 04:28:31 +00:00
natd Add history section to natd(8) 2016-10-05 20:42:35 +00:00
newfs Use MIN()/MAX() macros from sys/param.h. 2016-05-02 00:45:46 +00:00
newfs_msdos The code only converts from bpbHugeSectors to bpbSectors if the sum of 2016-08-30 18:01:26 +00:00
newfs_nandfs sbin: use our howmany() macro when available through <sys/param.h>. 2016-05-01 02:19:49 +00:00
nfsiod Explicitly add more files to the 'runtime' package. 2016-02-09 20:19:31 +00:00
nos-tun Add history section to nos-tun(8) 2016-10-05 20:45:21 +00:00
nvmecontrol Implement Intel's log page 0xc1 (Read Command Latency Log) and page 2016-12-09 23:37:14 +00:00
pfctl pfctl: fix nested inline anchors 2016-11-10 18:41:43 +00:00
pflogd Create packages for atm, ccdconfig, devd, ipf, ipfw, 2016-02-09 19:30:31 +00:00
ping Check for socket creation success before calling bind(). 2016-05-12 05:43:54 +00:00
ping6 Fix a regression introduced on revision r271909, when using argument -g 2016-07-05 07:01:42 +00:00
quotacheck For pointers use NULL instead of 0. 2016-05-16 00:36:12 +00:00
rcorder Add rcorder-visualize.sh, which generates graphviz from rc.d scripts 2016-12-06 15:49:39 +00:00
reboot sbin/reboot/reboot.8: Amend HISTORY 2016-09-16 04:11:04 +00:00
recoverdisk sbin: ake use of our rounddown() macro when sys/param.h is available. 2016-05-01 02:24:05 +00:00
resolvconf Fix missing substitution of @SBINDIR@ in resolvconf scripts 2016-08-23 02:06:20 +00:00
restore restore: promote some getfiles() parameters to size_t. 2016-05-01 21:17:30 +00:00
route Due to dropped mbuf in netisr queue route(8) can fall into infinity 2016-07-27 08:26:34 +00:00
routed routed(8): Use arc4random_uniform instead of arc4random. 2016-05-15 06:06:22 +00:00
rtsol Create packages for atm, ccdconfig, devd, ipf, ipfw, 2016-02-09 19:30:31 +00:00
savecore Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
sconfig sconfig appeared in FreeBSD 5.2. 2016-10-03 00:40:20 +00:00
setkey setkey appeared in FreeBSD 4.0 2016-10-03 00:42:25 +00:00
shutdown shutdown appeared as a standalone utility in 4.1BSD. 2016-10-03 00:55:18 +00:00
spppcontrol Add META_MODE support. 2015-06-13 19:20:56 +00:00
sunlabel Re-ident lines. 2016-04-20 01:35:09 +00:00
swapon swapoff: Remove only late devices with -aL. 2016-10-21 21:55:50 +00:00
sysctl Consolidate four efi_next_descriptor() definitions. 2016-09-18 17:38:02 +00:00
tests Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
tunefs Mention fsck_ffs -E in tunefs(8). It's non-obvious that one should 2016-04-19 15:08:35 +00:00
umount Modify umount so that it does not do an Unmount RPC for NFSv4 mounts 2016-11-19 23:58:50 +00:00
zfsbootcfg DIRDEPS_BUILD: Connect new dependencies. 2016-11-13 00:11:23 +00:00
Makefile Add support for encrypted kernel crash dumps. 2016-12-10 16:20:39 +00:00
Makefile.amd64
Makefile.arm
Makefile.i386
Makefile.inc Use src.opts.mk in preference to bsd.own.mk except where we need stuff 2014-05-06 04:22:01 +00:00
Makefile.mips
Makefile.pc98
Makefile.sparc64