Date: Sat, 04 Aug 2018 21:57:07 +0200 From: "Kristof Provost" <kp@FreeBSD.org> To: "Ian Lepore" <ian@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r336252 - in head: share/mk stand stand/common stand/efi/loader stand/i386/gptboot stand/i386/gptzfsboot stand/i386/isoboot stand/i386/libi386 stand/i386/loader stand/i386/zfsboot stand... Message-ID: <9CB310A7-0612-472C-91F0-4B0EB7D75912@FreeBSD.org> In-Reply-To: <201807131750.w6DHoPD9024230@repo.freebsd.org> References: <201807131750.w6DHoPD9024230@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=_MailMate_7414594C-7AEF-40D0-94A0-BF29CF616A67_= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 --=_MailMate_7414594C-7AEF-40D0-94A0-BF29CF616A67_= Content-Disposition: attachment; filename=gptzfsboot.patch Content-Transfer-Encoding: quoted-printable 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 =3D malloc(sizeof(struct zfsdsk)); -#ifdef LOADER_GELI_SUPPORT - zdsk->gdev =3D NULL; -#endif + zdsk =3D calloc(1, sizeof(struct zfsdsk)); zdsk->dsk.drive =3D *(uint8_t *)PTOV(ARGS); zdsk->dsk.type =3D zdsk->dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; zdsk->dsk.unit =3D zdsk->dsk.drive & DRV_MASK; @@ -758,7 +755,7 @@ main(void) if (!int13probe(i | DRV_HARD)) break; = - zdsk =3D malloc(sizeof(struct zfsdsk)); + zdsk =3D calloc(1, sizeof(struct zfsdsk)); zdsk->dsk.drive =3D i | DRV_HARD; zdsk->dsk.type =3D zdsk->dsk.drive & TYPE_AD; zdsk->dsk.unit =3D i; --=_MailMate_7414594C-7AEF-40D0-94A0-BF29CF616A67_=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9CB310A7-0612-472C-91F0-4B0EB7D75912>