linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: roberto.sassu@huawei.com, dmitry.kasatkin@gmail.com,
	eric.snowberg@oracle.com, paul@paul-moore.com, jmorris@namei.org,
	serge@hallyn.com, kernel-team@meta.com, brauner@kernel.org,
	jack@suse.cz, viro@zeniv.linux.org.uk, Song Liu <song@kernel.org>
Subject: [RFC 1/2] ima: Add kernel parameter to disable IMA
Date: Tue, 17 Dec 2024 12:25:24 -0800	[thread overview]
Message-ID: <20241217202525.1802109-2-song@kernel.org> (raw)
In-Reply-To: <20241217202525.1802109-1-song@kernel.org>

This patch provides kernel parameter 'ima=off' that disables IMA.
This will reduce memory consumption by the ima when it is not needed.
Specifically, this saves one pointer per inode in the system.

Originally-by: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Signed-off-by: Song Liu <song@kernel.org>
---
 security/integrity/ima/ima_main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 06132cf47016..21968c78f03f 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -1144,10 +1144,22 @@ static int ima_kernel_module_request(char *kmod_name)
 
 #endif /* CONFIG_INTEGRITY_ASYMMETRIC_KEYS */
 
+
+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);
+
 static int __init init_ima(void)
 {
 	int error;
 
+	if (!ima_mode)
+		return 0;
 	ima_appraise_parse_cmdline();
 	ima_init_template_list();
 	hash_setup(CONFIG_IMA_DEFAULT_HASH);
@@ -1217,6 +1229,7 @@ DEFINE_LSM(ima) = {
 	.name = "ima",
 	.init = init_ima_lsm,
 	.order = LSM_ORDER_LAST,
+	.enabled = &ima_mode,
 	.blobs = &ima_blob_sizes,
 };
 
-- 
2.43.5


  reply	other threads:[~2024-12-17 20:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17 20:25 [RFC 0/2] ima: evm: Add kernel cmdline options to disable IMA/EVM Song Liu
2024-12-17 20:25 ` Song Liu [this message]
2024-12-17 20:25 ` [RFC 2/2] evm: Add kernel parameter to disable EVM Song Liu
2024-12-17 21:29 ` [RFC 0/2] ima: evm: Add kernel cmdline options to disable IMA/EVM Casey Schaufler
2024-12-17 21:59   ` Paul Moore
2024-12-17 22:04     ` Song Liu
2024-12-17 22:47       ` Song Liu
2024-12-17 23:16         ` Paul Moore
2024-12-17 23:33           ` Song Liu
2024-12-18  6:41             ` Song Liu
2024-12-18 16:42               ` Casey Schaufler
2024-12-18 16:48                 ` Song Liu
2024-12-17 22:02   ` Song Liu
2024-12-18 11:02   ` Mimi Zohar
2024-12-18 17:07     ` Song Liu
2024-12-19 15:40       ` Roberto Sassu
2024-12-19 17:46         ` Song Liu
2024-12-19 18:18           ` Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241217202525.1802109-2-song@kernel.org \
    --to=song@kernel.org \
    --cc=brauner@kernel.org \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=roberto.sassu@huawei.com \
    --cc=serge@hallyn.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).