Skip to contentSkip to conversation

LUKS1/2 testing in fs-tester and LUKS2 support in grub-probe

PATCH In review Glenn Washburn 4 participants 10 messages Jan 12, 2023 – Jan 25, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

cover LUKS1/2 testing in fs-tester and LUKS2 support in grub-probe

This series adds the testing of LUKS 1 and 2 encrypted container to the user-space fs tester. While this does replicate some of the testing done by grub_cmd_cryptomount, and is less flexible, it is run natively (that is without need for virtualization). It also tests the added LUKS2 support in grub-probe, unlike grub_cmd_cryptomount which does not test any user-space grub components.

All of these patches have previously been sent to the list. Only patch 4 has been slightly modified to fix some issues. Since utility of any one is greatly enhanced, and in the case of patch 4 required, by the others, I think it makes sense to evaluate them together.

Fabian has noted a memory leak with error handling when using LUKS2 with a null_cipher[1]. Since this isn't something that I expect to happen in the wild (why would you use an unencrypted LUKS container?) and even if it does occur grub-probe is exiting, so the leak would be very short lived, I don't think this is something that we need to worry about. It wouldn't be that hard to fix though, just annoying and add a little more complexity to the source.

The corresponding patches can be found in the order of this series here:
1: [PATCH v3] disk/cryptodisk: When cheatmounting, use the sector info of the cheat device

    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00106.html
 2: [PATCH v6 1/2] devmapper/getroot: Have devmapper recognize LUKS2
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00036.html
 3: [PATCH v6 2/2] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00038.html
 4: [PATCH v4] grub-fs-tester: Add luks1 and luks2 support
    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00127.html

Glenn

[1] https://lists.gnu.org/archive/html/grub-devel/2022-11/msg00032.html

Fabian Vogt (1):
disk/cryptodisk: When cheatmounting, use the sector info of the cheat
device

Josselin Poiret (2):
devmapper/getroot: Have devmapper recognize LUKS2 devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM
parameters

Pierre-Louis Bonicoli (1):
grub-fs-tester: Add luks1 and luks2 support

 .gitignore                          |   2 +
 Makefile.util.def                   |  12 +++
 grub-core/disk/cryptodisk.c         |  20 ++++-
 grub-core/osdep/devmapper/getroot.c | 118 ++++++++++++++++++++++++++--
 tests/luks1_test.in                 |  23 ++++++
 tests/luks2_test.in                 |  23 ++++++
 tests/util/grub-fs-tester.in        |  57 +++++++++++++-
 7 files changed, 246 insertions(+), 9 deletions(-)
 create mode 100644 tests/luks1_test.in
 create mode 100644 tests/luks2_test.in
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/4 devmapper/getroot: Have devmapper recognize LUKS2

From: Josselin Poiret <[email protected]>

Changes UUID comparisons so that LUKS1 and LUKS2 are both recognized as being LUKS cryptodisks.

---
 grub-core/osdep/devmapper/getroot.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
grub-core/osdep/devmapper/getroot.c +7 -4
index 9ba5c98655..2bf4264cf0 100644
@@ -138,7 +138,8 @@ grub_util_get_dm_abstraction (const char *os_dev)
       grub_free (uuid);
       return GRUB_DEV_ABSTRACTION_LVM;
     }
-  if (strncmp (uuid, "CRYPT-LUKS1-", 12) == 0)
+  if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+      || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
     {
       grub_free (uuid);
       return GRUB_DEV_ABSTRACTION_LUKS;
@@ -179,7 +180,9 @@ grub_util_pull_devmapper (const char *os_dev)
 	  grub_util_pull_device (subdev);
 	}
     }
