Commit d3826ffe authored by Xiang Yang's avatar Xiang Yang Committed by sanglipeng1
Browse files

Revert "arm64: Stash shadow stack pointer in the task struct on interrupt"

stable inclusion
from stable-v5.10.210
commit f7e0231eeaa33245c649fac0303cf97209605446
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAE52H

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f7e0231eeaa33245c649fac0303cf97209605446



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

This reverts commit 3f225f29c69c13ce1cbdb1d607a42efeef080056 which is
commit 59b37fe5 upstream.

The shadow call stack for irq now is stored in current task's thread info
in irq_stack_entry. There is a possibility that we have some soft irqs
pending at the end of hard irq, and when we process softirq with the irq
enabled, irq_stack_entry will enter again and overwrite the shadow call
stack whitch stored in current task's thread info, leading to the
incorrect shadow call stack restoration for the first entry of the hard
IRQ, then the system end up with a panic.

task A                               |  task A
-------------------------------------+------------------------------------
el1_irq        //irq1 enter          |
  irq_handler  //save scs_sp1        |
    gic_handle_irq                   |
    irq_exit                         |
      __do_softirq                   |
                                     | el1_irq         //irq2 enter
                                     |   irq_handler   //save scs_sp2
                                     |                 //overwrite scs_sp1
                                     |   ...
                                     |   irq_stack_exit //restore scs_sp2
  irq_stack_exit //restore wrong     |
                 //scs_sp2           |

So revert this commit to fix it.

Fixes: 3f225f29c69c ("arm64: Stash shadow stack pointer in the task struct on interrupt")
Signed-off-by: default avatarXiang Yang <xiangyang3@huawei.com>
Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent ebabeaf1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -423,7 +423,9 @@ SYM_CODE_END(__swpan_exit_el0)

	.macro	irq_stack_entry
	mov	x19, sp			// preserve the original sp
	scs_save tsk			// preserve the original shadow stack
#ifdef CONFIG_SHADOW_CALL_STACK
	mov	x24, scs_sp		// preserve the original shadow stack
#endif

	/*
	 * Compare sp with the base of the task stack.
@@ -457,7 +459,9 @@ SYM_CODE_END(__swpan_exit_el0)
	 */
	.macro	irq_stack_exit
	mov	sp, x19
	scs_load_current
#ifdef CONFIG_SHADOW_CALL_STACK
	mov	scs_sp, x24
#endif
	.endm

/* GPRs used by entry code */