提交 b2582aac 编写于 作者: R Roberto Sassu 提交者: Zheng Zengkai

ima: Execute parser to upload digest lists not recognizable by the kernel

hulk inclusion
category: feature
feature: IMA Digest Lists extension
bugzilla: 46797

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

This patch limits the digest lists processed by the kernel by excluding
those that are not in the compact format. The patch then executes the
user space parsers to process the skipped digest lists.
Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
Acked-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 9835140e
...@@ -352,3 +352,10 @@ config IMA_DIGEST_LISTS_DIR ...@@ -352,3 +352,10 @@ config IMA_DIGEST_LISTS_DIR
help help
This option defines the path of the directory containing digest This option defines the path of the directory containing digest
lists. lists.
config IMA_PARSER_BINARY_PATH
string "Path of the parser binary"
depends on IMA_DIGEST_LIST
default "/usr/bin/upload_digest_lists"
help
This option defines the path of the parser binary.
...@@ -274,6 +274,7 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name, ...@@ -274,6 +274,7 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name,
struct dentry *dentry; struct dentry *dentry;
struct file *file; struct file *file;
u8 *xattr_value = NULL; u8 *xattr_value = NULL;
char *type_start, *format_start, *format_end;
void *datap = NULL; void *datap = NULL;
loff_t size; loff_t size;
int ret; int ret;
...@@ -281,6 +282,22 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name, ...@@ -281,6 +282,22 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name,
if (!strcmp(name, ".") || !strcmp(name, "..")) if (!strcmp(name, ".") || !strcmp(name, ".."))
return 0; return 0;
type_start = strchr(name, '-');
if (!type_start)
return 0;
format_start = strchr(type_start + 1, '-');
if (!format_start)
return 0;
format_end = strchr(format_start + 1, '-');
if (!format_end)
return 0;
if (format_end - format_start - 1 != strlen("compact") ||
strncmp(format_start + 1, "compact", format_end - format_start - 1))
return 0;
dentry = lookup_one_len(name, dir->dentry, strlen(name)); dentry = lookup_one_len(name, dir->dentry, strlen(name));
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return 0; return 0;
...@@ -322,6 +339,17 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name, ...@@ -322,6 +339,17 @@ static int __init load_digest_list(struct dir_context *__ctx, const char *name,
return 0; return 0;
} }
static void ima_exec_parser(void)
{
char *argv[4] = {NULL}, *envp[1] = {NULL};
argv[0] = (char *)CONFIG_IMA_PARSER_BINARY_PATH;
argv[1] = "add";
argv[2] = (char *)CONFIG_IMA_DIGEST_LISTS_DIR;
call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
}
void __init ima_load_digest_lists(void) void __init ima_load_digest_lists(void)
{ {
struct path path; struct path path;
...@@ -347,6 +375,8 @@ void __init ima_load_digest_lists(void) ...@@ -347,6 +375,8 @@ void __init ima_load_digest_lists(void)
fput(file); fput(file);
out: out:
path_put(&path); path_put(&path);
ima_exec_parser();
} }
/**************** /****************
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册