Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V7rhx-00031o-5s for mharc-grub-devel@gnu.org; Fri, 09 Aug 2013 14:46:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7rhm-0002du-M1 for grub-devel@gnu.org; Fri, 09 Aug 2013 14:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7rhh-000535-KT for grub-devel@gnu.org; Fri, 09 Aug 2013 14:46:30 -0400 Received: from mmserver.massimo-maggi.eu ([94.23.66.90]:55782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7rhg-00052i-VK for grub-devel@gnu.org; Fri, 09 Aug 2013 14:46:25 -0400 Received: from [IPv6:2001:b05:f:ffff::25] (unknown [IPv6:2001:b05:f:ffff::25]) by mmserver.massimo-maggi.eu (Postfix) with ESMTPSA id 1CB5926E; Fri, 9 Aug 2013 20:46:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=massimo-maggi.eu; s=mmserver; t=1376073983; bh=kl1mZAX5X9u7gVRjwC1LzG5KDBOQ+lJSE+cH6nNB+sw=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=b/9aPS/xodylABcVyYMeRuzKZjlUzFk6J850qmmyJNrznwu6Jl+26KYB8b3CiO46p GMsvE79okxDwKM9uBYSzoXYVcOxI/O5man7YXPHgYP/Y/Gx/SN6dxnVky8h9ohveqX 8Ar3Yubl1Mu02ydECotxpW5rRyyrOhBAuZly3cEQ= Message-ID: <52053904.6020800@massimo-maggi.eu> Date: Fri, 09 Aug 2013 20:46:28 +0200 From: Massimo Maggi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130619 Thunderbird/17.0.6 MIME-Version: 1.0 To: Andrey Borzenkov Subject: Re: [PATCH 1/5] Fix reporting of RAIDZ vdevs in zfsinfo References: <510F96B1.6080509@massimo-maggi.eu> <5185928A.9060905@gmail.com> <5187C6B6.1060709@massimo-maggi.eu> <5187F205.8000105@gmail.com> <51881A91.6050603@massimo-maggi.eu> <52043133.6080603@massimo-maggi.eu> <20130809063935.0396c64f@opensuse.site> In-Reply-To: <20130809063935.0396c64f@opensuse.site> X-Enigmail-Version: 1.6a1pre Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2DGIEKSALKTCCBCFQTINU" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 94.23.66.90 Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2013 18:46:39 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2DGIEKSALKTCCBCFQTINU Content-Type: multipart/mixed; boundary="------------030403060005020508080806" This is a multi-part message in MIME format. --------------030403060005020508080806 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Nella citazione in data ven 09 ago 2013 04:39:35 CEST, Andrey Borzenkov ha scritto: > > This condition sounds strange. Should it not be " =3D=3D ZEC_MAGIC"? > Obviously you're right! Thanks for catching this! I've attached the updated patch. Massimo Maggi --------------030403060005020508080806 Content-Type: text/x-patch; name="0001-ZFS-label-detection-improvements.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-ZFS-label-detection-improvements.patch" =46rom 7270d3fe49fbaf168897f84b0cc75cd4450264f6 Mon Sep 17 00:00:00 2001 From: Massimo Maggi Date: Fri, 9 Aug 2013 00:39:33 +0200 Subject: [PATCH] ZFS label detection improvements. In order to not let zfs code mistakenly analyze a block device as a ZFS filesystem when it contains some other filesystem,let's analyze better the label and fail as soon as possible. In details: * Check the magic number of the zio_eck_t in the vdev_phys_t structu= re, which is the first possible magic number met when analyzing a bloc= k device. * Verify the SHA256 checksum of the vdev_phys_t structure, which contains the nvlists that are going to be read later. Signed-off-by: Massimo Maggi --- grub-core/fs/zfs/zfs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index f4acfd8..54d2612 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -969,6 +969,9 @@ check_pool_label (struct grub_zfs_data *data, grub_uint64_t version; int found; grub_err_t err; + int endian; + vdev_phys_t *phys; + zio_cksum_t emptycksum; =20 *inserted =3D 0; =20 @@ -976,6 +979,28 @@ check_pool_label (struct grub_zfs_data *data, if (err) return err; =20 + phys=3D(vdev_phys_t*)nvlist; + if( grub_zfs_to_cpu64(phys->vp_zbt.zec_magic, + GRUB_ZFS_LITTLE_ENDIAN) =3D=3D ZEC_MAGIC) + { + endian =3D GRUB_ZFS_LITTLE_ENDIAN; + } + else if(grub_zfs_to_cpu64(phys->vp_zbt.zec_magic, + GRUB_ZFS_BIG_ENDIAN) =3D=3D ZEC_MAGIC) + { + endian =3D GRUB_ZFS_BIG_ENDIAN; + } + else + { + grub_error (GRUB_ERR_BAD_FS, "bad vdev_phys_t.vp_zbt.zec_magic num= ber"); + return grub_errno; + } + // Now check the integrity of the vdev_phys_t structure though checksu= m. + ZIO_SET_CHECKSUM(&emptycksum, diskdesc->vdev_phys_sector << 9, 0, 0, 0= ); + err =3D zio_checksum_verify (emptycksum, ZIO_CHECKSUM_LABEL, endian, n= vlist, VDEV_PHYS_SIZE); + if(err) + return err; + grub_dprintf ("zfs", "check 2 passed\n"); =20 found =3D grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STA= TE, --=20 1.8.2.1 --------------030403060005020508080806-- ------enig2DGIEKSALKTCCBCFQTINU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSBTkEAAoJEEO073X3hHDODHIH/RVVOqeA4CWDuVLWRYFcFwL8 wwO2OPUNuHe0I4cip7PfU+Of6MZvE/mJeo2JRkD48nDi8952J+e53VF4V1MoHQB0 a+SLsZdeA6rHK5CCuGGCGGOfR8Wfp+AkhkS/w8fKxTNHVnCaisXKQQe7jVKMBEkE Clgu76UiqhNNzQ15nUoAPJmY3edbcKe5GkRkxsJ8uoPes7+aQFsl1+n1TWkT/JXx zE/wODPtozvIjGeNggCIYrt5rCgqz1RfjevHmIVwCDfT3ZdvQo7ER6IFUufNnsRo GfkgBithhE9mcDE7xid34GG4XviVMc16IWuLGd9NXB975bzGVl+SfDZbXlLZtLI= =qw+j -----END PGP SIGNATURE----- ------enig2DGIEKSALKTCCBCFQTINU--