Date: Sun, 5 Aug 2018 11:15:28 +0000 (UTC) From: Kristof Provost <kp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337349 - head/stand/i386/zfsboot Message-ID: <201808051115.w75BFSAa062073@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808051115.w75BFSAa062073>