From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1keEUN-0007Ds-5t for mharc-grub-devel@gnu.org; Sun, 15 Nov 2020 04:38:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keEUL-0007Cf-A4 for grub-devel@gnu.org; Sun, 15 Nov 2020 04:38:25 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:57397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keEUJ-0000Bz-Du for grub-devel@gnu.org; Sun, 15 Nov 2020 04:38:25 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 06CD65C00C8; Sun, 15 Nov 2020 04:38:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 15 Nov 2020 04:38:23 -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=f+gi+10SxxbowuwIh1yVSxRIPg0 yDv+AGQVUUulArEU=; b=XeEwEi3TTSJQ0TgEws9nn9RIOl2dZRHXDZYUuiJg0bO vUtNuuoQJJ7DXUfSbSwST24OGBEDnXQ06K/YWB0fuuN7vII5wCunYSIqCOgk7mF5 jrcuCGioYrcH1KSjv3o0g1QUrLtJDAGixbIn1Tbpb/3tw0/OPYEYO/YDBN0O42At 6zkCmxP9nwhHTiG/qTDVgsPs2DeD+Gubfti8eGDKLLINpN1VLtFowzOe8+4zg6Y7 iO5jLre7WAMkkmZrmX1rotoE9//n6ZYZh1rBXc26htrrB0OZNe1AObHTSGuJ8tef oF7GJmg1khIi+tfw1Nvkkx677Wa14MIXLvsx8SS6jYg== 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=f+gi+1 0SxxbowuwIh1yVSxRIPg0yDv+AGQVUUulArEU=; b=BfUo7ABPxlfUCTmILVtxxa DOj5tvK2jP0XRYImsiYqDq6iztbn9Ws5OjS/M0roWGpeqk8E4bEWJcf10oFAH4rJ 0weXmuFOJYUPZuJjDj9oDoKCCfDR6tXdoBr8adVETphNXkhRYaBFdW74tvW50NXw 9gqqbKOxf4XbbA+iokkRmuwt9dJrdYA/iPNsiNJBwaVaRSL4qbG4Rlox7xUvhdCu J5F3wo8rIuhaFmlnXYAnJXp+CSJC4lLrXc8wVTd3G8gAMN5pPXegRJ+o+94HiH/2 7oCuH+QB2DzKdgf6FDtkl/PuCozQl6tW01Y8xgSTUlq78Gt4pcb1WJdMaeQK7Mng == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeekrdehgedrvddurddvtdeinecuvehluhhsthgvrhfuihiivgepudenucfrrg hrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Received: from vm-mail.pks.im (dynamic-078-054-021-206.78.54.pool.telefonica.de [78.54.21.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 376DD3064AA6; Sun, 15 Nov 2020 04:38:22 -0500 (EST) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 8e198113 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 15 Nov 2020 09:38:20 +0000 (UTC) Date: Sun, 15 Nov 2020 10:38:18 +0100 From: Patrick Steinhardt To: Glenn Washburn Cc: grub-devel@gnu.org, Daniel Kiper Subject: Re: [PATCH v4 02/15] cryptodisk: Rename offset in grub_cryptodisk_t to offset_sectors. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xBBdEOhF8AZVxcbe" Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=66.111.4.27; envelope-from=ps@pks.im; helo=out3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 04:37:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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: Sun, 15 Nov 2020 09:38:25 -0000 --xBBdEOhF8AZVxcbe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 06, 2020 at 10:44:22PM -0600, Glenn Washburn wrote: > This makes it clear that the offset represents sectors, not bytes, in ord= er > to improve readability. >=20 > Signed-off-by: Glenn Washburn Reviewed-by: Patrick Steinhardt > --- > grub-core/disk/cryptodisk.c | 10 +++++----- > grub-core/disk/geli.c | 2 +- > grub-core/disk/luks.c | 4 ++-- > grub-core/disk/luks2.c | 4 ++-- > include/grub/cryptodisk.h | 7 ++++++- > 5 files changed, 16 insertions(+), 11 deletions(-) >=20 > diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c > index 3703da221..473c93976 100644 > --- a/grub-core/disk/cryptodisk.c > +++ b/grub-core/disk/cryptodisk.c > @@ -754,10 +754,10 @@ grub_cryptodisk_read (grub_disk_t disk, grub_disk_a= ddr_t sector, > grub_dprintf ("cryptodisk", > "Reading %" PRIuGRUB_SIZE " sectors from sector 0x%" > PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T "\n", > - size, sector, dev->offset); > + size, sector, dev->offset_sectors); > =20 > err =3D grub_disk_read (dev->source_disk, > - grub_disk_from_native_sector (disk, sector + dev->offset), > + grub_disk_from_native_sector (disk, sector + dev->offset_sectors), > 0, size << disk->log_sector_size, buf); > if (err) > { > @@ -803,7 +803,7 @@ grub_cryptodisk_write (grub_disk_t disk, grub_disk_ad= dr_t sector, > grub_dprintf ("cryptodisk", > "Writing %" PRIuGRUB_SIZE " sectors to sector 0x%" > PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T "\n", > - size, sector, dev->offset); > + size, sector, dev->offset_sectors); > =20 > gcry_err =3D grub_cryptodisk_endecrypt (dev, (grub_uint8_t *) tmp, > size << disk->log_sector_size, > @@ -815,7 +815,7 @@ grub_cryptodisk_write (grub_disk_t disk, grub_disk_ad= dr_t sector, > } > =20 > /* Since ->write was called so disk.mod is loaded but be paranoid */ > - sector =3D sector + dev->offset; > + sector =3D sector + dev->offset_sectors; > if (grub_disk_write_weak) > err =3D grub_disk_write_weak (dev->source_disk, > grub_disk_from_native_sector (disk, sector), > @@ -1228,7 +1228,7 @@ luks_script_get (grub_size_t *sz) > ptr =3D grub_stpcpy (ptr, "luks_mount "); > ptr =3D grub_stpcpy (ptr, i->uuid); > *ptr++ =3D ' '; > - grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset); > + grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset_sectors); > while (*ptr) > ptr++; > for (iptr =3D i->cipher->cipher->name; *iptr; iptr++) > diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c > index 4ec875821..0175ce4c4 100644 > --- a/grub-core/disk/geli.c > +++ b/grub-core/disk/geli.c > @@ -361,7 +361,7 @@ configure_ciphers (grub_disk_t disk, const char *chec= k_uuid, > } > newdev->cipher =3D cipher; > newdev->secondary_cipher =3D secondary_cipher; > - newdev->offset =3D 0; > + newdev->offset_sectors =3D 0; > newdev->source_disk =3D NULL; > newdev->benbi_log =3D 0; > if (grub_le_to_cpu16 (header.alg) =3D=3D 0x16) > diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c > index 429db4ad8..aa9877b68 100644 > --- a/grub-core/disk/luks.c > +++ b/grub-core/disk/luks.c > @@ -122,10 +122,10 @@ configure_ciphers (grub_disk_t disk, const char *ch= eck_uuid, > newdev =3D grub_zalloc (sizeof (struct grub_cryptodisk)); > if (!newdev) > return NULL; > - newdev->offset =3D grub_be_to_cpu32 (header.payloadOffset); > + newdev->offset_sectors =3D grub_be_to_cpu32 (header.payloadOffset); > newdev->source_disk =3D NULL; > newdev->log_sector_size =3D 9; > - newdev->total_sectors =3D grub_disk_get_size (disk) - newdev->offset; > + newdev->total_sectors =3D grub_disk_get_size (disk) - newdev->offset_s= ectors; > grub_memcpy (newdev->uuid, uuid, sizeof (uuid)); > newdev->modname =3D "luks"; > =20 > diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c > index 3173a098d..26fb14a12 100644 > --- a/grub-core/disk/luks2.c > +++ b/grub-core/disk/luks2.c > @@ -605,11 +605,11 @@ luks2_recover_key (grub_disk_t disk, > grub_dprintf ("luks2", "Trying keyslot %"PRIuGRUB_SIZE"\n", i); > =20 > /* Set up disk according to keyslot's segment. */ > - crypt->offset =3D grub_divmod64 (segment.offset, segment.sector_si= ze, NULL); > + crypt->offset_sectors =3D grub_divmod64 (segment.offset, segment.s= ector_size, NULL); > 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 (disk) - crypt->offset; > + crypt->total_sectors =3D grub_disk_get_size (disk) - crypt->offset_sect= ors; > else > crypt->total_sectors =3D grub_strtoull (segment.size, NULL, 10); > =20 > diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h > index 21dc69501..258b777bf 100644 > --- a/include/grub/cryptodisk.h > +++ b/include/grub/cryptodisk.h > @@ -66,7 +66,12 @@ struct grub_cryptodisk > struct grub_cryptodisk **prev; > =20 > char *source; > - grub_disk_addr_t offset; > + > + /* > + * The number of sectors the start of the encrypted data is offset int= o the > + * underlying disk, where sectors are the size noted by log_sector_siz= e. > + */ > + grub_disk_addr_t offset_sectors; > /* Total number of encrypted sectors of size (1< grub_disk_addr_t total_sectors; > grub_disk_t source_disk; > --=20 > 2.27.0 >=20 --xBBdEOhF8AZVxcbe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl+w9woACgkQVbJhu7ck PpTDuhAAghEh0DzO5atW4N3yMmJkbw1zYOP4k5gLW+MfM9LUF76BJ044K90vDVgG pfZNb3aWK4580wKPkzavJ6Q1WmH/8HcG1NnpoOI47xjwUzu5ZuMarB5WwX+5lTfC zDQ7dj77BMhT/JrYWHKeel+4b2h7pP8/E7I1rH8+mbTVS5aca+9Tz9QxGMik61RW UO8RWcFCcSlOl9kMK+b8qq+NAysYzQO16sS9KFKpnAn95YWotP/uxIC4rUBiKQOD h7KsB9zK3C8SeLal+ikBExVJHemidHa5lwTSVo2kxdS1uT0JQOuaO3BOtOfMGMux 7AMJ531tt40UkuMZhphA84tnqlFt9lpakqaa0/Y6AY/Zc1EQiErbILILjA+JZseD f4Q6/YDbQwWRwhHCekaPAESaoSp9nWzJufqOkiVFr4Q70wheegv1lgNWDfKV29lx j6b36KdtvG6AgFFC/2VcYz7Eag3bt7HB3b2mTo4MLirqn2kPN+qOGkV7skokZFWg oZLXPrGUWIYrQStmJ1ZOCSYfBzuPn8Gw1NHxIBnzMIYFe2oQIwBCD9xXwrzJouQo Z1MPeiWrwhDHXTPqqGJaMCD9F/6dYrAmI2/VCkFBh0QFPjzLciyP/6bh8T8GFNTa fDZikh8/EzReO4O/JgzyK8rKiTTzmXJBWafXFQ+dWSoWUEyIHBw= =Z85E -----END PGP SIGNATURE----- --xBBdEOhF8AZVxcbe--