summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorThore Sommer <public@thson.de>2022-01-25 17:05:47 +0300
committerMike Snitzer <snitzer@redhat.com>2022-02-22 18:42:41 +0300
commit118f31b4964fa9fce65b0901ef598c734553cfc7 (patch)
treeb4e9b792963a61d9175dc728576a58ce37e19090 /drivers
parent302f035141d3d4faee36f8543d34a32fb36a886d (diff)
downloadlinux-118f31b4964fa9fce65b0901ef598c734553cfc7.tar.xz
dm ima: fix wrong length calculation for no_data string
All entries measured by dm ima are prefixed by a version string (dm_version=N.N.N). When there is no data to measure, the entire buffer is overwritten with a string containing the version string again and the length of that string is added to the length of the version string. The new length is now wrong because it contains the version string twice. This caused entries like this: dm_version=4.45.0;name=test,uuid=test;table_clear=no_data; \ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \ current_device_capacity=204808; Signed-off-by: Thore Sommer <public@thson.de> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-ima.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/md/dm-ima.c b/drivers/md/dm-ima.c
index 957999998d70..1842d3a958ef 100644
--- a/drivers/md/dm-ima.c
+++ b/drivers/md/dm-ima.c
@@ -455,7 +455,7 @@ void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap)
scnprintf(device_table_data, DM_IMA_DEVICE_BUF_LEN,
"%sname=%s,uuid=%s;device_resume=no_data;",
DM_IMA_VERSION_STR, dev_name, dev_uuid);
- l += strlen(device_table_data);
+ l = strlen(device_table_data);
}
@@ -568,7 +568,7 @@ void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all)
scnprintf(device_table_data, DM_IMA_DEVICE_BUF_LEN,
"%sname=%s,uuid=%s;device_remove=no_data;",
DM_IMA_VERSION_STR, dev_name, dev_uuid);
- l += strlen(device_table_data);
+ l = strlen(device_table_data);
}
memcpy(device_table_data + l, remove_all_str, remove_all_len);
@@ -654,7 +654,7 @@ void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map)
scnprintf(device_table_data, DM_IMA_DEVICE_BUF_LEN,
"%sname=%s,uuid=%s;table_clear=no_data;",
DM_IMA_VERSION_STR, dev_name, dev_uuid);
- l += strlen(device_table_data);
+ l = strlen(device_table_data);
}
capacity_len = strlen(capacity_str);