From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
To: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com,
jmorris@namei.org, serge@hallyn.com,
zhangliguang@linux.alibaba.com, zhang.jia@linux.alibaba.com
Cc: linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, tianjia.zhang@linux.alibaba.com
Subject: [PATCH v2 1/2] ima: support to read appraise mode
Date: Thu, 9 Apr 2020 18:34:39 +0800 [thread overview]
Message-ID: <20200409103440.47946-2-tianjia.zhang@linux.alibaba.com> (raw)
In-Reply-To: <20200409103440.47946-1-tianjia.zhang@linux.alibaba.com>
Support to read appraise mode in runtime through securityfs file
'integrity/ima/appraise_mode'.
Signed-off-by: luanshi <zhangliguang@linux.alibaba.com>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
security/integrity/ima/ima_fs.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index a71e822a6e92..65384f6ac0d9 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -360,6 +360,7 @@ static struct dentry *ascii_runtime_measurements;
static struct dentry *runtime_measurements_count;
static struct dentry *violations;
static struct dentry *ima_policy;
+static struct dentry *appraise_mode;
enum ima_fs_flags {
IMA_FS_BUSY,
@@ -447,6 +448,29 @@ static const struct file_operations ima_measure_policy_ops = {
.llseek = generic_file_llseek,
};
+static ssize_t ima_appraise_mode_read(struct file *filp,
+ char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ const char *mode;
+
+ if (ima_appraise & IMA_APPRAISE_ENFORCE)
+ mode = "enforce";
+ else if (ima_appraise & IMA_APPRAISE_FIX)
+ mode = "fix";
+ else if (ima_appraise & IMA_APPRAISE_LOG)
+ mode = "log";
+ else
+ mode = "off";
+
+ return simple_read_from_buffer(buf, count, ppos, mode, strlen(mode));
+}
+
+static const struct file_operations ima_appraise_mode_ops = {
+ .read = ima_appraise_mode_read,
+ .llseek = generic_file_llseek,
+};
+
int __init ima_fs_init(void)
{
ima_dir = securityfs_create_dir("ima", integrity_dir);
@@ -491,14 +515,20 @@ int __init ima_fs_init(void)
if (IS_ERR(ima_policy))
goto out;
+ appraise_mode =
+ securityfs_create_file("appraise_mode", S_IRUSR | S_IRGRP,
+ ima_dir, NULL, &ima_appraise_mode_ops);
+ if (IS_ERR(appraise_mode))
+ goto out;
+
return 0;
out:
+ securityfs_remove(ima_policy);
securityfs_remove(violations);
securityfs_remove(runtime_measurements_count);
securityfs_remove(ascii_runtime_measurements);
securityfs_remove(binary_runtime_measurements);
securityfs_remove(ima_symlink);
securityfs_remove(ima_dir);
- securityfs_remove(ima_policy);
return -1;
}
--
2.17.1
next prev parent reply other threads:[~2020-04-09 10:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 10:34 [PATCH v2 0/2] support to read and tune appraise mode in runtime Tianjia Zhang
2020-04-09 10:34 ` Tianjia Zhang [this message]
2020-04-09 10:34 ` [PATCH v2 2/2] ima: support to " Tianjia Zhang
2020-04-11 21:43 ` [PATCH v2 0/2] support to read and " Nayna
2020-04-13 2:23 ` Tianjia Zhang
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=20200409103440.47946-2-tianjia.zhang@linux.alibaba.com \
--to=tianjia.zhang@linux.alibaba.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=jmorris@namei.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=zhang.jia@linux.alibaba.com \
--cc=zhangliguang@linux.alibaba.com \
--cc=zohar@linux.ibm.com \
/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).