svn commit: r337349 - head/stand/i386/zfsboot
Kristof Provost
kp at FreeBSD.org
Sun Aug 5 11:15:29 UTC 2018
Author: kp
Date: Sun Aug 5 11:15:28 2018
New Revision: 337349
URL: https://svnweb.freebsd.org/changeset/base/337349
Log:
zfsboot: Fix startup crash
On a FreeNAS mini XL, with geli encrypted drives the loader crashed in
geli_read().
When we iterate over the list of disks and allocate the zfsdsk structures we
don’t zero out the gdev pointer. In one case that resulted in geli_read()
(called on the bogus pointer) dividing by zero.
Use calloc() to ensure the zfsdsk structure is always zeroed, so the pointer is
initialised to NULL. As a side benefit it gets rid of one #ifdef
LOADER_GELI_SUPPORT.
Modified:
head/stand/i386/zfsboot/zfsboot.c
Modified: head/stand/i386/zfsboot/zfsboot.c
==============================================================================
--- head/stand/i386/zfsboot/zfsboot.c Sun Aug 5 11:14:13 2018 (r337348)
+++ head/stand/i386/zfsboot/zfsboot.c Sun Aug 5 11:15:28 2018 (r337349)
@@ -707,10 +707,7 @@ main(void)
}
setheap(heap_next, heap_end);
- zdsk = malloc(sizeof(struct zfsdsk));
-#ifdef LOADER_GELI_SUPPORT
- zdsk->gdev = NULL;
-#endif
+ zdsk = calloc(1, sizeof(struct zfsdsk));
zdsk->dsk.drive = *(uint8_t *)PTOV(ARGS);
zdsk->dsk.type = zdsk->dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
zdsk->dsk.unit = zdsk->dsk.drive & DRV_MASK;
@@ -758,7 +755,7 @@ main(void)
if (!int13probe(i | DRV_HARD))
break;
- zdsk = malloc(sizeof(struct zfsdsk));
+ zdsk = calloc(1, sizeof(struct zfsdsk));
zdsk->dsk.drive = i | DRV_HARD;
zdsk->dsk.type = zdsk->dsk.drive & TYPE_AD;
zdsk->dsk.unit = i;
More information about the svn-src-all
mailing list