Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2014 22:53:05 GMT
From:      def@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r270040 - in soc2013/def/crashdump-head: sbin/dumpkey sbin/savecore sys/amd64/conf sys/conf sys/kern sys/sys
Message-ID:  <201406252253.s5PMr5PR067033@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: def
Date: Wed Jun 25 22:53:04 2014
New Revision: 270040
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=270040

Log:
  Style.

Modified:
  soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c
  soc2013/def/crashdump-head/sbin/savecore/dumpfile.c
  soc2013/def/crashdump-head/sbin/savecore/dumpfile.h
  soc2013/def/crashdump-head/sys/amd64/conf/GENERIC
  soc2013/def/crashdump-head/sys/conf/options
  soc2013/def/crashdump-head/sys/kern/kern_shutdown.c
  soc2013/def/crashdump-head/sys/sys/conf.h
  soc2013/def/crashdump-head/sys/sys/kerneldump.h

Modified: soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c	Wed Jun 25 22:53:04 2014	(r270040)
@@ -14,12 +14,13 @@
 #include <unistd.h>
 
 #define	PATH_DEVRANDOM		"/dev/random"
-#define	DEVBLK_SIZE		512
 
 static void
 usage(void)
 {
-	printf("%s\n%s\n", "usage: dumpkey -e public_key",
+
+	printf("%s\n%s\n",
+	    "usage: dumpkey -e public_key",
 	    "       dumpkey -d private_key -k encrypted_key -c encrypted_core");
 }
 
@@ -146,7 +147,7 @@
 decrypt_core(char *encrypted_core, char *private_key_file,
     char *encrypted_key_file)
 {
-	char buf[DEVBLK_SIZE];
+	char buf[KERNELDUMP_BUFFER_SIZE];
 	char key[KERNELDUMP_KEY_SIZE], iv[KERNELDUMP_IV_SIZE];
 	struct kerneldumpkey dumpkey;
 	FILE *fp, *fp_w;
@@ -179,9 +180,10 @@
 
 	offset = buf_used = 0;
 	do {
-		bytes = fread(buf + buf_used, 1, DEVBLK_SIZE - buf_used, fp);
+		bytes = fread(buf + buf_used, 1, KERNELDUMP_BUFFER_SIZE -
+		    buf_used, fp);
 		buf_used += bytes;
-		if (buf_used == DEVBLK_SIZE) {
+		if (buf_used == KERNELDUMP_BUFFER_SIZE) {
 			error = rijndael_cipherInit(&dumpkey.ci, MODE_CBC, iv);
 			if (error <= 0) {
 				printf("Error: cannot initialize a cipher.\n");

Modified: soc2013/def/crashdump-head/sbin/savecore/dumpfile.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/dumpfile.c	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sbin/savecore/dumpfile.c	Wed Jun 25 22:53:04 2014	(r270040)
@@ -58,12 +58,13 @@
 
 	fd = (dumpFile *)cookie;
 	saved = 0;
-	while (size + fd->buf_used >= DEVBLK_SIZE) {
-		resid = DEVBLK_SIZE - fd->buf_used;
+	while (size + fd->buf_used >= KERNELDUMP_BUFFER_SIZE) {
+		resid = KERNELDUMP_BUFFER_SIZE - fd->buf_used;
 		memcpy(fd->buf + fd->buf_used, data, resid);
 		fd->buf_used += resid;
 
-		if (fwrite(fd->buf, 1, DEVBLK_SIZE, fd->fp) != DEVBLK_SIZE) {
+		if (fwrite(fd->buf, 1, KERNELDUMP_BUFFER_SIZE, fd->fp) !=
+		    KERNELDUMP_BUFFER_SIZE) {
 			fd->buf_used -= resid;
 			return (saved);
 		}

Modified: soc2013/def/crashdump-head/sbin/savecore/dumpfile.h
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/dumpfile.h	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sbin/savecore/dumpfile.h	Wed Jun 25 22:53:04 2014	(r270040)
@@ -3,12 +3,10 @@
 
 #include <sys/kerneldump.h>
 
-#define	DEVBLK_SIZE	512
-
 typedef struct _dumpFile {
 	FILE	*fp;
 	char	ciphertext[KERNELDUMP_CIPHERTEXT_SIZE];
-	char	buf[DEVBLK_SIZE];
+	char	buf[KERNELDUMP_BUFFER_SIZE];
 	int	buf_used;
 } dumpFile;
 

Modified: soc2013/def/crashdump-head/sys/amd64/conf/GENERIC
==============================================================================
--- soc2013/def/crashdump-head/sys/amd64/conf/GENERIC	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sys/amd64/conf/GENERIC	Wed Jun 25 22:53:04 2014	(r270040)
@@ -352,4 +352,4 @@
 device		vmx			# VMware VMXNET3 Ethernet
 
 # Unattended encrypted kernel crash dumps 	 
-options		ENCRYPT_CRASH
+options		ENCRYPT_CRASH_DUMP

Modified: soc2013/def/crashdump-head/sys/conf/options
==============================================================================
--- soc2013/def/crashdump-head/sys/conf/options	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sys/conf/options	Wed Jun 25 22:53:04 2014	(r270040)
@@ -919,4 +919,4 @@
 RANDOM_RWFILE	opt_random.h
 
 # Unattended encrypted kernel crash dumps
-ENCRYPT_CRASH	opt_crash.h
+ENCRYPT_CRASH_DUMP	opt_ecd.h

Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c
==============================================================================
--- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c	Wed Jun 25 22:53:04 2014	(r270040)
@@ -38,11 +38,11 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_ddb.h"
+#include "opt_ecd.h"
 #include "opt_kdb.h"
 #include "opt_panic.h"
 #include "opt_sched.h"
 #include "opt_watchdog.h"
-#include "opt_crash.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,8 +87,6 @@
 
 #include <sys/signalvar.h>
 
-#include <opencrypto/cryptodev.h>
-
 #ifndef PANIC_REBOOT_WAIT_TIME
 #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
 #endif
@@ -142,11 +140,11 @@
 SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW,
 	&show_busybufs, 0, "");
 
+#ifdef ENCRYPT_CRASH_DUMP
 static struct kerneldumpkey dumperkey;
 static struct kerneldumpbuffer dumperbuffer;
-#ifdef ENCRYPT_CRASH
 SYSCTL_STRUCT(_kern, OID_AUTO, dumpkey, CTLFLAG_RW, &dumperkey,
-	kerneldumpkey, "Kernel crash dump key");
+    kerneldumpkey, "Kernel crash dump key");
 #endif
 
 /*
@@ -859,8 +857,7 @@
 	if (dumper.dumper != NULL)
 		return (EBUSY);
 	dumper = *di;
-
-#ifdef ENCRYPT_CRASH
+#ifdef ENCRYPT_CRASH_DUMP
 	kerneldump_crypto_init(&dumper, &dumperkey, &dumperbuffer);
 #endif
 
@@ -875,7 +872,7 @@
 /* Call dumper with encrypted data. */
 int
 dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
-		     off_t offset, size_t length)
+    off_t offset, size_t length)
 {
 	struct kerneldumpkey *kdk;
 	struct kerneldumpbuffer *kdb;
@@ -886,31 +883,32 @@
 
 	/* Write kernel dump headers. */
 	if (kdb->kdhoffset == 0 || offset == di->mediaoffset + di->mediasize -
-		sizeof(struct kerneldumpheader)) {
+	    sizeof(struct kerneldumpheader)) {
 		kdb->kdhoffset = offset + length;
-		return (di->dumper(di->priv, virtual, physical, offset, length));
+		return (di->dumper(di->priv, virtual, physical, offset,
+		    length));
 	}
 
 	while (length > 0) {
-		memcpy(kdb->buf, virtual, KERNELDUMP_DEVBLK_SIZE);
+		memcpy(kdb->buf, virtual, KERNELDUMP_BUFFER_SIZE);
 
 		error = rijndael_blockEncrypt(&kdk->ci, &kdk->ki, kdb->buf,
-		    KERNELDUMP_DEVBLK_SIZE * 8, kdb->buf);
+		    KERNELDUMP_BUFFER_SIZE * 8, kdb->buf);
 		if (error <= 0)
 			return (-1);
 		error = rijndael_cipherInit(&kdk->ci, MODE_CBC, kdb->buf +
-		    KERNELDUMP_DEVBLK_SIZE - KERNELDUMP_IV_SIZE);
+		    KERNELDUMP_BUFFER_SIZE - KERNELDUMP_IV_SIZE);
 		if (error <= 0)
 			return (-1);
 
-		error = (di->dumper(di->priv, kdb->buf, physical, offset, KERNELDUMP_DEVBLK_SIZE));
-
+		error = di->dumper(di->priv, kdb->buf, physical, offset,
+		    KERNELDUMP_BUFFER_SIZE);
 		if (error)
 			return (error);
 
-		virtual = (void *)((char *)virtual + KERNELDUMP_DEVBLK_SIZE);
-		length -= KERNELDUMP_DEVBLK_SIZE;
-		offset += KERNELDUMP_DEVBLK_SIZE;
+		virtual = (void *)((char *)virtual + KERNELDUMP_BUFFER_SIZE);
+		length -= KERNELDUMP_BUFFER_SIZE;
+		offset += KERNELDUMP_BUFFER_SIZE;
 	}
 
 	return (0);
@@ -930,7 +928,6 @@
 		    (uintmax_t)length, (intmax_t)di->mediasize);
 		return (ENOSPC);
 	}
-
 #ifdef ENCRYPT_CRASH
 	return (dump_encrypted_write(di, virtual, physical, offset, length));
 #else
@@ -940,16 +937,16 @@
 
 void
 kerneldump_crypto_init(struct dumperinfo *di, struct kerneldumpkey *kdk,
-	struct kerneldumpbuffer *kdb)
+    struct kerneldumpbuffer *kdb)
 {
+
 	if (kdk == NULL || kdb == NULL) {
-		printf("Attempt to initialize a non-existing kernel dump key and buffer.");
+		printf("Attempt to initialize a kernel dump key and buffer.");
 		return;
 	}
 
 	di->kdk = kdk;
 	di->kdb = kdb;
-
 	bzero(di->kdb, sizeof(struct kerneldumpbuffer));
 }
 

Modified: soc2013/def/crashdump-head/sys/sys/conf.h
==============================================================================
--- soc2013/def/crashdump-head/sys/sys/conf.h	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sys/sys/conf.h	Wed Jun 25 22:53:04 2014	(r270040)
@@ -328,19 +328,20 @@
 struct kerneldumpbuffer;
 
 struct dumperinfo {
-	dumper_t *dumper;		/* Dumping function. */
-	void    *priv;			/* Private parts. */
-	u_int   blocksize;		/* Size of block in bytes. */
-	u_int	maxiosize;		/* Max size allowed for an individual I/O */
-	off_t   mediaoffset;		/* Initial offset in bytes. */
-	off_t   mediasize;		/* Space available in bytes. */
+	dumper_t *dumper;	/* Dumping function. */
+	void    *priv;		/* Private parts. */
+	u_int   blocksize;	/* Size of block in bytes. */
+	u_int	maxiosize;	/* Max size allowed for an individual I/O */
+	off_t   mediaoffset;	/* Initial offset in bytes. */
+	off_t   mediasize;	/* Space available in bytes. */
 	struct kerneldumpkey *kdk;	/* Kernel dump key. */
 	struct kerneldumpbuffer	*kdb;	/* Kernel dump buffer. */
 };
 
 int set_dumper(struct dumperinfo *, const char *_devname);
 int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t);