-  if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+  if (uuid
+      && (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+          || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
       && lastsubdev)
     {
       char *grdev = grub_util_get_grub_dev (lastsubdev);
@@ -253,11 +256,11 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
       {
 	char *dash;
 
-	dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
+	dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS*-") - 1, '-');
 	if (dash)
 	  *dash = 0;
 	grub_dev = grub_xasprintf ("cryptouuid/%s",
-				   uuid + sizeof ("CRYPT-LUKS1-") - 1);
+				   uuid + sizeof ("CRYPT-LUKS*-") - 1);
 	grub_free (uuid);
 	return grub_dev;
       }
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/4 devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters

In reply to Glenn Washburn

From: Josselin Poiret <[email protected]>

This lets a LUKS2 cryptodisk have its cipher and hash filled out, otherwise they wouldn't be initialized if cheat mounted.

---
 grub-core/osdep/devmapper/getroot.c | 107 +++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
grub-core/osdep/devmapper/getroot.c +106 -1
index 2bf4264cf0..090ac71670 100644
@@ -51,6 +51,8 @@
 #include <grub/emu/misc.h>
 #include <grub/emu/hostdisk.h>
 
+#include <grub/cryptodisk.h>
+
 static int
 grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
 		   struct dm_tree_node **node)
@@ -186,7 +188,6 @@ grub_util_pull_devmapper (const char *os_dev)
       && lastsubdev)
     {
       char *grdev = grub_util_get_grub_dev (lastsubdev);
-      dm_tree_free (tree);
       if (grdev)
 	{
 	  grub_err_t err;
@@ -194,7 +195,111 @@ grub_util_pull_devmapper (const char *os_dev)
 	  if (err)
 	    grub_util_error (_("can't mount encrypted volume `%s': %s"),
 			     lastsubdev, grub_errmsg);
+          if (strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
+            {
+              /*
+               * set LUKS2 cipher from dm parameters, since it is not
+               * possible to determine the correct one without
+               * unlocking, as there might be multiple segments.
+               */
+              grub_disk_t source;
+              grub_cryptodisk_t cryptodisk;
+              grub_uint64_t start, length;
+              char *target_type;
+              char *params;
+              const char *name;
+              char *cipher, *cipher_mode;
+              struct dm_task *dmt;
+              char *seek_head, *c;
+              unsigned int remaining;
+
+              source = grub_disk_open (grdev);
+              if (! source)
+                grub_util_error (_("cannot open grub disk `%s'"), grdev);
+              cryptodisk = grub_cryptodisk_get_by_source_disk (source);
+              if (! cryptodisk)
+                grub_util_error (_("cannot get cryptodisk from source disk `%s'"), grdev);
+              grub_disk_close (source);
+
+              /*
+               * the following function always returns a non-NULL pointer,
+               * but the string may be empty if the relevant info is not present
+               */
+              name = dm_tree_node_get_name (node);
+              if (grub_strlen (name) == 0)
+                grub_util_error (_("cannot get dm node name for grub dev `%s'"), grdev);
+
+              grub_util_info ("populating parameters of cryptomount `%s' from DM device `%s'",
+                              uuid, name);
+
+              dmt = dm_task_create (DM_DEVICE_TABLE);
+              if (dmt == NULL)
+                grub_util_error (_("can't create dm task DM_DEVICE_TABLE"));
+              if (dm_task_set_name (dmt, name) == 0)
+                grub_util_error (_("can't set dm task name to `%s'"), name);
+              if (dm_task_run (dmt) == 0)
+                grub_util_error (_("can't run dm task for `%s'"), name);
+              /*
+               * dm_get_next_target doesn't have any error modes, everything has
+               * been handled by dm_task_run.
+               */
+              dm_get_next_target (dmt, NULL, &start, &length,
+                                  &target_type, &params);
+              if (strncmp (target_type, "crypt", sizeof ("crypt")) != 0)
+                grub_util_error (_("dm target of type `%s' is not `crypt'"), target_type);
+
+              /*
+               * dm target parameters for dm-crypt is
+               * <cipher> <key> <iv_offset> <device path> <offset> [<#opt_params> <opt_param1> ...]
+               */
+              c = params;
+              remaining = grub_strlen (c);
+
+              /* first, get the cipher name from the cipher */
+              seek_head = grub_memchr (c, '-', remaining);
+              if (seek_head == NULL)
+                grub_util_error (_("can't get cipher from dm-crypt parameters `%s'"),
+                                 params);
+              cipher = grub_strndup (c, seek_head - c);
+              if (cipher == NULL)
+                grub_util_error (_("could not strndup cipher of length `%lu'"), seek_head - c);
+              remaining -= seek_head - c + 1;
+              c = seek_head + 1;
+
+              /* now, the cipher mode */
+              seek_head = grub_memchr (c, ' ', remaining);
+              if (seek_head == NULL)
+                grub_util_error (_("can't get cipher mode from dm-crypt parameters `%s'"),
+                                 params);
+              cipher_mode = grub_strndup (c, seek_head - c);
+              if (cipher_mode == NULL)
+                grub_util_error (_("could not strndup cipher_mode of length `%lu'"), seek_head - c);
+
+              remaining -= seek_head - c + 1;
+              c = seek_head + 1;
+
+              err = grub_cryptodisk_setcipher (cryptodisk, cipher, cipher_mode);
+              if (err)
+                  grub_util_error (_("can't set cipher of cryptodisk `%s' to `%s' with mode `%s'"),
+                                   uuid, cipher, cipher_mode);
+
+              grub_free (cipher);
+              grub_free (cipher_mode);
+
+              /*
+               * This is the only hash usable by PBKDF2, and we don't
+               * have Argon2 support yet, so set it by default,
+               * otherwise grub-probe would miss the required
+               * abstraction
+               */
+              cryptodisk->hash = grub_crypto_lookup_md_by_name ("sha256");
+              if (cryptodisk->hash == NULL)
+                  grub_util_error (_("can't lookup hash sha256 by name"));
+
+              dm_task_destroy (dmt);
+            }
 	}
+      dm_tree_free (tree);
       grub_free (grdev);
     }
   else
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 disk/cryptodisk: When cheatmounting, use the sector info of the cheat device

In reply to Glenn Washburn

From: Fabian Vogt <[email protected]>

When using grub-probe with cryptodisk, the mapped block device from the host is used directly instead of decrypting the source device in GRUB code. In that case, the sector size and count of the host device needs to be used. This is especially important when using luks2, which does not assign total_sectors and log_sector_size when scanning, but only later when the segments in the JSON area are evaluated. With an unset log_sector_size, grub_open_device complains.

This fixes grub-probe failing with
"error: sector sizes of 1 bytes aren't supported yet."

---
 grub-core/disk/cryptodisk.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
grub-core/disk/cryptodisk.c +18 -2
index 14308822aa..ed1769eabb 100644
@@ -718,16 +718,31 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk)
   if (!dev)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such device");
 
