On 13 Jul 2018, at 19:50, Ian Lepore wrote:
Author: ian
Date: Fri Jul 13 17:50:25 2018
New Revision: 336252
URL: https://svnweb.freebsd.org/changeset/base/336252

Log:
Extend loader(8) geli support to all architectures and all disk-like devices.

This moves the bulk of the geli support from lib386/biosdisk.c into a new geli/gelidev.c which implements a devsw-type device whose dv_strategy() function handles geli decryption. Support for all arches comes from moving
  the taste-and-attach code to the devopen() function in libsa.

  After opening any DEVT_DISK device, devopen() calls the new function
geli_probe_and_attach(), which will "attach" the geli code to the open_file struct by creating a geli_devdesc instance to replace the disk_devdesc instance in the open_file. That routes all IO for the device through the
  geli code.

A new public geli_add_key() function is added, to allow arch/vendor-specific
  code to add keys obtained from custom hardware or other sources.

With these changes, geli support will be compiled into all variations of
  loader(8) on all arches because the default is WITH_LOADER_GELI.

  Relnotes:     yes
  Sponsored by: Microchip Technology Inc
  Differential Revision:        https://reviews.freebsd.org/D15743

I ran into a crash during startup with a geli encrypted raid-z1 root pool.

I believe this change broke it (although it could have been broken before too). When we iterate over the list of disks and allocate the zfsdsk structures we don’t zero out the `gdev` pointer. In my case that resulted in a geli_read() (called on the bogus pointer) dividing by zero.

The attached patch simply changes malloc() to calloc(), so the pointer is always set to NULL. As a side benefit it gets rid of one `#ifdef LOADER_GELI_SUPPORT`.

Regards,
Kristof
diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c
index fbdd9ac44e1..e8852775715 100644
--- a/stand/i386/zfsboot/zfsboot.c
+++ b/stand/i386/zfsboot/zfsboot.c
@@ -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;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to