-int dump_encrypted_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t);
+int dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
+    off_t offset, size_t length);
 void dumpsys(struct dumperinfo *);
 int doadump(boolean_t);
 extern int dumping;		/* system is dumping */

Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h
==============================================================================
--- soc2013/def/crashdump-head/sys/sys/kerneldump.h	Wed Jun 25 20:30:47 2014	(r270039)
+++ soc2013/def/crashdump-head/sys/sys/kerneldump.h	Wed Jun 25 22:53:04 2014	(r270040)
@@ -79,6 +79,7 @@
 #define	KERNELDUMP_KEY_SIZE		32
 #define	KERNELDUMP_IV_SIZE		16
 #define	KERNELDUMP_CIPHERTEXT_SIZE	256
+#define	KERNELDUMP_BUFFER_SIZE		512
 	uint64_t	dumplength;		/* excl headers */
 	uint64_t	dumptime;
 	uint32_t	blocksize;
@@ -89,6 +90,12 @@
 	uint32_t	parity;
 };
 
+struct kerneldumpkey {
+	char		ciphertext[KERNELDUMP_CIPHERTEXT_SIZE];
+	keyInstance	ki;
+	cipherInstance	ci;
+};
+
 /*
  * Parity calculation is endian insensitive.
  */
@@ -105,21 +112,14 @@
 	return (parity);
 }
 
-struct kerneldumpkey {
-	char		ciphertext[KERNELDUMP_CIPHERTEXT_SIZE];
-	keyInstance	ki;
-	cipherInstance	ci;
-};
-
 #ifdef _KERNEL
 struct kerneldumpbuffer {
-#define	KERNELDUMP_DEVBLK_SIZE	512
-	uint8_t		buf[KERNELDUMP_DEVBLK_SIZE];	/* Raw data buffer. */
-	off_t		kdhoffset;			/* Offset value of the first kdh. */
+	uint8_t	buf[KERNELDUMP_BUFFER_SIZE];	/* Raw data buffer. */
+	off_t	kdhoffset;			/* Offset value of the first kdh. */
 };
 
 void kerneldump_crypto_init(struct dumperinfo *di, struct kerneldumpkey *kdk,
-	struct kerneldumpbuffer *kdb);
+    struct kerneldumpbuffer *kdb);
 void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
     uint64_t dumplen, uint32_t blksz);
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406252253.s5PMr5PR067033>