-  disk->log_sector_size = dev->log_sector_size;
-
 #ifdef GRUB_UTIL
   if (dev->cheat)
     {
+      grub_uint64_t cheat_dev_size;
+      unsigned int cheat_log_sector_size;
+
       if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd))
 	dev->cheat_fd = grub_util_fd_open (dev->cheat, GRUB_UTIL_FD_O_RDONLY);
       if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd))
 	return grub_error (GRUB_ERR_IO, N_("cannot open `%s': %s"),
 			   dev->cheat, grub_util_fd_strerror ());
+
+      /* Use the sector size and count of the cheat device */
+      cheat_dev_size = grub_util_get_fd_size (dev->cheat_fd, dev->cheat, &cheat_log_sector_size);
+      if (cheat_dev_size == -1)
+        {
+          const char *errmsg = grub_util_fd_strerror ();
+          grub_util_fd_close (dev->cheat_fd);
+          dev->cheat_fd = GRUB_UTIL_FD_INVALID;
+          return grub_error (GRUB_ERR_IO, N_("failed to query size of device `%s': %s"),
+                             dev->cheat, errmsg);
+        }
+
+      dev->log_sector_size = cheat_log_sector_size;
+      dev->total_sectors = cheat_dev_size >> cheat_log_sector_size;
     }
 #endif
 
