dm ima: add a warning in dm_init if duplicate ima events are not measured
authorTushar Sugandhi <tusharsu@linux.microsoft.com>
Fri, 13 Aug 2021 21:37:59 +0000 (14:37 -0700)
committerMike Snitzer <snitzer@redhat.com>
Fri, 20 Aug 2021 20:07:35 +0000 (16:07 -0400)
The end-users of DM devices/targets may remove and re-create the same
device multiple times.  IMA does not measure such duplicate events if the
configuration CONFIG_IMA_DISABLE_HTABLE is set to 'n'.
To avoid confusion, the end-users need some indication on the client
if that configuration option is disabled.

Add a one-time warning during dm_init() if CONFIG_IMA_DISABLE_HTABLE
is set to 'n', to notify the end-users that duplicate events will not
be measured in the ima log. Also cleanup some whitespace in dm_init().

Signed-off-by: Tushar Sugandhi <tusharsu@linux.microsoft.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm.c

index 33e55ac9ec656d2aab7df1fd54800cc9690b9864..84e9145b171461eb80d85f6914897cd9684c82fc 100644 (file)
@@ -262,9 +262,13 @@ static void (*_exits[])(void) = {
 static int __init dm_init(void)
 {
        const int count = ARRAY_SIZE(_inits);
-
        int r, i;
 
+#if (IS_ENABLED(CONFIG_IMA) && !IS_ENABLED(CONFIG_IMA_DISABLE_HTABLE))
+       DMWARN("CONFIG_IMA_DISABLE_HTABLE is disabled."
+              " Duplicate IMA measurements will not be recorded in the IMA log.");
+#endif
+
        for (i = 0; i < count; i++) {
                r = _inits[i]();
                if (r)
@@ -272,8 +276,7 @@ static int __init dm_init(void)
        }
 
        return 0;
-
-      bad:
+bad:
        while (i--)
                _exits[i]();