1 Star 0 Fork 10

jinlun/dim_9

forked from src-openEuler/dim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-add-parameter-check.patch 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
From 363b0761d007fa20e165f385a085a2fcf6fc11a0 Mon Sep 17 00:00:00 2001
From: jinlun <jinlun@huawei.com>
Date: Tue, 18 Jun 2024 09:45:47 +0800
Subject: [PATCH 13/14] add parameter check
---
src/common/dim_measure_log.c | 3 +++
src/core/tasks/dim_core_measure_kernel.c | 6 +++---
src/core/tasks/dim_core_measure_module.c | 6 ++++--
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/common/dim_measure_log.c b/src/common/dim_measure_log.c
index 4b3bd34..59654a5 100644
--- a/src/common/dim_measure_log.c
+++ b/src/common/dim_measure_log.c
@@ -33,6 +33,9 @@ static int cal_measure_log_digest(const char *name,
int digest_size = dim_digest_size(info->digest.algo);
SHASH_DESC_ON_STACK(shash, hash->tfm);
+ if (algo_name == NULL)
+ return -EINVAL;
+
shash->tfm = hash->tfm;
ret = crypto_shash_init(shash);
if (ret < 0)
diff --git a/src/core/tasks/dim_core_measure_kernel.c b/src/core/tasks/dim_core_measure_kernel.c
index fa04ae4..bb7fd74 100644
--- a/src/core/tasks/dim_core_measure_kernel.c
+++ b/src/core/tasks/dim_core_measure_kernel.c
@@ -139,13 +139,13 @@ static int kernel_text_measure(int mode, struct dim_measure *m)
{
int ret = 0;
const char *kr = init_uts_ns.name.release;
- struct dim_digest digest = {
- .algo = m->hash.algo,
- };
+ struct dim_digest digest = {0};
if (m == NULL)
return -EINVAL;
+ digest.algo = m->hash.algo;
+
if (!dim_core_policy_match(DIM_POLICY_OBJ_KERNEL_TEXT,
DIM_POLICY_KEY_NAME, kr))
return 0;
diff --git a/src/core/tasks/dim_core_measure_module.c b/src/core/tasks/dim_core_measure_module.c
index feb6624..613e0e5 100644
--- a/src/core/tasks/dim_core_measure_module.c
+++ b/src/core/tasks/dim_core_measure_module.c
@@ -64,13 +64,15 @@ static int measure_module(struct dim_policy *policy, void *data)
{
int ret = 0;
struct module_text_measure_ctx *ctx = data;
- const char *mod_name = policy->name;
+ const char *mod_name = NULL;
struct dim_digest digest = { 0 };
if (policy == NULL || policy->obj != DIM_POLICY_OBJ_MODULE_TEXT ||
- mod_name == NULL)
+ policy->name == NULL)
return 0;
+ mod_name = policy->name;
+
/* if module is not inserted in baseline_init stage, ignore it */
if (ctx->mode == DIM_MEASURE &&
dim_measure_dynamic_baseline_search(ctx->m, mod_name,
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinlun123123/dim_9.git
git@gitee.com:jinlun123123/dim_9.git
jinlun123123
dim_9
dim_9
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385