summaryrefslogtreecommitdiffstats
path: root/sys/ia64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-12-17 02:51:56 +0000
committermarcel <marcel@FreeBSD.org>2002-12-17 02:51:56 +0000
commit527408760d81666a3f0b220f592890afe1a1c8e1 (patch)
treeadbf7fc3c9b53c5a417b889cbfa1c4461f4f412b /sys/ia64
parent595fed56c73a275eb570569111adbb62a317d8de (diff)
downloadFreeBSD-src-527408760d81666a3f0b220f592890afe1a1c8e1.zip
FreeBSD-src-527408760d81666a3f0b220f592890afe1a1c8e1.tar.gz
Check that the dump device is large enough. Otherwise we could
end up with a dump offset that's smaller than the start of the dump device and either clobber data in preceding partitions or try to write beyond the end of the medium (unsigned wrap). Implement legacy behaviour to never write to the first 64KB as that is where metadata (ie disklabels) may reside.
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/ia64/dump_machdep.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c
index 0099462..4195498 100644
--- a/sys/ia64/ia64/dump_machdep.c
+++ b/sys/ia64/ia64/dump_machdep.c
@@ -41,6 +41,12 @@
CTASSERT(sizeof(struct kerneldumpheader) == 512);
+/*
+ * Don't touch the first SIZEOF_METADATA bytes on the dump device. This
+ * is to protect us from metadata and to protect metadata from us.
+ */
+#define SIZEOF_METADATA (64*1024)
+
#define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK)
#define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
@@ -251,6 +257,10 @@ dumpsys(struct dumperinfo *di)
hdrgap = fileofs - DEV_ALIGN(hdrsz);
/* Determine dump offset on device. */
+ if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) {
+ error = ENOSPC;
+ goto fail;
+ }
dumplo = di->mediaoffset + di->mediasize - dumpsize;
dumplo -= sizeof(kdh) * 2;
OpenPOWER on IntegriCloud