Skip to content

Commit 3bf19a0

Browse files
Zheng Yejianjpoimboe
authored andcommitted
x86/unwind/orc: Fix unwind for newly forked tasks
When arch_stack_walk_reliable() is called to unwind for newly forked tasks, the return value is negative which means the call stack is unreliable. This obviously does not meet expectations. The root cause is that after commit 3aec4ec ("x86: Rewrite ret_from_fork() in C"), the 'ret_addr' of newly forked task is changed to 'ret_from_fork_asm' (see copy_thread()), then at the start of the unwind, it is incorrectly interprets not as a "signal" one because 'ret_from_fork' is still used to determine the initial "signal" (see __unwind_start()). Then the address gets incorrectly decremented in the call to orc_find() (see unwind_next_frame()) and resulting in the incorrect ORC data. To fix it, check 'ret_from_fork_asm' rather than 'ret_from_fork' in __unwind_start(). Fixes: 3aec4ec ("x86: Rewrite ret_from_fork() in C") Signed-off-by: Zheng Yejian <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]>
1 parent 32b5048 commit 3bf19a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/unwind_orc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
723723
state->sp = task->thread.sp + sizeof(*frame);
724724
state->bp = READ_ONCE_NOCHECK(frame->bp);
725725
state->ip = READ_ONCE_NOCHECK(frame->ret_addr);
726-
state->signal = (void *)state->ip == ret_from_fork;
726+
state->signal = (void *)state->ip == ret_from_fork_asm;
727727
}
728728

729729
if (get_stack_info((unsigned long *)state->sp, state->task,

0 commit comments

Comments
 (0)