[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/4] luks2: set up dummy sector size during scan
From: |
Fabian Vogt |
Subject: |
Re: [PATCH 3/4] luks2: set up dummy sector size during scan |
Date: |
Thu, 16 Dec 2021 16:52:00 +0100 |
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
- Re: [PATCH 3/4] luks2: set up dummy sector size during scan,
Fabian Vogt <=