From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ko02f-00032h-45 for mharc-grub-devel@gnu.org; Sat, 12 Dec 2020 03:14:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ko02d-00031w-SX for grub-devel@gnu.org; Sat, 12 Dec 2020 03:14:11 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:53391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ko02c-0004bv-5F for grub-devel@gnu.org; Sat, 12 Dec 2020 03:14:11 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C72AC76A; Sat, 12 Dec 2020 03:14:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 12 Dec 2020 03:14:09 -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=9lTSsp5vBunUdmkXZsr4wKPky97 ytOvNS7ZTLVwYuhc=; b=iCqbtpKWMWTPzZ7bhyf+/6oWRphNHV3EcQ2OYn1whz4 M+SpETEkeass8hWLiC1UNKB9WCOizGlZLLA4oIBWrTNeJo8hBSRwQxj800iRAfKG qwWxv7SlOsm03ogkmooxn7Ql8AWe16z3rG8G8vKc9SbyvafDJ7iCm2R3TNi4YDea FitN1e+qDyE2/LTIkv8mrCBIbtlzTaeslhw8hm4fFHgHQumbv1F1wSmkmeiq3LwW LkgLGJOG/KheRRUUE7AHIiJMY5b0uSVnYBEXQbUPGH7s0FSzNnAVQD95HJh33lKS utlVgir1TyM710IGXBrZLxiIDI5Oqop097rswJf+y/w== 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=9lTSsp 5vBunUdmkXZsr4wKPky97ytOvNS7ZTLVwYuhc=; b=KnS+TOsPf1xUvkzzJtvI62 uIfrxMP1xZO6kcCEL5xl/Qt8Y7MD57E57kp5cauEBI2lGOHWQ1QzZVWbV/Kp15wy dHSz20xzjucV3mZIm1QY9Bo5uxngKMhPfvX86Bfq2V9MkYEOfapLdrxHSjInpO4o 9lr9cUzV43kSHbAd8Fdj9IexeHXtnuuo1I30DV3k82ZvJglau/tnMjluhJnqoUBW KreP1wHieAXowmIaYbimAY0NOXQ1jjVGVwwCz+yXkqMSUYWEfaPRR5ldnCuQqcwj hjgAuEv1aS6njz8G1SPkbipnvcfSuxZf5z0TdFld1i4034o3jmmqFxllt3lz+oqQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudekfedguddulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfh necukfhppeejjedrudeluddruddtrdduleegnecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Received: from vm-mail (x4dbf0ac2.dyn.telefonica.de [77.191.10.194]) by mail.messagingengine.com (Postfix) with ESMTPA id 95ECD1080067; Sat, 12 Dec 2020 03:14:07 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail (OpenSMTPD) with ESMTPSA id cbbd4b32 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 12 Dec 2020 08:14:06 +0000 (UTC) Date: Sat, 12 Dec 2020 09:14:05 +0100 From: Patrick Steinhardt To: Glenn Washburn Cc: grub-devel@gnu.org, Daniel Kiper , Daniel Kiper Subject: Re: [PATCH v8 12/18] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="U7FCZC9ZSo09REDv" Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=64.147.123.25; envelope-from=ps@pks.im; helo=wout2-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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Sat, 12 Dec 2020 08:14:12 -0000 --U7FCZC9ZSo09REDv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 08, 2020 at 04:45:43PM -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 > Signed-off-by: Glenn Washburn > Reviewed-by: Daniel Kiper 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 ebf03e77b..429a4cfa1 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 --U7FCZC9ZSo09REDv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl/Ue8wACgkQVbJhu7ck PpRmTQ/8DWwfvTwASciRFahU49aFxDghb8De0HwngPMLQDer5taxU0VzUp2OwoaS 04s2tFTnC1rFP4AhDPodivDJtZGTmltAPBdq8zQXf4uf90XpE0acgy2jbvtr6hI8 EfxKwCAnrn6QoVGH5Ypi4RlcRHxX6m3WRN8uIXEKrZGCQMcWuj2oD6kOW5E8+ay6 va6WW3klEjnESVwaGleRPvCvgMTfayjnncMKFE8yS7F8dLBQgQVhcpWiauffBsF/ +fSA0t/R/zRqdc26TXuYZ7hps/WmnYNx44EKJMOOUxZOEYPaOyuitb9/XvQv5NPt nlLhMSZtfz7Os4v/RCsCcbnLjNTW+Lz9pIf/chMMQ2UsaFC8fAqyWaXpHOnOyMIS LnV386BAID5sHg6VzhQ6o7wx+9wEpgZ9Tamz2oxnktT0HpjMXqE45OWDnI5FXUJl 1mhUFuzG7lM1n1xl6OS0QazKpLG9yXJvkJ0xvjYLPYvlH/U5uTmI4HOOq8ZczQPx jSGiXC4J5K4ly8Kkkr5xG9hdBuysKhkI95R82cEAOVdmcmmMiYsMFaOyPy4/Y6U5 RJAWZSfBepHlXpQ2KViTtCppF29/vPFfmK7o4Wy67NYsRUbkhHXkcz6vACkUzoAv /ZKiC029+w8OIV6XKqZSnO/L/Q2TXEBuykGvBNkVQ3zTZrjRblo= =SrFV -----END PGP SIGNATURE----- --U7FCZC9ZSo09REDv--