[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200818152037.11869-6-krzysztof.struczynski@huawei.com>
Date: Tue, 18 Aug 2020 17:20:12 +0200
From: <krzysztof.struczynski@...wei.com>
To: <linux-integrity@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<containers@...ts.linux-foundation.org>,
<linux-security-module@...r.kernel.org>
CC: Krzysztof Struczynski <krzysztof.struczynski@...wei.com>,
<zohar@...ux.ibm.com>, <stefanb@...ux.vnet.ibm.com>,
<sunyuqiong1988@...il.com>, <mkayaalp@...binghamton.edu>,
<dmitry.kasatkin@...il.com>, <serge@...lyn.com>,
<jmorris@...ei.org>, <christian@...uner.io>,
<silviu.vlasceanu@...wei.com>, <roberto.sassu@...wei.com>
Subject: [RFC PATCH 05/30] ima: Add methods for parsing ima policy configuration string
From: Krzysztof Struczynski <krzysztof.struczynski@...wei.com>
IMA subsystem is configured at boot time using kernel command-line
parameters, e.g.: ima_policy=tcb|appraise_tcb|secure_boot. The same
configuration options should be available for the new ima namespace.
Add new functions to parse configuration string and store parsed data
in the new policy data structures. Don't implement it yet, just add the
dummy interface.
Signed-off-by: Krzysztof Struczynski <krzysztof.struczynski@...wei.com>
---
security/integrity/ima/ima.h | 10 ++++++++
security/integrity/ima/ima_appraise.c | 9 +++++++
security/integrity/ima/ima_policy.c | 37 +++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 0d88222e3500..4872f193f7a3 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -306,6 +306,16 @@ void *ima_policy_next(struct seq_file *m, void *v, loff_t *pos);
void ima_policy_stop(struct seq_file *m, void *v);
int ima_policy_show(struct seq_file *m, void *v);
+int ima_policy_setup(char *str,
+ struct ima_policy_setup_data *policy_setup_data,
+ bool *fail_unverifiable_sigs);
+int ima_default_measure_policy_setup(const char *str,
+ struct ima_policy_setup_data *setup_data);
+int ima_default_appraise_policy_setup(const char *str,
+ struct ima_policy_setup_data *setup_data);
+int ima_default_appraise_setup(const char *str,
+ struct ima_policy_setup_data *setup_data);
+
/* Appraise integrity measurements */
#define IMA_APPRAISE_ENFORCE 0x01
#define IMA_APPRAISE_FIX 0x02
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 372d16382960..0632d3881611 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -16,6 +16,15 @@
#include "ima.h"
+int ima_default_appraise_setup(const char *str,
+ struct ima_policy_setup_data *setup_data)
+{
+ /* Currently unused. It will be implemented after namespacing ima
+ * policy, when global variables are removed.
+ */
+ return 1;
+}
+
static int __init default_appraise_setup(char *str)
{
#ifdef CONFIG_IMA_APPRAISE_BOOTPARAM
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 6b56741ec1c9..403854b18ef2 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -223,6 +223,15 @@ struct ima_policy_data init_policy_data = {
.ima_temp_rules = LIST_HEAD_INIT(init_policy_data.ima_temp_rules),
};
+int ima_default_measure_policy_setup(const char *str,
+ struct ima_policy_setup_data *setup_data)
+{
+ /* Currently unused. It will be implemented after namespacing ima
+ * policy, when global variables are removed.
+ */
+ return 1;
+}
+
static int __init default_measure_policy_setup(char *str)
{
if (ima_policy)
@@ -236,6 +245,25 @@ __setup("ima_tcb", default_measure_policy_setup);
static bool ima_use_appraise_tcb __initdata;
static bool ima_use_secure_boot __initdata;
static bool ima_fail_unverifiable_sigs __ro_after_init;
+
+/**
+ * ima_policy_setup - parse policy configuration string "ima_policy="
+ * @str: string to be parsed
+ * @setup_data: pointer to a structure where parsed data is stored
+ * @fail_unverifiable_sigs: boolean flag treated separately to preserve
+ * __ro_after_init
+ */
+int ima_policy_setup(char *str,
+ struct ima_policy_setup_data *setup_data,
+ bool *fail_unverifiable_sigs)
+{
+
+ /* Currently unused. It will be implemented after namespacing ima
+ * policy, when global variables are removed.
+ */
+ return 1;
+}
+
static int __init policy_setup(char *str)
{
char *p;
@@ -257,6 +285,15 @@ static int __init policy_setup(char *str)
}
__setup("ima_policy=", policy_setup);
+int ima_default_appraise_policy_setup(const char *str,
+ struct ima_policy_setup_data *setup_data)
+{
+ /* Currently unused. It will be implemented after namespacing ima
+ * policy, when global variables are removed.
+ */
+ return 1;
+}
+
static int __init default_appraise_policy_setup(char *str)
{
ima_use_appraise_tcb = true;
--
2.20.1
Powered by blists - more mailing lists