@@ -741,6 +756,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk)
     }
 
   disk->data = dev;
+  disk->log_sector_size = dev->log_sector_size;
   disk->total_sectors = dev->total_sectors;
   disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
   disk->id = dev->id;
Signature · 1 line
2.34.1
#6 lore raw

PATCH 4/4 grub-fs-tester: Add luks1 and luks2 support

In reply to Glenn Washburn

From: Pierre-Louis Bonicoli <[email protected]>

The logical sector size used by LUKS1 is 512 bytes and LUKS2 uses 512 to 4069 bytes. The deafualt password used is "pass", but can be overridden by setting the PASS environment variable. The device mapper name is set to the name of the temp directory so that its easy to corrolate device mapper name with a particular test run. Also since this name is unique per test run, multiple simultaneous test runs are allowed.

Note that cryptsetup is passing the --disable-locks parameter to allow cryptsetup run successfully when /run/lock/cryptsetup is not accessible. Since the device mapper name is unique per test run, there is no need to worry about locking the device to serialize access.

---
 .gitignore                   |  2 ++
 Makefile.util.def            | 12 ++++++++
 tests/luks1_test.in          | 23 +++++++++++++++
 tests/luks2_test.in          | 23 +++++++++++++++
 tests/util/grub-fs-tester.in | 57 ++++++++++++++++++++++++++++++++++--
 5 files changed, 115 insertions(+), 2 deletions(-)
 create mode 100644 tests/luks1_test.in
 create mode 100644 tests/luks2_test.in
.gitignore +2 -0
index f6a1bd0517..4064d3d1ec 100644
@@ -230,6 +230,8 @@ widthspec.bin
 /lib/libgcrypt-grub
 /libgrub_a_init.c
 /lzocompress_test
+/luks1_test
+/luks2_test
 /m4/
 /minixfs_test
 /missing
Makefile.util.def +12 -0
index d919c562c4..3f1162b765 100644
@@ -1213,6 +1213,18 @@ script = {
   common = tests/syslinux_test.in;
 };
 
+script = {
+  testcase = native;
+  name = luks1_test;
+  common = tests/luks1_test.in;
+};
+
+script = {
+  testcase = native;
+  name = luks2_test;
+  common = tests/luks2_test.in;
+};
+
 program = {
   testcase = native;
   name = example_unit_test;
tests/luks1_test.in new file +23 -0
new file mode 100644
index 0000000000..cd28fd7149
@@ -0,0 +1,23 @@
+#!@BUILD_SHEBANG@
+
+set -e
+
+if [ "x$EUID" = "x" ] ; then
+  EUID=`id -u`
+fi
+
+if [ "$EUID" != 0 ] ; then
+   exit 99
+fi
+
+if ! which mkfs.ext2 >/dev/null 2>&1; then
+   echo "mkfs.ext2 not installed; cannot test luks."
+   exit 99
+fi
+
+if ! which cryptsetup >/dev/null 2>&1; then
+   echo "cryptsetup not installed; cannot test luks."
+   exit 99
+fi
+
+"@builddir@/grub-fs-tester" luks1
tests/luks2_test.in new file +23 -0
new file mode 100644
index 0000000000..6a26ba6266
@@ -0,0 +1,23 @@
+#!@BUILD_SHEBANG@
+
+set -e
+
+if [ "x$EUID" = "x" ] ; then
+  EUID=`id -u`
+fi
+
+if [ "$EUID" != 0 ] ; then
+   exit 99
+fi
+
+if ! which mkfs.ext2 >/dev/null 2>&1; then
+   echo "mkfs.ext2 not installed; cannot test luks2."
+   exit 99
+fi
+
+if ! which cryptsetup >/dev/null 2>&1; then
+   echo "cryptsetup not installed; cannot test luks2."
+   exit 99
+fi
+
+"@builddir@/grub-fs-tester" luks2
tests/util/grub-fs-tester.in +55 -2

123 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 3/4] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters

