]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm-ima: remove new_map from dm_ima_measure_on_device_clear
authorBenjamin Marzinski <bmarzins@redhat.com>
Wed, 29 Apr 2026 20:21:04 +0000 (16:21 -0400)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 4 May 2026 12:53:19 +0000 (14:53 +0200)
Now that two processes can't modify md->ima in
dm_ima_measure_on_device_clear() at the same time, there's no need to
track if an inactive table was actually removed. We might as well
clean it up unconditionally, on the off chance that a previous
ima measurement failed and left md->ima.inactive_table behind.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-ima.c
drivers/md/dm-ima.h
drivers/md/dm-ioctl.c

index 096c664d855ca6bcd12fea7c5801e45e883cfb3a..75c46b5af3f794c54d78543c9a28574718ca5a39 100644 (file)
@@ -549,7 +549,7 @@ exit:
 /*
  * Measure ima data on table clear.
  */
-void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map,
+void dm_ima_measure_on_table_clear(struct mapped_device *md,
                                   struct dm_ima_context *context)
 {
        unsigned int l = 0;
@@ -609,11 +609,9 @@ void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map,
 
        dm_ima_measure_data("dm_table_clear", device_table_data, l, noio);
 
-       if (new_map) {
-               kfree(md->ima.inactive_table.hash);
-               kfree(md->ima.inactive_table.device_metadata);
-               memset(&md->ima.inactive_table, 0, sizeof(md->ima.inactive_table));
-       }
+       kfree(md->ima.inactive_table.hash);
+       kfree(md->ima.inactive_table.device_metadata);
+       memset(&md->ima.inactive_table, 0, sizeof(md->ima.inactive_table));
 
 error:
        kfree(capacity_str);
index 01fa0b89a38595609ac6de3b959d735b5f813701..b240e0e4b6a1961916437635bc3ca6b87270f3b0 100644 (file)
@@ -83,7 +83,7 @@ void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap,
 void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all,
                                     struct dm_ima_context *context,
                                     unsigned int idx);
-void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map,
+void dm_ima_measure_on_table_clear(struct mapped_device *md,
                                   struct dm_ima_context *context);
 void dm_ima_measure_on_device_rename(struct mapped_device *md,
                                     struct dm_ima_context *context);
@@ -108,7 +108,6 @@ static inline void dm_ima_measure_on_device_remove(struct mapped_device *md,
                                                   struct dm_ima_context *context,
                                                   unsigned int idx) {}
 static inline void dm_ima_measure_on_table_clear(struct mapped_device *md,
-                                                bool new_map,
                                                 struct dm_ima_context *context) {}
 static inline void dm_ima_measure_on_device_rename(struct mapped_device *md,
                                                   struct dm_ima_context *context) {}
index 3da8b33cdc5402f56e09d7321e5ac379f1353845..b92ec3efff01c47626a96357d339f3f5aa46b218 100644 (file)
@@ -1741,7 +1741,6 @@ static int table_clear(struct file *filp, struct dm_ioctl *param, size_t param_s
        struct hash_cell *hc;
        struct mapped_device *md;
        struct dm_table *old_map = NULL;
-       bool has_new_map = false;
        struct dm_ima_context *ima_context = NULL;
 
        dm_ima_alloc_context(&ima_context, true);
@@ -1758,13 +1757,12 @@ static int table_clear(struct file *filp, struct dm_ioctl *param, size_t param_s
        if (hc->new_map) {
                old_map = hc->new_map;
                hc->new_map = NULL;
-               has_new_map = true;
        }
 
        dm_ima_init_context(hc, ima_context, false);
        md = hc->md;
        up_write(&_hash_lock);
-       dm_ima_measure_on_table_clear(md, has_new_map, ima_context);
+       dm_ima_measure_on_table_clear(md, ima_context);
        dm_ima_free_context(ima_context);
 
        param->flags &= ~DM_INACTIVE_PRESENT_FLAG;