]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: introduce luks opal prober
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 30 Mar 2024 10:14:47 +0000 (11:14 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 30 Mar 2024 10:14:47 +0000 (11:14 +0100)
Accesses to a disk locked with OPAL trigger IO errors logged by the
kernel which should be avoided.
Running the normal luks prober first breaks the ordering of probers
leading to incorrect detections, for example detecting mdadm superblocks
before version 1.1 as luks.

Introduce a new prober that only runs on OPAL-locked disks to avoid
these false-positives.

See #2061, #2373 and #2882.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/superblocks/luks.c
libblkid/src/superblocks/superblocks.c
libblkid/src/superblocks/superblocks.h

index 4623c98fc9d64db75504a7b09b4566cec2f2dc30..1c487f8ff3d4125b55435ad5eff4edf6166cf727 100644 (file)
@@ -139,6 +139,14 @@ static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute_
        return BLKID_PROBE_NONE;
 }
 
+static int probe_luks_opal(blkid_probe pr, const struct blkid_idmag *mag)
+{
+       if (!blkdid_probe_is_opal_locked(pr))
+               return BLKID_PROBE_NONE;
+
+       return probe_luks(pr, mag);
+}
+
 const struct blkid_idinfo luks_idinfo =
 {
        .name           = "crypto_LUKS",
@@ -146,3 +154,11 @@ const struct blkid_idinfo luks_idinfo =
        .probefunc      = probe_luks,
        .magics         = BLKID_NONE_MAGIC
 };
+
+const struct blkid_idinfo luks_opal_idinfo =
+{
+       .name           = "crypto_LUKS",
+       .usage          = BLKID_USAGE_CRYPTO,
+       .probefunc      = probe_luks_opal,
+       .magics         = BLKID_NONE_MAGIC,
+};
index dd1e6dcf31d79fecd79b8555c120b18268309adc..e89cb598d679b9b4f482b3b72780c0a69a3c54c7 100644 (file)
@@ -94,6 +94,9 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage);
  */
 static const struct blkid_idinfo *idinfos[] =
 {
+       /* First, as access to locked OPAL region triggers IO errors */
+       &luks_opal_idinfo,
+
        /* RAIDs */
        &linuxraid_idinfo,
        &ddfraid_idinfo,
index dc669e0fa014269d331fa53fce531e719966ddf4..140261eae8e96070299e0474a6720e3cf1d74110 100644 (file)
@@ -68,6 +68,7 @@ extern const struct blkid_idinfo snapcow_idinfo;
 extern const struct blkid_idinfo verity_hash_idinfo;
 extern const struct blkid_idinfo integrity_idinfo;
 extern const struct blkid_idinfo luks_idinfo;
+extern const struct blkid_idinfo luks_opal_idinfo;
 extern const struct blkid_idinfo highpoint37x_idinfo;
 extern const struct blkid_idinfo highpoint45x_idinfo;
 extern const struct blkid_idinfo squashfs_idinfo;