Date: Mon, 26 Oct 2015 20:36:09 GMT From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r293096 - soc2013/def/crashdump-head/sys/kern Message-ID: <201510262036.t9QKa9uB058603@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: def Date: Mon Oct 26 20:36:08 2015 New Revision: 293096 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=293096 Log: Encode kernel dump key. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Oct 26 20:34:11 2015 (r293095) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Mon Oct 26 20:36:08 2015 (r293096) @@ -44,6 +44,7 @@ #include "opt_sched.h" #include "opt_watchdog.h" +#include <sys/endian.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/bio.h> @@ -878,9 +879,6 @@ sizeof(kdc->kdc_iv) + sizeof(kdc->kdc_encryptedkeysize) + kdc->kdc_encryptedkeysize + KERNELDUMP_BLOCK_SIZE - 1) / KERNELDUMP_BLOCK_SIZE * KERNELDUMP_BLOCK_SIZE; - kdc->kdc_dumpkeysize = (sizeof(struct kerneldumpkey) + - kdc->kdc_encryptedkeysize + KERNELDUMP_BLOCK_SIZE - 1) / - KERNELDUMP_BLOCK_SIZE * KERNELDUMP_BLOCK_SIZE; return (kdc); failed: @@ -1061,23 +1059,28 @@ int dump_write_key(struct dumperinfo *di, vm_offset_t physical, off_t offset) { + uint8_t *buf, *p; struct kerneldumpcrypto *kdc; - struct kerneldumpkey *kdk; int ret; kdc = di->kdc; if (kdc == NULL) return (0); - kdk = malloc(kdc->kdc_dumpkeysize, M_EKCD, M_WAITOK | M_ZERO); - kdk->kdk_algorithm = kdc->kdc_algorithm; - bcopy(kdc->kdc_iv, kdk->kdk_iv, sizeof(kdk->kdk_iv)); - kdk->kdk_encryptedkeysize = kdc->kdc_encryptedkeysize; - bcopy(kdc->kdc_encryptedkey, kdk->kdk_encryptedkey, - kdk->kdk_encryptedkeysize); + buf = malloc(kdc->kdc_dumpkeysize, M_EKCD, M_WAITOK | M_ZERO); + + p = buf; + *p = kdc->kdc_algorithm; + p += sizeof(kdc->kdc_algorithm); + bcopy(kdc->kdc_iv, p, sizeof(kdc->kdc_iv)); + p += sizeof(kdc->kdc_iv); + le32enc(p, kdc->kdc_encryptedkeysize); + p += sizeof(kdc->kdc_encryptedkeysize); + bcopy(kdc->kdc_encryptedkey, p, kdc->kdc_encryptedkeysize); + p += kdc->kdc_encryptedkeysize; - ret = dump_raw_write(di, kdk, physical, offset, kdc->kdc_dumpkeysize); - free(kdk, M_EKCD); + ret = dump_raw_write(di, buf, physical, offset, kdc->kdc_dumpkeysize); + free(buf, M_EKCD); return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510262036.t9QKa9uB058603>