Skip to content

Commit aa9bb1b

Browse files
Baoquan Hemimizohar
authored andcommitted
ima: add a knob ima= to allow disabling IMA in kdump kernel
Kdump kernel doesn't need IMA functionality, and enabling IMA will cost extra memory. It would be very helpful to allow IMA to be disabled for kdump kernel. Hence add a knob ima=on|off here to allow turning IMA off in kdump kernel if needed. Note that this IMA disabling is limited to kdump kernel, please don't abuse it in other kernel and thus serious consequences are caused. Signed-off-by: Baoquan He <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent e04c78d commit aa9bb1b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,11 @@
22122212
different crypto accelerators. This option can be used
22132213
to achieve best performance for particular HW.
22142214

2215+
ima= [IMA] Enable or disable IMA
2216+
Format: { "off" | "on" }
2217+
Default: "on"
2218+
Note that disabling IMA is limited to kdump kernel.
2219+
22152220
indirect_target_selection= [X86,Intel] Mitigation control for Indirect
22162221
Target Selection(ITS) bug in Intel CPUs. Updated
22172222
microcode is also required for a fix in IBPB.

security/integrity/ima/ima_main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/fs.h>
2828
#include <linux/iversion.h>
2929
#include <linux/evm.h>
30+
#include <linux/crash_dump.h>
3031

3132
#include "ima.h"
3233

@@ -38,11 +39,30 @@ int ima_appraise;
3839

3940
int __ro_after_init ima_hash_algo = HASH_ALGO_SHA1;
4041
static int hash_setup_done;
42+
static int ima_disabled __ro_after_init;
4143

4244
static struct notifier_block ima_lsm_policy_notifier = {
4345
.notifier_call = ima_lsm_policy_change,
4446
};
4547

48+
static int __init ima_setup(char *str)
49+
{
50+
if (!is_kdump_kernel()) {
51+
pr_info("Warning: ima setup option only permitted in kdump");
52+
return 1;
53+
}
54+
55+
if (strncmp(str, "off", 3) == 0)
56+
ima_disabled = 1;
57+
else if (strncmp(str, "on", 2) == 0)
58+
ima_disabled = 0;
59+
else
60+
pr_err("Invalid ima setup option: \"%s\" , please specify ima=on|off.", str);
61+
62+
return 1;
63+
}
64+
__setup("ima=", ima_setup);
65+
4666
static int __init hash_setup(char *str)
4767
{
4868
struct ima_template_desc *template_desc = ima_template_desc_current();
@@ -1186,6 +1206,12 @@ static int __init init_ima(void)
11861206
{
11871207
int error;
11881208

1209+
/*Note that turning IMA off is intentionally limited to kdump kernel.*/
1210+
if (ima_disabled && is_kdump_kernel()) {
1211+
pr_info("IMA functionality is disabled");
1212+
return 0;
1213+
}
1214+
11891215
ima_appraise_parse_cmdline();
11901216
ima_init_template_list();
11911217
hash_setup(CONFIG_IMA_DEFAULT_HASH);

0 commit comments

Comments
 (0)