From bce9bd3a3ba6b8e2a96d8cc66c0c4215a04a2431 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 16 May 2022 17:11:45 +0200 Subject: [PATCH] Use better error message for incompatible dm-integrity metadata. If cryptsetup/integritysetup tool is too old, it can happen that kernel dm-integrity uses more recent version of dm-integrity metadata. Print (and also traslate) better error in this case. Fixes: #667 --- lib/integrity/integrity.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/integrity/integrity.c b/lib/integrity/integrity.c index ee38c4f4..bdc28f6d 100644 --- a/lib/integrity/integrity.c +++ b/lib/integrity/integrity.c @@ -49,11 +49,13 @@ static int INTEGRITY_read_superblock(struct crypt_device *cd, return -EINVAL; if (read_lseek_blockwise(devfd, device_block_size(cd, device), - device_alignment(device), sb, sizeof(*sb), offset) != sizeof(*sb) || - memcmp(sb->magic, SB_MAGIC, sizeof(sb->magic)) || - sb->version < SB_VERSION_1 || sb->version > SB_VERSION_5) { - log_std(cd, "No integrity superblock detected on %s.\n", - device_path(device)); + device_alignment(device), sb, sizeof(*sb), offset) != sizeof(*sb) || + memcmp(sb->magic, SB_MAGIC, sizeof(sb->magic))) { + log_err(cd, _("No kernel dm-integrity metadata detected on %s."), device_path(device)); + r = -EINVAL; + } else if (sb->version < SB_VERSION_1 || sb->version > SB_VERSION_5) { + log_err(cd, _("Incompatible kernel dm-integrity metadata (version %u) detected on %s."), + sb->version, device_path(device)); r = -EINVAL; } else { sb->integrity_tag_size = le16toh(sb->integrity_tag_size);