From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kluBk-0000Bz-Jo for mharc-grub-devel@gnu.org; Sun, 06 Dec 2020 08:34:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kluBi-000092-Ud for grub-devel@gnu.org; Sun, 06 Dec 2020 08:34:55 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:38815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kluBZ-0004k9-1Q for grub-devel@gnu.org; Sun, 06 Dec 2020 08:34:54 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4AE999F4; Sun, 6 Dec 2020 08:34:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 06 Dec 2020 08:34:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=jEQYiIPxz29P9v+wUKj9Te/G2JF jbBETkzGvE1q04n8=; b=rkc6uLO9LG8uueXeO/bG+LHc8mJ5uYXaUOsJ/gn7sIy UceOVtgs+p+xrZzIuvQtRfSJwfIXmrZ83OgkVZZB7F65Nsg/ZpNCUlk8d6uNM0fd FZYsnbzDrU92X3nQXnNwMXCI/1+EVc1i8xmhS4Qhcvtvj0HX6ELO665fzM0/fHA4 8c1BmNiOGqhQTFv5WJBep21lZAd/Vg3zp4KdHxXmPuSUQdCa5lM0kc0FhHWfgbuw WXg6f0ukKSZYOeV//A5D6LQBNScTuJTbH7qxD9mtR31He4nH/GQ+Fgod8Zvqxpi/ 7CpCSYkX9imlWvuUZ5ZOYWiIHA7Nlv/IL0J2zvmUMhw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=jEQYiI Pxz29P9v+wUKj9Te/G2JFjbBETkzGvE1q04n8=; b=UwmiCfFs/gdOjxTHaR+sau z65sF805ypsu2HXRVa8Q1qVfNzHRCj6cNEr5IMU/FKVzVUoe7+pAehALm2t0id6D NeZ72JQoEO6IzvfrOv1YtWHGDa8d5inTuZV7YEbSaXm2TBkpV4XiiIpazEZZN+2w GWa4ArTx8W5dNjt7pYhAaQNaKYjgl6FJLoPArDJVC2R5ne0GJL+CgMuBi+OwTqjC 9+6CtP1sywIa1WVTIl33INklBEwH8ka8SzqA5yNEUWJP5wKlINJbgDwIxm0UCSnw A7hgPZvh/FV9zDoTWumtInGiTfr6vhKacTF18Hfnkga+Fc+NwDCjKI322HNTWG2A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejvddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeejrddukeefrddujedruddutdenucevlhhushhtvghrufhiiigvpeegnecurf grrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail (x4db7116e.dyn.telefonica.de [77.183.17.110]) by mail.messagingengine.com (Postfix) with ESMTPA id 1D676108005B; Sun, 6 Dec 2020 08:34:40 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail (OpenSMTPD) with ESMTPSA id adfca42b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 6 Dec 2020 13:34:38 +0000 (UTC) Date: Sun, 6 Dec 2020 14:34:37 +0100 From: Patrick Steinhardt To: Glenn Washburn Cc: grub-devel@gnu.org, Daniel Kiper , Daniel Kiper Subject: Re: [PATCH v7 10/17] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors Message-ID: References: <7e8f242d12ba35fb70656e8f44650726e69143f8.1607098915.git.development@efficientek.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="H8eArRFlK8gBZpyV" Content-Disposition: inline In-Reply-To: <7e8f242d12ba35fb70656e8f44650726e69143f8.1607098915.git.development@efficientek.com> Received-SPF: pass client-ip=64.147.123.24; envelope-from=ps@pks.im; helo=wout1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Dec 2020 13:34:55 -0000 --H8eArRFlK8gBZpyV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 04, 2020 at 10:43:39AM -0600, Glenn Washburn wrote: > We need to convert the sectors from the size of the underlying device to = the > cryptodisk sector size; segment.size is in bytes which need to be convert= ed > to cryptodisk sectors as well. >=20 > Also, removed an empty statement. >=20 > Reviewed-by: Daniel Kiper > Signed-off-by: Glenn Washburn Reviewed-by: Patrick Steinhardt > --- > grub-core/disk/luks2.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) >=20 > diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c > index 4be40b22b..bdf40768b 100644 > --- a/grub-core/disk/luks2.c > +++ b/grub-core/disk/luks2.c > @@ -429,7 +429,7 @@ luks2_decrypt_key (grub_uint8_t *out_key, > grub_uint8_t salt[GRUB_CRYPTODISK_MAX_KEYLEN]; > grub_uint8_t *split_key =3D NULL; > grub_size_t saltlen =3D sizeof (salt); > - char cipher[32], *p;; > + char cipher[32], *p; > const gcry_md_spec_t *hash; > gcry_err_code_t gcry_ret; > grub_err_t ret; > @@ -615,9 +615,10 @@ luks2_recover_key (grub_disk_t source, > crypt->log_sector_size =3D sizeof (unsigned int) * 8 > - __builtin_clz ((unsigned int) segment.sector_size) - 1; > if (grub_strcmp (segment.size, "dynamic") =3D=3D 0) > - crypt->total_sectors =3D grub_disk_get_size (source) - crypt->offset_se= ctors; > + crypt->total_sectors =3D (grub_disk_get_size (source) >> (crypt->log_se= ctor_size - source->log_sector_size)) > + - crypt->offset_sectors; > else > - crypt->total_sectors =3D grub_strtoull (segment.size, NULL, 10); > + crypt->total_sectors =3D grub_strtoull (segment.size, NULL, 10) >> cryp= t->log_sector_size; > =20 > ret =3D luks2_decrypt_key (candidate_key, source, crypt, &keyslot, > (const grub_uint8_t *) passphrase, grub_strlen (passphrase)); > --=20 > 2.27.0 >=20 --H8eArRFlK8gBZpyV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl/M3e0ACgkQVbJhu7ck PpRHwBAAmUtJtejTjAdLLzZ8OrE/sZrjq3nIi/4apirIiw0BFY3+BBPoSgvIG/9D qcpsuZNyuufjvksAv57GnXqsyEzpERcic9eGjo6e5Tr3j4OXbojGinJB+5QEz475 LDlkoKOpawTyObUmEfMLqU74KCA47kIrTI5J9HTLiswXGy7lT0Sas2EOW6H+/xgC eN5I5Ke7k5RZPhdu1Vp2lBbF69v9qUL+k5wKHXy/SOjW1egTTFVL8ntmMwAAJlw0 Wy3WuB/dHIQKPnBRnLDlsRFIvV4gbzonTYVUqnzaMziIeNvpBcZWjgeZ6Syo/uCc Tmhp/zNKXAvV6RXGrDcva7PN2iX/kF5ngezdzMTeNhv0w15A2m2l52kIz3tzrCDY JRbdoElXxSCJ/h4357kKYBqnYAFGIJq39m65XevcAcS2wWMl7HYqs89CUTNtxsWw LgQ2ure7WMj9X4rjSonhiB4uqn5te6gMCsE02AEAtpRKfurTrwIAYi/Ijk+C0jWz 6uAqs5IJZ1u7uo743FZXSXl455gMrAWp8IymsSgB44RXf52jKYCCWFdMaZXd413K 6YuUl6grrWYwHjNZ/9cY653jC0GzsbmajTm1I43CoWL2nBWLZ7y8DXDEoGF/aRbQ Noggvmu+HJBw/8r4ZHLlY80T/QmaZBoLKCB0KXf77Y2yEXwFDOE= =OiyW -----END PGP SIGNATURE----- --H8eArRFlK8gBZpyV--