From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mxt3B-00047z-DY for mharc-grub-devel@gnu.org; Thu, 16 Dec 2021 10:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxt38-00046P-Bk for grub-devel@gnu.org; Thu, 16 Dec 2021 10:52:07 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:60638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxt36-0005Jx-6e for grub-devel@gnu.org; Thu, 16 Dec 2021 10:52:06 -0500 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4CCA821135; Thu, 16 Dec 2021 15:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1639669921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1fPKa56TKNsq7qSYf3xsFbdoHxounMcCvVRCofIHUlg=; b=UOMHAlo+Z+l3BIs8xuc8dd0AsHnPgqkepmThZmb2aWjC1L4xqFYQsVUjJPCwXrBitKypqO q0HTwMy05eIOtF+pTUByLLxtbIjR3TtH1XBQGOOnqVc7M3GA0/MS0LZ9Sas6X8Eer+pIuR AXeaYFCeePlRbCnFgbrQf1OVNrRsobQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1639669921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1fPKa56TKNsq7qSYf3xsFbdoHxounMcCvVRCofIHUlg=; b=/De1m+4bwS8TT2NL+SULLCqx7uisnTxOQ918elIUe9CofkTSQFPYYApqRi4xqkMJw6Ki9E w9PCv2+50sBvioCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 13AE713E96; Thu, 16 Dec 2021 15:52:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sDuIAqFgu2HDNQAAMHmgww (envelope-from ); Thu, 16 Dec 2021 15:52:01 +0000 From: Fabian Vogt To: The development of GNU GRUB , Patrick Steinhardt Cc: Michael Chang , Josselin Poiret Subject: Re: [PATCH 3/4] luks2: set up dummy sector size during scan Date: Thu, 16 Dec 2021 16:52:00 +0100 Message-ID: <43151052.QDiU1Cuimh@linux-e202.suse.de> In-Reply-To: References: <20210806045110.GA4099@mercury> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: pass client-ip=195.135.220.28; envelope-from=fvogt@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_NONE=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.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Dec 2021 15:52:07 -0000 Hi, (I *finally* got to this topic again...) Am Sonntag, 8. August 2021, 16:20:12 CET schrieb Patrick Steinhardt: > On Fri, Aug 06, 2021 at 12:51:10PM +0800, Michael Chang via Grub-devel wrote: > [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; > > > > /* Try to open disk. */ > > source = grub_disk_open (sourcedev); > > @@ -1062,6 +1063,25 @@ grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat) > > if (!dev) > > continue; > > > > + /* Use the sector size and count of the cheat device */ > > + dev->cheat_fd = 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 = grub_util_get_fd_size (dev->cheat_fd, cheat, &cheat_sector_size); > > + if (dev->total_sectors == -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. Agreed. > > + dev->log_sector_size = cheat_sector_size; > > + dev->total_sectors >>= dev->log_sector_size; > > + grub_util_fd_close (dev->cheat_fd); > > + dev->cheat_fd = 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. A bit, yes, but the alternative is having a variable "int cheat_fd" which makes it more confusing IMO. I'm fine with either option. > 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. Feel free to incorporate it, or I can refine it and resend as v2. (I'll most likely get to the latter only in the next year though) It looks like we have a third patch (series) for this feature meanwhile: [PATCH 0/2] Have LUKS2 cryptomounts be useable with grub-probe I CC'd the author, let's try to coordinate. Thanks, Fabian > Patrick