All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabian Vogt <fvogt@suse.de>
To: The development of GNU GRUB <grub-devel@gnu.org>,
	Patrick Steinhardt <ps@pks.im>
Cc: Michael Chang <mchang@suse.com>, Josselin Poiret <dev@jpoiret.xyz>
Subject: Re: [PATCH 3/4] luks2: set up dummy sector size during scan
Date: Thu, 16 Dec 2021 16:52:00 +0100	[thread overview]
Message-ID: <43151052.QDiU1Cuimh@linux-e202.suse.de> (raw)
In-Reply-To: <YQ/oHMKe4bX3fDOA@ncase>

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





  reply	other threads:[~2021-12-16 15:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-30 12:25 [PATCH 0/4] Probing support for LUKS2 Patrick Steinhardt
2020-05-30 12:25 ` [PATCH 1/4] luks: fix out-of-bounds copy of UUID Patrick Steinhardt
2020-06-06 23:32   ` Petr Vorel
2020-05-30 12:25 ` [PATCH 2/4] luks2: strip dashes off of the UUID Patrick Steinhardt
2020-09-15 14:30   ` Daniel Kiper
2020-05-30 12:25 ` [PATCH 3/4] luks2: set up dummy sector size during scan Patrick Steinhardt
2021-08-06  4:51   ` Michael Chang
2021-08-08 14:20     ` Patrick Steinhardt
2021-12-16 15:52       ` Fabian Vogt [this message]
2021-12-22 18:17         ` Josselin Poiret
2022-02-04 15:46           ` Fabian Vogt
2022-02-07 13:15             ` Josselin Poiret
2022-05-21  0:13               ` Glenn Washburn
2022-05-21 10:53                 ` Fabian Vogt
2022-06-13 14:29                 ` [PATCH v2] disk/cryptodisk: When cheatmounting, use the sector info of the cheat device Fabian Vogt
2022-06-14  2:19                   ` Glenn Washburn
2022-06-14 13:55                     ` [PATCH v3] " Fabian Vogt
2022-06-14 18:18                       ` Glenn Washburn
2022-06-21 15:40                       ` Patrick Steinhardt
2022-08-11 18:22                       ` Glenn Washburn
2020-05-30 12:25 ` [PATCH 4/4] osdep: detect LUKS2-encrypted devices Patrick Steinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43151052.QDiU1Cuimh@linux-e202.suse.de \
    --to=fvogt@suse.de \
    --cc=dev@jpoiret.xyz \
    --cc=grub-devel@gnu.org \
    --cc=mchang@suse.com \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.