提交 ab40e2f8 编写于 作者: T Thadeu Lima de Souza Cascardo 提交者: Zheng Zengkai

objtool: skip non-text sections when adding return-thunk sites

stable inclusion
from stable-v5.10.133
commit 446eb6f08936e6f87bea9f35be05556a7211df9b
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=446eb6f08936e6f87bea9f35be05556a7211df9b

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

The .discard.text section is added in order to reserve BRK, with a
temporary function just so it can give it a size. This adds a relocation to
the return thunk, which objtool will add to the .return_sites section.
Linking will then fail as there are references to the .discard.text
section.

Do not add instructions from non-text sections to the list of return thunk
calls, avoiding the reference to .discard.text.
Signed-off-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: NJosh Poimboeuf <jpoimboe@kernel.org>
Signed-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>
上级 ff9aae87
...@@ -1089,7 +1089,9 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn) ...@@ -1089,7 +1089,9 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn)
insn->type = INSN_RETURN; insn->type = INSN_RETURN;
insn->retpoline_safe = true; insn->retpoline_safe = true;
list_add_tail(&insn->call_node, &file->return_thunk_list); /* Skip the non-text sections, specially .discard ones */
if (insn->sec->text)
list_add_tail(&insn->call_node, &file->return_thunk_list);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册