提交 a3909e7e 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

objtool: Skip magical retpoline .altinstr_replacement

stable inclusion
from stable-v5.10.133
commit ed7783dca5baff4103c214214abf0a3aeb27a79f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5PTAS
CVE: CVE-2022-29900,CVE-2022-23816,CVE-2022-29901

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

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

commit 50e7b4a1 upstream.

When the .altinstr_replacement is a retpoline, skip the alternative.
We already special case retpolines anyway.
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Signed-off-by: NIngo Molnar <mingo@kernel.org>
Reviewed-by: NMiroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/20210326151300.259429287@infradead.orgSigned-off-by: NBen Hutchings <ben@decadent.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NLin Yujun <linyujun809@huawei.com>
Reviewed-by: NZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 03ab0922
...@@ -104,6 +104,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, ...@@ -104,6 +104,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
return -1; return -1;
} }
/*
* Skip retpoline .altinstr_replacement... we already rewrite the
* instructions for retpolines anyway, see arch_is_retpoline()
* usage in add_{call,jump}_destinations().
*/
if (arch_is_retpoline(new_reloc->sym))
return 1;
alt->new_sec = new_reloc->sym->sec; alt->new_sec = new_reloc->sym->sec;
alt->new_off = (unsigned int)new_reloc->addend; alt->new_off = (unsigned int)new_reloc->addend;
...@@ -152,7 +160,9 @@ int special_get_alts(struct elf *elf, struct list_head *alts) ...@@ -152,7 +160,9 @@ int special_get_alts(struct elf *elf, struct list_head *alts)
memset(alt, 0, sizeof(*alt)); memset(alt, 0, sizeof(*alt));
ret = get_alt_entry(elf, entry, sec, idx, alt); ret = get_alt_entry(elf, entry, sec, idx, alt);
if (ret) if (ret > 0)
continue;
if (ret < 0)
return ret; return ret;
list_add_tail(&alt->list, alts); list_add_tail(&alt->list, alts);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册