Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149281189
D11603.1789813012.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D11603.1789813012.diff
View Options
Index: head/sys/amd64/amd64/minidump_machdep.c
===================================================================
--- head/sys/amd64/amd64/minidump_machdep.c
+++ head/sys/amd64/amd64/minidump_machdep.c
@@ -327,8 +327,8 @@
mdhdr.dmapbase = DMAP_MIN_ADDRESS;
mdhdr.dmapend = DMAP_MAX_ADDRESS;
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION,
+ dumpsize);
printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20,
ptoa((uintmax_t)physmem) / 1048576);
Index: head/sys/arm/arm/minidump_machdep.c
===================================================================
--- head/sys/arm/arm/minidump_machdep.c
+++ head/sys/arm/arm/minidump_machdep.c
@@ -245,8 +245,8 @@
#else
mdhdr.mmuformat = MINIDUMP_MMU_FORMAT_V4;
#endif
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION, dumpsize,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION,
+ dumpsize);
printf("Physical memory: %u MB\n", ptoa((uintmax_t)physmem) / 1048576);
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
Index: head/sys/arm64/arm64/minidump_machdep.c
===================================================================
--- head/sys/arm64/arm64/minidump_machdep.c
+++ head/sys/arm64/arm64/minidump_machdep.c
@@ -289,8 +289,8 @@
mdhdr.dmapbase = DMAP_MIN_ADDRESS;
mdhdr.dmapend = DMAP_MAX_ADDRESS;
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AARCH64_VERSION,
- dumpsize, kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_AARCH64_VERSION,
+ dumpsize);
printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20,
ptoa((uintmax_t)physmem) / 1048576);
Index: head/sys/ddb/db_textdump.c
===================================================================
--- head/sys/ddb/db_textdump.c
+++ head/sys/ddb/db_textdump.c
@@ -463,8 +463,7 @@
*/
textdump_offset = di->mediasize - sizeof(kdh);
textdump_saveoff(&trailer_offset);
- mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, 0,
- TEXTDUMP_BLOCKSIZE);
+ dump_init_header(di, &kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0);
(void)textdump_writenextblock(di, (char *)&kdh);
/*
@@ -489,8 +488,8 @@
* size.
*/
dumplen = trailer_offset - (textdump_offset + TEXTDUMP_BLOCKSIZE);
- mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, dumplen, 0,
- TEXTDUMP_BLOCKSIZE);
+ dump_init_header(di, &kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION,
+ dumplen);
(void)textdump_writenextblock(di, (char *)&kdh);
textdump_restoreoff(trailer_offset);
(void)textdump_writenextblock(di, (char *)&kdh);
Index: head/sys/i386/i386/minidump_machdep.c
===================================================================
--- head/sys/i386/i386/minidump_machdep.c
+++ head/sys/i386/i386/minidump_machdep.c
@@ -252,8 +252,8 @@
mdhdr.paemode = 1;
#endif
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION,
+ dumpsize);
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
Index: head/sys/kern/kern_dump.c
===================================================================
--- head/sys/kern/kern_dump.c
+++ head/sys/kern/kern_dump.c
@@ -341,8 +341,8 @@
dumpsize += fileofs;
hdrgap = fileofs - roundup2((off_t)hdrsz, di->blocksize);
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION, dumpsize,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION,
+ dumpsize);
printf("Dumping %ju MB (%d chunks)\n", (uintmax_t)dumpsize >> 20,
ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS);
Index: head/sys/kern/kern_shutdown.c
===================================================================
--- head/sys/kern/kern_shutdown.c
+++ head/sys/kern/kern_shutdown.c
@@ -895,14 +895,10 @@
free(kdc, M_EKCD);
return (NULL);
}
-#endif /* EKCD */
static int
kerneldumpcrypto_init(struct kerneldumpcrypto *kdc)
{
-#ifndef EKCD
- return (0);
-#else
uint8_t hash[SHA256_DIGEST_LENGTH];
SHA256_CTX ctx;
struct kerneldumpkey *kdk;
@@ -942,21 +938,17 @@
out:
explicit_bzero(hash, sizeof(hash));
return (error);
-#endif
}
-uint32_t
+static uint32_t
kerneldumpcrypto_dumpkeysize(const struct kerneldumpcrypto *kdc)
{
-#ifdef EKCD
if (kdc == NULL)
return (0);
return (kdc->kdc_dumpkeysize);
-#else
- return (0);
-#endif
}
+#endif /* EKCD */
/* Registration of dumpers */
int
@@ -1036,6 +1028,20 @@
return (0);
}
+/* Call dumper with bounds checking. */
+static int
+dump_raw_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
+ off_t offset, size_t length)
+{
+ int error;
+
+ error = dump_check_bounds(di, offset, length);
+ if (error != 0)
+ return (error);
+
+ return (di->dumper(di->priv, virtual, physical, offset, length));
+}
+
#ifdef EKCD
static int
dump_encrypt(struct kerneldumpcrypto *kdc, uint8_t *buf, size_t size)
@@ -1115,21 +1121,20 @@
return (0);
}
-#endif /* EKCD */
-/* Call dumper with bounds checking. */
static int
-dump_raw_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
- off_t offset, size_t length)
+dump_write_key(struct dumperinfo *di, vm_offset_t physical, off_t offset)
{
- int error;
+ struct kerneldumpcrypto *kdc;
- error = dump_check_bounds(di, offset, length);
- if (error != 0)
- return (error);
+ kdc = di->kdc;
+ if (kdc == NULL)
+ return (0);
- return (di->dumper(di->priv, virtual, physical, offset, length));
+ return (dump_raw_write(di, kdc->kdc_dumpkey, physical, offset,
+ kdc->kdc_dumpkeysize));
}
+#endif /* EKCD */
int
dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
@@ -1194,23 +1199,6 @@
return (ret);
}
-static int
-dump_write_key(struct dumperinfo *di, vm_offset_t physical, off_t offset)
-{
-#ifndef EKCD
- return (0);
-#else /* EKCD */
- struct kerneldumpcrypto *kdc;
-
- kdc = di->kdc;
- if (kdc == NULL)
- return (0);
-
- return (dump_raw_write(di, kdc->kdc_dumpkey, physical, offset,
- kdc->kdc_dumpkeysize));
-#endif /* !EKCD */
-}
-
/*
* Don't touch the first SIZEOF_METADATA bytes on the dump device. This is to
* protect us from metadata and metadata from us.
@@ -1226,14 +1214,19 @@
dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh, off_t *dumplop)
{
uint64_t dumpsize;
+ uint32_t keysize;
int error;
+#ifdef EKCD
error = kerneldumpcrypto_init(di->kdc);
if (error != 0)
return (error);
+ keysize = kerneldumpcrypto_dumpkeysize(di->kdc);
+#else
+ keysize = 0;
+#endif
- dumpsize = dtoh64(kdh->dumplength) + 2 * di->blocksize +
- kerneldumpcrypto_dumpkeysize(di->kdc);
+ dumpsize = dtoh64(kdh->dumplength) + 2 * di->blocksize + keysize;
if (di->mediasize < SIZEOF_METADATA + dumpsize)
return (E2BIG);
@@ -1244,10 +1237,12 @@
return (error);
*dumplop += di->blocksize;
+#ifdef EKCD
error = dump_write_key(di, 0, *dumplop);
if (error != 0)
return (error);
- *dumplop += kerneldumpcrypto_dumpkeysize(di->kdc);
+ *dumplop += keysize;
+#endif
return (0);
}
@@ -1270,8 +1265,8 @@
}
void
-mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
- uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz)
+dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh,
+ char *magic, uint32_t archver, uint64_t dumplen)
{
size_t dstsize;
@@ -1282,8 +1277,12 @@
kdh->architectureversion = htod32(archver);
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
- kdh->dumpkeysize = htod32(dumpkeysize);
- kdh->blocksize = htod32(blksz);
+#ifdef EKCD
+ kdh->dumpkeysize = htod32(kerneldumpcrypto_dumpkeysize(di->kdc));
+#else
+ kdh->dumpkeysize = 0;
+#endif
+ kdh->blocksize = htod32(di->blocksize);
strlcpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname));
dstsize = sizeof(kdh->versionstring);
if (strlcpy(kdh->versionstring, version, dstsize) >= dstsize)
Index: head/sys/mips/mips/minidump_machdep.c
===================================================================
--- head/sys/mips/mips/minidump_machdep.c
+++ head/sys/mips/mips/minidump_machdep.c
@@ -261,8 +261,8 @@
mdhdr.ptesize = ptesize;
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS;
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_MIPS_VERSION, dumpsize,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_MIPS_VERSION,
+ dumpsize);
printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20,
ptoa((uintmax_t)physmem) / 1048576);
Index: head/sys/sparc64/sparc64/dump_machdep.c
===================================================================
--- head/sys/sparc64/sparc64/dump_machdep.c
+++ head/sys/sparc64/sparc64/dump_machdep.c
@@ -94,8 +94,8 @@
DEV_BSIZE);
size += hdrsize;
- mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size,
- kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize);
+ dump_init_header(di, &kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION,
+ size);
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg);
Index: head/sys/sys/conf.h
===================================================================
--- head/sys/sys/conf.h
+++ head/sys/sys/conf.h
@@ -342,6 +342,8 @@
int set_dumper(struct dumperinfo *di, const char *devname, struct thread *td,
uint8_t encrypt, const uint8_t *key, uint32_t encryptedkeysize,
const uint8_t *encryptedkey);
+void dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh,
+ char *magic, uint32_t archver, uint64_t dumplen);
int dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh,
off_t *dumplop);
int dump_finish(struct dumperinfo *di, struct kerneldumpheader *kdh,
Index: head/sys/sys/kerneldump.h
===================================================================
--- head/sys/sys/kerneldump.h
+++ head/sys/sys/kerneldump.h
@@ -125,11 +125,6 @@
vm_paddr_t pa_size;
};
-uint32_t kerneldumpcrypto_dumpkeysize(const struct kerneldumpcrypto *kdc);
-
-void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
- uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz);
-
int dumpsys_generic(struct dumperinfo *);
void dumpsys_map_chunk(vm_paddr_t, size_t, void **);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 19, 10:16 AM (4 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29777634
Default Alt Text
D11603.1789813012.diff (10 KB)
Attached To
Mode
D11603: Shift some of the EKCD funcs around to keep them grouped together.
Attached
Detach File
Event Timeline
Log In to Comment