From owner-svn-src-all@freebsd.org Sat Aug 4 19:57:12 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD8D71051417; Sat, 4 Aug 2018 19:57:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70E8885BF3; Sat, 4 Aug 2018 19:57:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 222B41AB40; Sat, 4 Aug 2018 19:57:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.0.2.164] (ptr-8rgnodwefsncims6j5o.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:240b:b802:c58a:76da:2e2d:7a7c]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id AF4043F9C4; Sat, 4 Aug 2018 21:57:09 +0200 (CEST) From: "Kristof Provost" To: "Ian Lepore" 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... Date: Sat, 04 Aug 2018 21:57:07 +0200 X-Mailer: MailMate (2.0BETAr6116) Message-ID: <9CB310A7-0612-472C-91F0-4B0EB7D75912@FreeBSD.org> In-Reply-To: <201807131750.w6DHoPD9024230@repo.freebsd.org> References: <201807131750.w6DHoPD9024230@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_MailMate_7414594C-7AEF-40D0-94A0-BF29CF616A67_=" Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2018 19:57:13 -0000 --=_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_=--