mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
Mark reported that the ORC unwinder incorrectly marks an unwind as reliable when the unwind terminates prematurely in the dark corners of return_to_handler() due to lack of information about the next frame. The problem is UNWIND_HINT_EMPTY is used in two different situations: 1) The end of the kernel stack unwind before hitting user entry, boot code, or fork entry 2) A blind spot in ORC coverage where the unwinder has to bail due to lack of information about the next frame The ORC unwinder has no way to tell the difference between the two. When it encounters an undefined stack state with 'end=1', it blindly marks the stack reliable, which can break the livepatch consistency model. Fix it by splitting UNWIND_HINT_EMPTY into UNWIND_HINT_UNDEFINED and UNWIND_HINT_END_OF_STACK. Reported-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/fd6212c8b450d3564b855e1cb48404d6277b4d9f.1677683419.git.jpoimboe@kernel.org
84 lines
1.8 KiB
C
84 lines
1.8 KiB
C
#ifndef _ASM_X86_UNWIND_HINTS_H
|
|
#define _ASM_X86_UNWIND_HINTS_H
|
|
|
|
#include <linux/objtool.h>
|
|
|
|
#include "orc_types.h"
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
.macro UNWIND_HINT_END_OF_STACK
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_END_OF_STACK
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_UNDEFINED
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_UNDEFINED
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_ENTRY
|
|
VALIDATE_UNRET_BEGIN
|
|
UNWIND_HINT_END_OF_STACK
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0 signal=1
|
|
.if \base == %rsp
|
|
.if \indirect
|
|
.set sp_reg, ORC_REG_SP_INDIRECT
|
|
.else
|
|
.set sp_reg, ORC_REG_SP
|
|
.endif
|
|
.elseif \base == %rbp
|
|
.set sp_reg, ORC_REG_BP
|
|
.elseif \base == %rdi
|
|
.set sp_reg, ORC_REG_DI
|
|
.elseif \base == %rdx
|
|
.set sp_reg, ORC_REG_DX
|
|
.elseif \base == %r10
|
|
.set sp_reg, ORC_REG_R10
|
|
.else
|
|
.error "UNWIND_HINT_REGS: bad base register"
|
|
.endif
|
|
|
|
.set sp_offset, \offset
|
|
|
|
.if \partial
|
|
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
|
|
.elseif \extra == 0
|
|
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
|
|
.set sp_offset, \offset + (16*8)
|
|
.else
|
|
.set type, UNWIND_HINT_TYPE_REGS
|
|
.endif
|
|
|
|
UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type signal=\signal
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_IRET_REGS base=%rsp offset=0 signal=1
|
|
UNWIND_HINT_REGS base=\base offset=\offset partial=1 signal=\signal
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_IRET_ENTRY base=%rsp offset=0 signal=1
|
|
VALIDATE_UNRET_BEGIN
|
|
UNWIND_HINT_IRET_REGS base=\base offset=\offset signal=\signal
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_FUNC
|
|
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_SAVE
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_SAVE
|
|
.endm
|
|
|
|
.macro UNWIND_HINT_RESTORE
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_RESTORE
|
|
.endm
|
|
|
|
#else
|
|
|
|
#define UNWIND_HINT_FUNC \
|
|
UNWIND_HINT(UNWIND_HINT_TYPE_FUNC, ORC_REG_SP, 8, 0)
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_X86_UNWIND_HINTS_H */
|