grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Plenefisch <simonpatp@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Yixuan Guo <gyx@google.com>
Subject: Re: [PATCH] grub_diskfilter_memberlist: recurse into lv nodes.
Date: Sun, 14 Apr 2024 16:01:13 -0400	[thread overview]
Message-ID: <CAOCpoWdRrKpfzN4tO=Gq387HAoois13GE5=My5akW_Gfp9iJoQ@mail.gmail.com> (raw)
In-Reply-To: <20240414110356.30794-1-culu.gyx@gmail.com>

This may have some interaction with my pending LVM patches from
January & Febuary for a superficially similar issue on complex lv's.

My original patch:
https://lists.gnu.org/archive/html/grub-devel/2024-01/msg00110.html
Github branch with split patches:
https://github.com/byteit101/grub2/tree/grub-lvmintegrity

Patrick

On Sun, Apr 14, 2024 at 7:05 AM GUO Yixuan <culu.gyx@gmail.com> wrote:
>
> From: Yixuan Guo <gyx@google.com>
>
> This applies to lvm2 LVs with redundancy, which use internal LVs, so it's
> necessary to go into seg->nodes[j].lv to find the underlying PV.
>
> Example of a raid1 LV and its internal LVs, created with lvm2.
>
> ├─vdb3                        254:19   0  9.3G  0 part
> │ └─vdb3_crypt                253:3    0  9.3G  0 crypt
> │   ├─crypt--vg-root_rmeta_0  253:11   0    4M  0 lvm
> │   │ └─crypt--vg-root        253:15   0    1G  0 lvm
> │   └─crypt--vg-root_rimage_0 253:12   0    1G  0 lvm
> │     └─crypt--vg-root        253:15   0    1G  0 lvm
> ├─vdb4                        254:20   0  9.3G  0 part
> │ └─vdb4_crypt                253:4    0  9.3G  0 crypt
> │   ├─crypt--vg-root_rmeta_1  253:13   0    4M  0 lvm
> │   │ └─crypt--vg-root        253:15   0    1G  0 lvm
> │   └─crypt--vg-root_rimage_1 253:14   0    1G  0 lvm
> │     └─crypt--vg-root        253:15   0    1G  0 lvm
>
> Currently, grub-probe returns incomplete results for these LVs if their PVs
> are encrypted:
> $ grub-probe -t abstraction -d /dev/crypt-vg/root
> lvm
>
> This patch allows grub-probe to detect the underlying cryptodisk correctly:
> $ ./grub-probe -t abstraction -d /dev/crypt-vg/root
> cryptodisk
> luks2
> gcry_rijndael
> gcry_rijndael
> gcry_sha256
> cryptodisk
> luks2
> gcry_rijndael
> gcry_rijndael
> gcry_sha256
> lvm
>
> Signed-off-by: Yixuan Guo <gyx@google.com>
> ---
>  grub-core/disk/diskfilter.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
> index 21e239511..6c24cabce 100644
> --- a/grub-core/disk/diskfilter.c
> +++ b/grub-core/disk/diskfilter.c
> @@ -291,9 +291,8 @@ grub_diskfilter_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
>
>  #ifdef GRUB_UTIL
>  static grub_disk_memberlist_t
> -grub_diskfilter_memberlist (grub_disk_t disk)
> +grub_diskfilter_memberlist_lv (struct grub_diskfilter_lv *lv)
>  {
> -  struct grub_diskfilter_lv *lv = disk->data;
>    grub_disk_memberlist_t list = NULL, tmp;
>    struct grub_diskfilter_pv *pv;
>    grub_disk_pull_t pull;
> @@ -367,6 +366,20 @@ grub_diskfilter_memberlist (grub_disk_t disk)
>           tmp->next = list;
>           list = tmp;
>         }
> +      else if (seg->nodes[j].lv != NULL)
> +       {
> +         tmp = grub_diskfilter_memberlist_lv(seg->nodes[j].lv);
> +         if (tmp == NULL)
> +           goto fail;
> +         if (list != NULL)
> +           {
> +             grub_disk_memberlist_t tail = tmp;
> +             while (tail->next != NULL)
> +               tail = tail->next;
> +             tail->next = list;
> +           }
> +         list = tmp;
> +       }
>
>    return list;
>
> @@ -381,6 +394,13 @@ grub_diskfilter_memberlist (grub_disk_t disk)
>    return NULL;
>  }
>
> +static grub_disk_memberlist_t
> +grub_diskfilter_memberlist (grub_disk_t disk)
> +{
> +  struct grub_diskfilter_lv *lv = disk->data;
> +  return grub_diskfilter_memberlist_lv(lv);
> +}
> +
>  void
>  grub_diskfilter_get_partmap (grub_disk_t disk,
>                              void (*cb) (const char *pm, void *data),
> --
> 2.43.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

      reply	other threads:[~2024-04-14 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-14 11:03 [PATCH] grub_diskfilter_memberlist: recurse into lv nodes GUO Yixuan
2024-04-14 20:01 ` Patrick Plenefisch [this message]

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='CAOCpoWdRrKpfzN4tO=Gq387HAoois13GE5=My5akW_Gfp9iJoQ@mail.gmail.com' \
    --to=simonpatp@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=gyx@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).