[PATCH master 3/3] dm: verity: support superblocks without a salt
Ahmad Fatoum
a.fatoum at barebox.org
Thu Nov 26 08:10:23 PST 2026
For a superblock without a salt, dm_verity_config_from_sb() leaves the
salt column empty. The table parser skips empty columns, so the target
gets 9 instead of 10 arguments and hash devices formatted with --salt=-
can't be opened.
Let's write "-" instead, which the verity target takes as no salt, like
in Linux.
Fixes: f2cc4a0a5f3c ("dm: verity: Add helper to parse superblock information")
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
drivers/block/dm/dm-verity.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/block/dm/dm-verity.c b/drivers/block/dm/dm-verity.c
index c4f88852b5f2..ca32dc326730 100644
--- a/drivers/block/dm/dm-verity.c
+++ b/drivers/block/dm/dm-verity.c
@@ -483,6 +483,7 @@ char *dm_verity_config_from_sb(const char *data_dev, const char *hash_dev,
const char *root_hash)
{
struct dm_verity_sb sb;
+ char salt[2 * sizeof(sb.salt) + 1] = "-";
unsigned int salt_size;
blkcnt_t sects;
ssize_t n;
@@ -512,17 +513,21 @@ char *dm_verity_config_from_sb(const char *data_dev, const char *hash_dev,
if (salt_size > sizeof(sb.salt))
return ERR_PTR(-EINVAL);
+ /* An empty column would shift the arguments, Linux uses "-" too */
+ if (salt_size)
+ *bin2hex(salt, sb.salt, salt_size) = '\0';
+
sects = le32_to_cpu(sb.data_block_size) >> SECTOR_SHIFT;
if (!sects)
return ERR_PTR(-ERANGE);
sects *= le64_to_cpu(sb.data_blocks);
- return xasprintf("0 %llu verity %u %s %s %u %u %llu 1 %s %s %*phN",
+ return xasprintf("0 %llu verity %u %s %s %u %u %llu 1 %s %s %s",
sects, le32_to_cpu(sb.hash_type), data_dev, hash_dev,
le32_to_cpu(sb.data_block_size),
le32_to_cpu(sb.hash_block_size),
le64_to_cpu(sb.data_blocks), sb.algorithm, root_hash,
- salt_size, sb.salt);
+ salt);
}
EXPORT_SYMBOL(dm_verity_config_from_sb);
--
2.47.3
More information about the barebox
mailing list