加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-calculating-ELF-memory-address.patch 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
From 6c1a35ac10351a2b2d4d66899f5848c1201ca6fc Mon Sep 17 00:00:00 2001
From: Huaxin Lu <luhuaxin1@huawei.com>
Date: Mon, 29 Apr 2024 21:55:45 +0800
Subject: [PATCH 01/28] Fix calculating ELF memory address
---
.../dim_core_measure_process_elf.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/core/tasks/dim_core_measure_process/dim_core_measure_process_elf.c b/src/core/tasks/dim_core_measure_process/dim_core_measure_process_elf.c
index 3821c7f..76d1560 100644
--- a/src/core/tasks/dim_core_measure_process/dim_core_measure_process_elf.c
+++ b/src/core/tasks/dim_core_measure_process/dim_core_measure_process_elf.c
@@ -266,6 +266,7 @@ static int measure_elf_text(struct vm_area_struct *vma,
int ret = 0;
unsigned int i = 0;
unsigned long addr = 0;
+ unsigned long base = 0;
struct elf_phdr *phdr = NULL;
struct dim_digest digest = {
.algo = ctx->m->hash.algo,
@@ -276,10 +277,12 @@ static int measure_elf_text(struct vm_area_struct *vma,
ret = crypto_shash_init(shash);
if (ret < 0)
return ret;
-
+
+ base = vma->vm_start - phdrs_text[0].p_vaddr;
+
for (; i < phdrs_text_num; i++) {
phdr = &phdrs_text[i];
- addr = vma->vm_start + phdr->p_vaddr - vma->vm_pgoff * PAGE_SIZE;
+ addr = base + phdr->p_vaddr;
ret = dim_vm_hash_update_address(vma->vm_mm, addr,
phdr->p_memsz, shash);
if (ret < 0)
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化