Skip to content

Commit 81f755d

Browse files
Brian GerstPeter Zijlstra
authored andcommitted
x86/32: Remove schedule_tail_wrapper()
The unwinder expects a return address at the very top of the kernel stack just below pt_regs and before any stack frame is created. Instead of calling a wrapper, set up a return address as if ret_from_fork() was called from the syscall entry code. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Link: https://lkml.kernel.org/r/20230623225529.34590-2-brgerst@gmail.com
1 parent 9831c62 commit 81f755d

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

arch/x86/entry/entry_32.S

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -719,26 +719,6 @@ SYM_CODE_START(__switch_to_asm)
719719
SYM_CODE_END(__switch_to_asm)
720720
.popsection
721721

722-
/*
723-
* The unwinder expects the last frame on the stack to always be at the same
724-
* offset from the end of the page, which allows it to validate the stack.
725-
* Calling schedule_tail() directly would break that convention because its an
726-
* asmlinkage function so its argument has to be pushed on the stack. This
727-
* wrapper creates a proper "end of stack" frame header before the call.
728-
*/
729-
.pushsection .text, "ax"
730-
SYM_FUNC_START(schedule_tail_wrapper)
731-
FRAME_BEGIN
732-
733-
pushl %eax
734-
call schedule_tail
735-
popl %eax
736-
737-
FRAME_END
738-
RET
739-
SYM_FUNC_END(schedule_tail_wrapper)
740-
.popsection
741-
742722
/*
743723
* A newly forked process directly context switches into this address.
744724
*
@@ -748,16 +728,23 @@ SYM_FUNC_END(schedule_tail_wrapper)
748728
*/
749729
.pushsection .text, "ax"
750730
SYM_CODE_START(ret_from_fork)
751-
call schedule_tail_wrapper
731+
/* return address for the stack unwinder */
732+
pushl $.Lsyscall_32_done
733+
734+
FRAME_BEGIN
735+
pushl %eax
736+
call schedule_tail
737+
addl $4, %esp
738+
FRAME_END
752739

753740
testl %ebx, %ebx
754741
jnz 1f /* kernel threads are uncommon */
755742

756743
2:
757744
/* When we fork, we trace the syscall return in the child, too. */
758-
movl %esp, %eax
745+
leal 4(%esp), %eax
759746
call syscall_exit_to_user_mode
760-
jmp .Lsyscall_32_done
747+
RET
761748

762749
/* kernel thread */
763750
1: movl %edi, %eax

0 commit comments

Comments
 (0)