提交 17e07b09 编写于 作者: T Tong Tiangen 提交者: Zheng Zengkai

arm64/__mc_ex_table: fix __mc_ex_table do_sort() issue

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GB28
CVE: NA

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

If ARCH_HAS_MC_EXTABLE is not set then the _mc_ex_table is empty.

There is a logic error in do_sort(). _mc_ex_table is different from
_ex_table. _ex_table is always not empty, while _mc_ex_table may be empty.
If _mc_ex_table is empty, there is a issue with setting the initial value
of mc_extable_index to 0.

Fixes: 8bb071c9 ("arm64: extable: add new extable type "__mc_ex_table"")
Signed-off-by: NTong Tiangen <tongtiangen@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 3d25668e
......@@ -227,7 +227,6 @@ static int do_sort(Elf_Ehdr *ehdr,
Elf_Rel *mc_relocs = NULL;
int mc_relocs_size = 0;
char *mc_extab_image = NULL;
int mc_extab_index = 0;
shstrndx = r2(&ehdr->e_shstrndx);
if (shstrndx == SHN_XINDEX)
......@@ -245,11 +244,6 @@ static int do_sort(Elf_Ehdr *ehdr,
extab_index = i;
}
if (!strcmp(secstrings + idx, "__mc_ex_table")) {
mc_extab_sec = s;
mc_extab_index = i;
}
if (!strcmp(secstrings + idx, ".symtab"))
symtab_sec = s;
if (!strcmp(secstrings + idx, ".strtab"))
......@@ -262,11 +256,15 @@ static int do_sort(Elf_Ehdr *ehdr,
relocs_size = _r(&s->sh_size);
}
if ((r(&s->sh_type) == SHT_REL ||
r(&s->sh_type) == SHT_RELA) &&
r(&s->sh_info) == mc_extab_index) {
mc_relocs = (void *)ehdr + _r(&s->sh_offset);
mc_relocs_size = _r(&s->sh_size);
if (!strcmp(secstrings + idx, "__mc_ex_table")) {
mc_extab_sec = s;
if ((r(&s->sh_type) == SHT_REL ||
r(&s->sh_type) == SHT_RELA) &&
r(&s->sh_info) == i) {
mc_relocs = (void *)ehdr + _r(&s->sh_offset);
mc_relocs_size = _r(&s->sh_size);
}
}
if (r(&s->sh_type) == SHT_SYMTAB_SHNDX)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册