socsvn commit: r257589 - in soc2013/def/crashdump-head: sbin/savecore sys/kern sys/sys
def at FreeBSD.org
def at FreeBSD.org
Sat Sep 21 23:07:04 UTC 2013
Author: def
Date: Sat Sep 21 23:07:03 2013
New Revision: 257589
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257589
Log:
Change crash dump routines and savecore to use the current version of XTS implementation.
Modified:
soc2013/def/crashdump-head/sbin/savecore/decryptfile.c
soc2013/def/crashdump-head/sys/kern/kern_shutdown.c
soc2013/def/crashdump-head/sys/sys/kerneldump.h
Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Sat Sep 21 22:43:50 2013 (r257588)
+++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Sat Sep 21 23:07:03 2013 (r257589)
@@ -19,9 +19,9 @@
memcpy(fd->buf + fd->buf_used, data, resid);
fd->buf_used += resid;
- xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx,
- fd->offset, fd->tweak, NULL, PEFS_SECTOR_SIZE,
- fd->buf, fd->buf);
+ xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx,
+ (struct xts_ctx *)&fd->data_ctx, fd->offset, fd->tweak, 0,
+ PEFS_SECTOR_SIZE, fd->buf, fd->buf);
if (fwrite(fd->buf, 1, PEFS_SECTOR_SIZE, fd->fp) != PEFS_SECTOR_SIZE)
return (0);
Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c
==============================================================================
--- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Sep 21 22:43:50 2013 (r257588)
+++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Sep 21 23:07:03 2013 (r257589)
@@ -876,7 +876,6 @@
struct kerneldumpbuffer *kdb;
int error, sector_index, devblk_index;
off_t sector_offset;
- uint64_t tweak[XTS_BLK_BYTES / 8];
kdk = di->kdk;
kdb = di->kdb;
@@ -890,26 +889,14 @@
sector_index = (offset - kdb->kdhoffset)/KERNELDUMP_SECTOR_SIZE;
sector_offset = kdb->kdhoffset + sector_index*KERNELDUMP_SECTOR_SIZE;
- devblk_index = (offset - kdb->kdhoffset - sector_index*KERNELDUMP_SECTOR_SIZE)/KERNELDUMP_DEVBLK_SIZE;
-
- if (sector_index == kdb->sector_index) {
- kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, kdb->devblk_index, devblk_index,
- sector_offset, kdk->tweak);
- memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak));
- }
+ devblk_index = (offset - sector_offset)/KERNELDUMP_DEVBLK_SIZE;
while (length > 0) {
memcpy(kdb->buf, virtual, KERNELDUMP_DEVBLK_SIZE);
- if (sector_index != kdb->sector_index) {
- kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, 0, devblk_index,
- sector_offset, kdk->tweak);
- kdb->sector_index = sector_index;
- memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak));
- }
-
- xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, offset, kdk->tweak,
- tweak, KERNELDUMP_DEVBLK_SIZE, kdb->buf, kdb->buf);
+ xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx,
+ sector_offset, kdk->tweak, devblk_index*KERNELDUMP_DEVBLK_BLKS,
+ KERNELDUMP_DEVBLK_SIZE, kdb->buf, kdb->buf);
error = (di->dumper(di->priv, kdb->buf, physical, offset, KERNELDUMP_DEVBLK_SIZE));
@@ -921,13 +908,8 @@
offset += KERNELDUMP_DEVBLK_SIZE;
devblk_index = (devblk_index+1)%KERNELDUMP_SECTOR_BLKS;
- if (devblk_index == 0) {
- sector_index++;
+ if (devblk_index == 0)
sector_offset = offset;
- } else {
- memcpy(kdb->alpha_j[devblk_index], tweak, sizeof(tweak));
- kdb->devblk_index = devblk_index;
- }
}
return (0);
@@ -955,24 +937,6 @@
#endif
}
-void
-kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx,
- uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j,
- uint64_t sector, const uint8_t *xtweak)
-{
- int k;
-
- if (i == 0)
- xts_start(alg, tweak_ctx, alpha_j[0], sector, xtweak);
-
- for (++i ; i <= j ; i++) {
- memcpy(alpha_j[i], alpha_j[i-1], XTS_BLK_BYTES);
-
- for (k = 0 ; k < KERNELDUMP_DEVBLK_SIZE/XTS_BLK_BYTES ; k++)
- gf_mul128(alpha_j[i], alpha_j[i]);
- }
-}
-
static void
kerneldump_hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key,
int idx, const uint8_t *magic, size_t magicsize)
@@ -1037,8 +1001,6 @@
return (NULL);
}
- kdb->sector_index = -1;
- kdb->devblk_index = -1;
kdb->kdhoffset = 0;
return (kdb);
Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h
==============================================================================
--- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Sep 21 22:43:50 2013 (r257588)
+++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Sep 21 23:07:03 2013 (r257589)
@@ -133,20 +133,15 @@
struct kerneldumpbuffer {
#define KERNELDUMP_DEVBLK_SIZE 512
#define KERNELDUMP_SECTOR_SIZE 4096
+#define KERNELDUMP_DEVBLK_BLKS (KERNELDUMP_DEVBLK_SIZE/XTS_BLK_BYTES)
#define KERNELDUMP_SECTOR_BLKS (KERNELDUMP_SECTOR_SIZE/KERNELDUMP_DEVBLK_SIZE)
uint8_t buf[KERNELDUMP_DEVBLK_SIZE]; /* Raw data buffer. */
- uint64_t alpha_j[KERNELDUMP_SECTOR_BLKS][XTS_BLK_BYTES / 8];
- off_t sector_index;
- off_t devblk_index;
off_t kdhoffset; /* Offset value of the first kdh. */
};
void kerneldump_crypto_init(struct dumperinfo *di);
struct kerneldumpkey *kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *key, char *tweak);
struct kerneldumpbuffer *kerneldump_set_buffer(struct kerneldumpbuffer *kdb);
-void kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx,
- uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j,
- uint64_t sector, const uint8_t *xtweak);
void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
uint64_t dumplen, uint32_t blksz);
#endif
More information about the svn-soc-all
mailing list