“a5e5d666eb9a817dad8293e74b224de202859734”上不存在“...sun/nio/git@gitcode.net:openanolis/dragonwell8_jdk.git”
提交 f9851a37 编写于 作者: R Roberto Sassu 提交者: Zheng Zengkai

ima: Allow template selection with ima_template[_fmt]= after ima_hash=

stable inclusion
from stable-v5.10.101
commit 8171c8a99feab7d476bcc5c48b87e285bb5650a0
bugzilla: https://gitee.com/openeuler/kernel/issues/I5669Z

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8171c8a99feab7d476bcc5c48b87e285bb5650a0

--------------------------------

commit bb8e52e4 upstream.

Commit c2426d2a ("ima: added support for new kernel cmdline parameter
ima_template_fmt") introduced an additional check on the ima_template
variable to avoid multiple template selection.

Unfortunately, ima_template could be also set by the setup function of the
ima_hash= parameter, when it calls ima_template_desc_current(). This causes
attempts to choose a new template with ima_template= or with
ima_template_fmt=, after ima_hash=, to be ignored.

Achieve the goal of the commit mentioned with the new static variable
template_setup_done, so that template selection requests after ima_hash=
are not ignored.

Finally, call ima_init_template_list(), if not already done, to initialize
the list of templates before lookup_template_desc() is called.
Reported-by: NGuo Zihua <guozihua@huawei.com>
Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
Cc: stable@vger.kernel.org
Fixes: c2426d2a ("ima: added support for new kernel cmdline parameter ima_template_fmt")
Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 267986ec
...@@ -27,6 +27,7 @@ static struct ima_template_desc builtin_templates[] = { ...@@ -27,6 +27,7 @@ static struct ima_template_desc builtin_templates[] = {
static LIST_HEAD(defined_templates); static LIST_HEAD(defined_templates);
static DEFINE_SPINLOCK(template_list); static DEFINE_SPINLOCK(template_list);
static int template_setup_done;
static const struct ima_template_field supported_fields[] = { static const struct ima_template_field supported_fields[] = {
{.field_id = "d", .field_init = ima_eventdigest_init, {.field_id = "d", .field_init = ima_eventdigest_init,
...@@ -82,10 +83,11 @@ static int __init ima_template_setup(char *str) ...@@ -82,10 +83,11 @@ static int __init ima_template_setup(char *str)
struct ima_template_desc *template_desc; struct ima_template_desc *template_desc;
int template_len = strlen(str); int template_len = strlen(str);
if (ima_template) if (template_setup_done)
return 1; return 1;
ima_init_template_list(); if (!ima_template)
ima_init_template_list();
/* /*
* Verify that a template with the supplied name exists. * Verify that a template with the supplied name exists.
...@@ -109,6 +111,7 @@ static int __init ima_template_setup(char *str) ...@@ -109,6 +111,7 @@ static int __init ima_template_setup(char *str)
} }
ima_template = template_desc; ima_template = template_desc;
template_setup_done = 1;
return 1; return 1;
} }
__setup("ima_template=", ima_template_setup); __setup("ima_template=", ima_template_setup);
...@@ -117,7 +120,7 @@ static int __init ima_template_fmt_setup(char *str) ...@@ -117,7 +120,7 @@ static int __init ima_template_fmt_setup(char *str)
{ {
int num_templates = ARRAY_SIZE(builtin_templates); int num_templates = ARRAY_SIZE(builtin_templates);
if (ima_template) if (template_setup_done)
return 1; return 1;
if (template_desc_init_fields(str, NULL, NULL) < 0) { if (template_desc_init_fields(str, NULL, NULL) < 0) {
...@@ -128,6 +131,7 @@ static int __init ima_template_fmt_setup(char *str) ...@@ -128,6 +131,7 @@ static int __init ima_template_fmt_setup(char *str)
builtin_templates[num_templates - 1].fmt = str; builtin_templates[num_templates - 1].fmt = str;
ima_template = builtin_templates + num_templates - 1; ima_template = builtin_templates + num_templates - 1;
template_setup_done = 1;
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册