提交 bc9968af 编写于 作者: J Josh Poimboeuf 提交者: Zheng Zengkai

x86/xen: Support objtool validation in xen-asm.S

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

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

commit cde07a4e upstream.

The OBJECT_FILES_NON_STANDARD annotation is used to tell objtool to
ignore a file.  File-level ignores won't work when validating vmlinux.o.

Tweak the ELF metadata and unwind hints to allow objtool to follow the
code.

Cc: Juergen Gross <jgross@suse.com>
Reviewed-by: NBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/8b042a09c69e8645f3b133ef6653ba28f896807d.1611263462.git.jpoimboe@redhat.comSigned-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>
上级 12024efc
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
OBJECT_FILES_NON_STANDARD_xen-asm.o := y
ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FUNCTION_TRACER
# Do not profile debug and lowlevel utilities # Do not profile debug and lowlevel utilities
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/asm.h> #include <asm/asm.h>
#include <asm/frame.h> #include <asm/frame.h>
#include <asm/unwind_hints.h>
#include <xen/interface/xen.h> #include <xen/interface/xen.h>
...@@ -147,6 +148,7 @@ SYM_FUNC_END(xen_read_cr2_direct); ...@@ -147,6 +148,7 @@ SYM_FUNC_END(xen_read_cr2_direct);
.macro xen_pv_trap name .macro xen_pv_trap name
SYM_CODE_START(xen_\name) SYM_CODE_START(xen_\name)
UNWIND_HINT_EMPTY
pop %rcx pop %rcx
pop %r11 pop %r11
jmp \name jmp \name
...@@ -186,6 +188,7 @@ xen_pv_trap asm_exc_xen_hypervisor_callback ...@@ -186,6 +188,7 @@ xen_pv_trap asm_exc_xen_hypervisor_callback
SYM_CODE_START(xen_early_idt_handler_array) SYM_CODE_START(xen_early_idt_handler_array)
i = 0 i = 0
.rept NUM_EXCEPTION_VECTORS .rept NUM_EXCEPTION_VECTORS
UNWIND_HINT_EMPTY
pop %rcx pop %rcx
pop %r11 pop %r11
jmp early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE jmp early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE
...@@ -212,11 +215,13 @@ hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32 ...@@ -212,11 +215,13 @@ hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
* rsp->rax } * rsp->rax }
*/ */
SYM_CODE_START(xen_iret) SYM_CODE_START(xen_iret)
UNWIND_HINT_EMPTY
pushq $0 pushq $0
jmp hypercall_iret jmp hypercall_iret
SYM_CODE_END(xen_iret) SYM_CODE_END(xen_iret)
SYM_CODE_START(xen_sysret64) SYM_CODE_START(xen_sysret64)
UNWIND_HINT_EMPTY
/* /*
* We're already on the usermode stack at this point, but * We're already on the usermode stack at this point, but
* still with the kernel gs, so we can easily switch back. * still with the kernel gs, so we can easily switch back.
...@@ -271,7 +276,8 @@ SYM_CODE_END(xenpv_restore_regs_and_return_to_usermode) ...@@ -271,7 +276,8 @@ SYM_CODE_END(xenpv_restore_regs_and_return_to_usermode)
*/ */
/* Normal 64-bit system call target */ /* Normal 64-bit system call target */
SYM_FUNC_START(xen_syscall_target) SYM_CODE_START(xen_syscall_target)
UNWIND_HINT_EMPTY
popq %rcx popq %rcx
popq %r11 popq %r11
...@@ -284,12 +290,13 @@ SYM_FUNC_START(xen_syscall_target) ...@@ -284,12 +290,13 @@ SYM_FUNC_START(xen_syscall_target)
movq $__USER_CS, 1*8(%rsp) movq $__USER_CS, 1*8(%rsp)
jmp entry_SYSCALL_64_after_hwframe jmp entry_SYSCALL_64_after_hwframe
SYM_FUNC_END(xen_syscall_target) SYM_CODE_END(xen_syscall_target)
#ifdef CONFIG_IA32_EMULATION #ifdef CONFIG_IA32_EMULATION
/* 32-bit compat syscall target */ /* 32-bit compat syscall target */
SYM_FUNC_START(xen_syscall32_target) SYM_CODE_START(xen_syscall32_target)
UNWIND_HINT_EMPTY
popq %rcx popq %rcx
popq %r11 popq %r11
...@@ -302,10 +309,11 @@ SYM_FUNC_START(xen_syscall32_target) ...@@ -302,10 +309,11 @@ SYM_FUNC_START(xen_syscall32_target)
movq $__USER32_CS, 1*8(%rsp) movq $__USER32_CS, 1*8(%rsp)
jmp entry_SYSCALL_compat_after_hwframe jmp entry_SYSCALL_compat_after_hwframe
SYM_FUNC_END(xen_syscall32_target) SYM_CODE_END(xen_syscall32_target)
/* 32-bit compat sysenter target */ /* 32-bit compat sysenter target */
SYM_FUNC_START(xen_sysenter_target) SYM_CODE_START(xen_sysenter_target)
UNWIND_HINT_EMPTY
/* /*
* NB: Xen is polite and clears TF from EFLAGS for us. This means * NB: Xen is polite and clears TF from EFLAGS for us. This means
* that we don't need to guard against single step exceptions here. * that we don't need to guard against single step exceptions here.
...@@ -322,17 +330,18 @@ SYM_FUNC_START(xen_sysenter_target) ...@@ -322,17 +330,18 @@ SYM_FUNC_START(xen_sysenter_target)
movq $__USER32_CS, 1*8(%rsp) movq $__USER32_CS, 1*8(%rsp)
jmp entry_SYSENTER_compat_after_hwframe jmp entry_SYSENTER_compat_after_hwframe
SYM_FUNC_END(xen_sysenter_target) SYM_CODE_END(xen_sysenter_target)
#else /* !CONFIG_IA32_EMULATION */ #else /* !CONFIG_IA32_EMULATION */
SYM_FUNC_START_ALIAS(xen_syscall32_target) SYM_CODE_START(xen_syscall32_target)
SYM_FUNC_START(xen_sysenter_target) SYM_CODE_START(xen_sysenter_target)
UNWIND_HINT_EMPTY
lea 16(%rsp), %rsp /* strip %rcx, %r11 */ lea 16(%rsp), %rsp /* strip %rcx, %r11 */
mov $-ENOSYS, %rax mov $-ENOSYS, %rax
pushq $0 pushq $0
jmp hypercall_iret jmp hypercall_iret
SYM_FUNC_END(xen_sysenter_target) SYM_CODE_END(xen_sysenter_target)
SYM_FUNC_END_ALIAS(xen_syscall32_target) SYM_CODE_END(xen_syscall32_target)
#endif /* CONFIG_IA32_EMULATION */ #endif /* CONFIG_IA32_EMULATION */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册