[PATCH 11/20] ima: added kernel parameter for disabling IMA

From: Dmitry Kasatkin
Date: Wed Apr 23 2014 - 09:58:03 EST


If ima_tcb and ima_appraise_tcb are not specified on the kernel command
line, IMA policy remains empty and IMA functionality is disabled.

When policy is loaded from the kernel, IMA becomes enabled without specifying
ima_tcb and ima_appraise_tcb. There should be a possibiliy to disable IMA.
Distributions might want to compile IMA support, but leave for the user
to decide if to enable or disable IMA functionality.

This patch provides kernel parameter 'ima=off' that allows to disable IMA.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@xxxxxxxxxxx>
---
security/integrity/ima/ima_main.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index c0aaed8..6af4966 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -67,6 +67,15 @@ out:
}
__setup("ima_hash=", hash_setup);

+static int ima_mode = 1;
+static int __init ima_setup(char *str)
+{
+ if (strncmp(str, "off", 3) == 0)
+ ima_mode = 0;
+ return 1;
+}
+__setup("ima=", ima_setup);
+
/*
* ima_rdwr_violation_check
*
@@ -324,8 +333,9 @@ static int __init init_ima(void)
int error;

hash_setup(CONFIG_IMA_DEFAULT_HASH);
+
error = ima_init();
- if (!error)
+ if (!error && ima_mode)
ima_initialized = 1;
return error;
}
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/