Skip to content

Commit 9c2adfa

Browse files
Tushar Sugandhisnitm
authored andcommitted
dm ima: prefix ima event name related to device mapper with dm_
The event names for the DM events recorded in the ima log do not contain any information to indicate the events are part of the DM devices/targets. Prefix the event names for DM events with "dm_" to indicate that they are part of device-mapper. Signed-off-by: Tushar Sugandhi <[email protected]> Suggested-by: Thore Sommer <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent dc7b79c commit 9c2adfa

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/md/dm-ima.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
192192
* when prefixing the hash value with the hash algorithm name. e.g. sha256:<hash_value>.
193193
*/
194194
const size_t hash_alg_prefix_len = strlen(DM_IMA_TABLE_HASH_ALG) + 1;
195+
char table_load_event_name[] = "dm_table_load";
195196

196197
ima_buf = dm_ima_alloc(DM_IMA_MEASUREMENT_BUF_LEN, GFP_KERNEL, noio);
197198
if (!ima_buf)
@@ -271,7 +272,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
271272
* targets by prefixing the device metadata again.
272273
*/
273274
if (unlikely(cur_total_buf_len >= DM_IMA_MEASUREMENT_BUF_LEN)) {
274-
dm_ima_measure_data("table_load", ima_buf, l, noio);
275+
dm_ima_measure_data(table_load_event_name, ima_buf, l, noio);
275276
r = crypto_shash_update(shash, (const u8 *)ima_buf, l);
276277
if (r < 0)
277278
goto error;
@@ -280,8 +281,8 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
280281
l = 0;
281282

282283
/*
283-
* Each new "table_load" entry in IMA log should have device data
284-
* prefix, so that multiple records from the same table_load for
284+
* Each new "dm_table_load" entry in IMA log should have device data
285+
* prefix, so that multiple records from the same "dm_table_load" for
285286
* a given device can be linked together.
286287
*/
287288
memcpy(ima_buf + l, DM_IMA_VERSION_STR, table->md->ima.dm_version_str_len);
@@ -292,7 +293,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
292293

293294
/*
294295
* If this iteration of the for loop turns out to be the last target
295-
* in the table, dm_ima_measure_data("table_load", ...) doesn't need
296+
* in the table, dm_ima_measure_data("dm_table_load", ...) doesn't need
296297
* to be called again, just the hash needs to be finalized.
297298
* "last_target_measured" tracks this state.
298299
*/
@@ -311,7 +312,7 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
311312
}
312313

313314
if (!last_target_measured) {
314-
dm_ima_measure_data("table_load", ima_buf, l, noio);
315+
dm_ima_measure_data(table_load_event_name, ima_buf, l, noio);
315316

316317
r = crypto_shash_update(shash, (const u8 *)ima_buf, l);
317318
if (r < 0)
@@ -460,7 +461,7 @@ void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap)
460461
memcpy(device_table_data + l, capacity_str, capacity_len);
461462
l += capacity_len;
462463

463-
dm_ima_measure_data("device_resume", device_table_data, l, noio);
464+
dm_ima_measure_data("dm_device_resume", device_table_data, l, noio);
464465

465466
kfree(dev_name);
466467
kfree(dev_uuid);
@@ -577,7 +578,7 @@ void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all)
577578
memcpy(device_table_data + l, capacity_str, capacity_len);
578579
l += capacity_len;
579580

580-
dm_ima_measure_data("device_remove", device_table_data, l, noio);
581+
dm_ima_measure_data("dm_device_remove", device_table_data, l, noio);
581582

582583
error:
583584
kfree(device_table_data);
@@ -658,7 +659,7 @@ void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map)
658659
memcpy(device_table_data + l, capacity_str, capacity_len);
659660
l += capacity_len;
660661

661-
dm_ima_measure_data("table_clear", device_table_data, l, noio);
662+
dm_ima_measure_data("dm_table_clear", device_table_data, l, noio);
662663

663664
if (new_map) {
664665
if (md->ima.inactive_table.hash &&
@@ -733,7 +734,7 @@ void dm_ima_measure_on_device_rename(struct mapped_device *md)
733734
"%s%snew_name=%s,new_uuid=%s;%s", DM_IMA_VERSION_STR, old_device_data,
734735
new_dev_name, new_dev_uuid, capacity_str);
735736

736-
dm_ima_measure_data("device_rename", combined_device_data, strlen(combined_device_data),
737+
dm_ima_measure_data("dm_device_rename", combined_device_data, strlen(combined_device_data),
737738
noio);
738739

739740
goto exit;

0 commit comments

Comments
 (0)