From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mCjf5-0007LB-TX for mharc-grub-devel@gnu.org; Sun, 08 Aug 2021 10:20:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCjf4-0007Jd-87 for grub-devel@gnu.org; Sun, 08 Aug 2021 10:20:22 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCjf1-00045L-07 for grub-devel@gnu.org; Sun, 08 Aug 2021 10:20:22 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id A2A165C0125; Sun, 8 Aug 2021 10:20:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 08 Aug 2021 10:20:17 -0400 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=fm1; bh=miEYi8LuiWRctM1PZkVMsNdYCDv xmYd6o4N5tKrQ67Y=; b=GgBN9JMHXAo84clDumvTHRvNDE5iBHiu9eVkGdjhmTo 3LRNmDP62KrH2Qk/Pxzq3RPWZZHcQbaCGcuXNZlhna5IIBwdCjoCfLK0BX7g74Xy WBUgjOJzZ8BsNPoKw7wbVdmprClm608tOz+euHgoveZztpfXtY+zLPKqjwAOKZIm DTal3KrwoPZIT/Xpve+sGtl5tL+BEHxv0KmKk6zocTEaSNFX5LsLd2LhTFFff9un jmTf1SMNpTAKn4rXNj+lLsDUd6xL7sjFfNEJgvtBfi7mQm3Kd3O7mJ6kzGDTBTRm qYaSdKwf8nGhFlLMF68w3EJb1SqBjD3KKXScFxtV2Jw== 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=fm3; bh=miEYi8 LuiWRctM1PZkVMsNdYCDvxmYd6o4N5tKrQ67Y=; b=T96mq3P31+eWhdNns55Qll Dek8mkOW3vTmxmbxSm/9uDKDewOffl1033U4nm24CgicpZ9cinLOBcfinTD0V8jI ny2AqStEEwHDcuvDOvLOHUoffd2RfBcSQDWuNi8AmdecUSl4hUSi1q2I1i2qI0OO EkrAYYP2k1wWY6LDo7cbvK4M60/VcWGsoUGp+2HbYECKmHngpJSBX2RGvvIgCOZr heUm74I5NdBwwhEakkz/8fcES7PUEHq+Ptk56eo8CO/6H61FRsmVIrOT6cbWFkFF JvWgwiKZSn6Y9BBpehKj0gLuBqoqbRg/Bmg/4nhQjCXxHLubLXSS6I4HraVX2YFA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrjeehgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhrihgt khcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnh epheeghfdtfeeuffehkefgffduleffjedthfdvjeektdfhhedvlefgtefgvdettdfhnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkh hsrdhimh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Aug 2021 10:20:16 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 6b668885 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 8 Aug 2021 14:20:13 +0000 (UTC) Date: Sun, 8 Aug 2021 16:20:12 +0200 From: Patrick Steinhardt To: The development of GNU GRUB Cc: Michael Chang , Fabian Vogt Subject: Re: [PATCH 3/4] luks2: set up dummy sector size during scan Message-ID: References: <20210806045110.GA4099@mercury> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BFKbS0H+GnTH4qeq" Content-Disposition: inline In-Reply-To: <20210806045110.GA4099@mercury> Received-SPF: pass client-ip=66.111.4.25; envelope-from=ps@pks.im; helo=out1-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.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, 08 Aug 2021 14:20:22 -0000 --BFKbS0H+GnTH4qeq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 06, 2021 at 12:51:10PM +0800, Michael Chang via Grub-devel wrot= e: [snip] > diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c > index 90f82b2d3..c2bb2b6eb 100644 > --- a/grub-core/disk/cryptodisk.c > +++ b/grub-core/disk/cryptodisk.c > @@ -1040,6 +1040,7 @@ grub_cryptodisk_cheat_mount (const char *sourcedev,= const char *cheat) > grub_cryptodisk_t dev; > grub_cryptodisk_dev_t cr; > grub_disk_t source; > + unsigned int cheat_sector_size; > =20 > /* Try to open disk. */ > source =3D grub_disk_open (sourcedev); > @@ -1062,6 +1063,25 @@ grub_cryptodisk_cheat_mount (const char *sourcedev= , const char *cheat) > if (!dev) > continue; > =20 > + /* Use the sector size and count of the cheat device */ > + dev->cheat_fd =3D grub_util_fd_open (cheat, GRUB_UTIL_FD_O_RDONLY); > + if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd)) > + { > + grub_free (dev); > + return grub_errno; > + } > + dev->total_sectors =3D grub_util_get_fd_size (dev->cheat_fd, cheat, = &cheat_sector_size); > + if (dev->total_sectors =3D=3D -1) > + { > + grub_util_fd_close (dev->cheat_fd); > + grub_free (dev); > + return grub_errno; > + } We may want to print error messages for both error cases. Otherwise it's hard to tell why cheat mounting might've failed. > + dev->log_sector_size =3D cheat_sector_size; > + dev->total_sectors >>=3D dev->log_sector_size; > + grub_util_fd_close (dev->cheat_fd); > + dev->cheat_fd =3D GRUB_UTIL_FD_INVALID; Wouldn't it make more sense to just use a separate variable for the FD? Feels kind of weird to put it into `dev->cheat_fd`, only to clone and unset the member variable immediately after we're done again. In any case, thanks for the patch. It does look a lot more sensible compared to what I'd been doing. Do you want to keep owning the patch and try to upstream it, or shall I pick it up as part of this patch series? I'd of course retain author information. Patrick --BFKbS0H+GnTH4qeq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAmEP6BsACgkQVbJhu7ck PpRzog/+OviuWuXRT1DDVe2JHTeIQV6EnwO0XKnHqN+gxpXsYJq7jqzN2o0zFjv+ xwJlBsexK4pJeDGcVU2zVU/Jv9JuVKF++v8DVbKcJB7U4p679wxwRZcoMpER3Jpb tuGD8O0u3l3YTqJYr/FygdkNjxkg7aa7UIXdw1x8L/1Y0TnhjBCR6O1CZCwPFfxm aBp4qboQiobIAg/sv2uRB1BOUdZQ6rNtjdPIG+xeVWI45sF9pJakmpNfc0Z+G9vD 8OM4eizX2yylOjVvjaJwfbZmg8f4NfpGAgVvFN/F2Vh1gmQAtPWTaIhXA09VU9w0 VsvK3MPWudvbgddL1/0sRvFShdd72kd02++6aQLhLNx2AMWXv7HrHZUMCYq5LnIB 4uWohDw3r/2r8XJ8RlP/9IfuRq4/GkVxHZSM7ssQDezLhl0NP6QMRPZLuxEyOzsT rd2tn3oL9Sa4oMY5Ix+ygTljNXU6WBih1yRd23NUD7VB7ZaGR4ol6uwpmOt/F/vD K50P1hFbl6BV9Z0uduc7J3V25BI8c9i5Emrigk1c0F/k0ZSE0tknEVP9oAKUChVY qNOF5liFuSY0rc3kybtKnXwgCNQa/A+aUOvhRGS+W8o9p9/DatnBMmKf44I2edrl yGLQgQCDt0DhvzNp5z4nr8S10i4uCWuQIO63vdR+wCbrdfCLwS4= =RMqr -----END PGP SIGNATURE----- --BFKbS0H+GnTH4qeq--