In reply to Glenn Washburn
Quoted 126 lines · Glenn Washburn

From: Josselin Poiret <[email protected]>

This lets a LUKS2 cryptodisk have its cipher and hash filled out, otherwise they wouldn't be initialized if cheat mounted.

---
 grub-core/osdep/devmapper/getroot.c | 107 +++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
grub-core/osdep/devmapper/getroot.c +92 -1
index 2bf4264cf0..090ac71670 100644
@@ -51,6 +51,8 @@
 #include <grub/emu/misc.h>
 #include <grub/emu/hostdisk.h>
 
+#include <grub/cryptodisk.h>
+
 static int
 grub_util_open_dm (const char *os_dev, struct dm_tree **tree,
 		   struct dm_tree_node **node)
@@ -186,7 +188,6 @@ grub_util_pull_devmapper (const char *os_dev)
       && lastsubdev)
     {
       char *grdev = grub_util_get_grub_dev (lastsubdev);
-      dm_tree_free (tree);
       if (grdev)
 	{
 	  grub_err_t err;
@@ -194,7 +195,111 @@ grub_util_pull_devmapper (const char *os_dev)
 	  if (err)
 	    grub_util_error (_("can't mount encrypted volume `%s': %s"),
 			     lastsubdev, grub_errmsg);
+          if (strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
+            {
+              /*
+               * set LUKS2 cipher from dm parameters, since it is not
+               * possible to determine the correct one without
+               * unlocking, as there might be multiple segments.
+               */
+              grub_disk_t source;
+              grub_cryptodisk_t cryptodisk;
+              grub_uint64_t start, length;
+              char *target_type;
+              char *params;
+              const char *name;
+              char *cipher, *cipher_mode;
+              struct dm_task *dmt;
+              char *seek_head, *c;
+              unsigned int remaining;
+
+              source = grub_disk_open (grdev);
+              if (! source)
+                grub_util_error (_("cannot open grub disk `%s'"), grdev);
+              cryptodisk = grub_cryptodisk_get_by_source_disk (source);
+              if (! cryptodisk)
+                grub_util_error (_("cannot get cryptodisk from source disk `%s'"), grdev);
+              grub_disk_close (source);
+
+              /*
+               * the following function always returns a non-NULL pointer,
+               * but the string may be empty if the relevant info is not present
+               */
+              name = dm_tree_node_get_name (node);
+              if (grub_strlen (name) == 0)
+                grub_util_error (_("cannot get dm node name for grub dev `%s'"), grdev);
+
+              grub_util_info ("populating parameters of cryptomount `%s' from DM device `%s'",
+                              uuid, name);
+
+              dmt = dm_task_create (DM_DEVICE_TABLE);
+              if (dmt == NULL)
+                grub_util_error (_("can't create dm task DM_DEVICE_TABLE"));
+              if (dm_task_set_name (dmt, name) == 0)
+                grub_util_error (_("can't set dm task name to `%s'"), name);
+              if (dm_task_run (dmt) == 0)
+                grub_util_error (_("can't run dm task for `%s'"), name);
+              /*
+               * dm_get_next_target doesn't have any error modes, everything has
+               * been handled by dm_task_run.
+               */
+              dm_get_next_target (dmt, NULL, &start, &length,
+                                  &target_type, &params);
+              if (strncmp (target_type, "crypt", sizeof ("crypt")) != 0)
+                grub_util_error (_("dm target of type `%s' is not `crypt'"), target_type);
+
+              /*
+               * dm target parameters for dm-crypt is
+               * <cipher> <key> <iv_offset> <device path> <offset> [<#opt_params> <opt_param1> ...]
+               */
+              c = params;
+              remaining = grub_strlen (c);
+
+              /* first, get the cipher name from the cipher */
+              seek_head = grub_memchr (c, '-', remaining);
+              if (seek_head == NULL)
+                grub_util_error (_("can't get cipher from dm-crypt parameters `%s'"),
+                                 params);
+              cipher = grub_strndup (c, seek_head - c);
+              if (cipher == NULL)
+                grub_util_error (_("could not strndup cipher of length `%lu'"), seek_head - c);
+              remaining -= seek_head - c + 1;
+              c = seek_head + 1;
+
+              /* now, the cipher mode */
+              seek_head = grub_memchr (c, ' ', remaining);
+              if (seek_head == NULL)
+                grub_util_error (_("can't get cipher mode from dm-crypt parameters `%s'"),
+                                 params);
+              cipher_mode = grub_strndup (c, seek_head - c);
+              if (cipher_mode == NULL)
+                grub_util_error (_("could not strndup cipher_mode of length `%lu'"), seek_head - c);
+
+              remaining -= seek_head - c + 1;
+              c = seek_head + 1;
+
+              err = grub_cryptodisk_setcipher (cryptodisk, cipher, cipher_mode);
+              if (err)
+                  grub_util_error (_("can't set cipher of cryptodisk `%s' to `%s' with mode `%s'"),
+                                   uuid, cipher, cipher_mode);
+
+              grub_free (cipher);
+              grub_free (cipher_mode);

grub-core/osdep/devmapper/getroot.c grub_util_pull_devmapper (const char *os_dev) · line 297

Quoted 10 lines
grub-core/osdep/devmapper/getroot.c +10 -0
+
+              /*
+               * This is the only hash usable by PBKDF2, and we don't
+               * have Argon2 support yet, so set it by default,
+               * otherwise grub-probe would miss the required
+               * abstraction
+               */
+              cryptodisk->hash = grub_crypto_lookup_md_by_name ("sha256");
+              if (cryptodisk->hash == NULL)
+                  grub_util_error (_("can't lookup hash sha256 by name"));

I had to re-check whether this is actually true, but at least the LUKS2 spec says it's always SHA256. The format allows for a different hashing function, but that does not yet seem to be used according to the spec.

We can iterate at a later point as required.

Patrick

Quoted 10 lines
grub-core/osdep/devmapper/getroot.c +3 -0
+              dm_task_destroy (dmt);
+            }
 	}
+      dm_tree_free (tree);
       grub_free (grdev);
     }
   else
Signature · 1 line
2.34.1
Reviewed-by on the v1 series
#7 lore raw
In reply to Glenn Washburn
Quoted 11 lines · Glenn Washburn

This series adds the testing of LUKS 1 and 2 encrypted container to the user-space fs tester. While this does replicate some of the testing done by grub_cmd_cryptomount, and is less flexible, it is run natively (that is without need for virtualization). It also tests the added LUKS2 support in grub-probe, unlike grub_cmd_cryptomount which does not test any user-space grub components.

All of these patches have previously been sent to the list. Only patch 4 has been slightly modified to fix some issues. Since utility of any one is greatly enhanced, and in the case of patch 4 required, by the others, I think it makes sense to evaluate them together.

Yeah, makes sense to have them all in one place.

Quoted 9 lines

Fabian has noted a memory leak with error handling when using LUKS2 with a null_cipher[1]. Since this isn't something that I expect to happen in the wild (why would you use an unencrypted LUKS container?) and even if it does occur grub-probe is exiting, so the leak would be very short lived, I don't think this is something that we need to worry about. It wouldn't be that hard to fix though, just annoying and add a little more complexity to the source.

The corresponding patches can be found in the order of this series here:
1: [PATCH v3] disk/cryptodisk: When cheatmounting, use the sector info of the cheat device

Quoted 7 lines
    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00106.html
 2: [PATCH v6 1/2] devmapper/getroot: Have devmapper recognize LUKS2
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00036.html
 3: [PATCH v6 2/2] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00038.html
 4: [PATCH v4] grub-fs-tester: Add luks1 and luks2 support
    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00127.html

For all patches:

Thanks a bunch!

Patrick

#5 lore raw

Re: [PATCH 3/4] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters

In reply to Glenn Washburn

grub-core/osdep/devmapper/getroot.c grub_util_pull_devmapper (const char *os_dev) · line 230

Quoted 3 lines
grub-core/osdep/devmapper/getroot.c +3 -0
+              name = dm_tree_node_get_name (node);
+              if (grub_strlen (name) == 0)
+                grub_util_error (_("cannot get dm node name for grub dev `%s'"), grdev);

if (name[0] == '\0')
...

#8 lore raw
In reply to Patrick Steinhardt
Quoted 38 lines · On Fri, 13 Jan 2023 09:31:43 +0100 Patrick Steinhardt <[email protected]> wrote:
Quoted 8 lines · Glenn Washburn

This series adds the testing of LUKS 1 and 2 encrypted container to the user-space fs tester. While this does replicate some of the testing done by grub_cmd_cryptomount, and is less flexible, it is run natively (that is without need for virtualization). It also tests the added LUKS2 support in grub-probe, unlike grub_cmd_cryptomount which does not test any user-space grub components.

Quoted 5 lines

All of these patches have previously been sent to the list. Only patch 4 has been slightly modified to fix some issues. Since utility of any one is greatly enhanced, and in the case of patch 4 required, by the others, I think it makes sense to evaluate them together.

Yeah, makes sense to have them all in one place.

Quoted 9 lines

Fabian has noted a memory leak with error handling when using LUKS2 with a null_cipher[1]. Since this isn't something that I expect to happen in the wild (why would you use an unencrypted LUKS container?) and even if it does occur grub-probe is exiting, so the leak would be very short lived, I don't think this is something that we need to worry about. It wouldn't be that hard to fix though, just annoying and add a little more complexity to the source.

Quoted 11 lines

The corresponding patches can be found in the order of this series
here: 1: [PATCH v3] disk/cryptodisk: When cheatmounting, use the sector info of the cheat device
https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00106.html
2: [PATCH v6 1/2] devmapper/getroot: Have devmapper recognize LUKS2
https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00036.html
3: [PATCH v6 2/2] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters
https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00038.html
4: [PATCH v4] grub-fs-tester: Add luks1 and luks2 support
https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00127.html

Quoted 5 lines

For all patches:

Thanks a bunch!

And thanks Patrick for taking a look at these again and the other cryptomount test patches.

Glenn

Reviewed-by
#9 lore raw
In reply to Patrick Steinhardt
Quoted 32 lines · Patrick Steinhardt
Quoted 11 lines · Glenn Washburn

This series adds the testing of LUKS 1 and 2 encrypted container to the user-space fs tester. While this does replicate some of the testing done by grub_cmd_cryptomount, and is less flexible, it is run natively (that is without need for virtualization). It also tests the added LUKS2 support in grub-probe, unlike grub_cmd_cryptomount which does not test any user-space grub components.

All of these patches have previously been sent to the list. Only patch 4 has been slightly modified to fix some issues. Since utility of any one is greatly enhanced, and in the case of patch 4 required, by the others, I think it makes sense to evaluate them together.

Yeah, makes sense to have them all in one place.

Quoted 9 lines

Fabian has noted a memory leak with error handling when using LUKS2 with a null_cipher[1]. Since this isn't something that I expect to happen in the wild (why would you use an unencrypted LUKS container?) and even if it does occur grub-probe is exiting, so the leak would be very short lived, I don't think this is something that we need to worry about. It wouldn't be that hard to fix though, just annoying and add a little more complexity to the source.

The corresponding patches can be found in the order of this series here:
1: [PATCH v3] disk/cryptodisk: When cheatmounting, use the sector info of the cheat device

Quoted 7 lines
    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00106.html
 2: [PATCH v6 1/2] devmapper/getroot: Have devmapper recognize LUKS2
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00036.html
 3: [PATCH v6 2/2] devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM parameters
    https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00038.html
 4: [PATCH v4] grub-fs-tester: Add luks1 and luks2 support
    https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00127.html
Quoted 3 lines

For all patches:

Daniel