linux-stable/arch/powerpc
Kamalesh Babulal e36a82ee4c powerpc/livepatch: Fix livepatch stack access
While running stress test with livepatch module loaded, kernel bug was
triggered.

  cpu 0x5: Vector: 400 (Instruction Access) at [c0000000eb9d3b60]
  5:mon> t
  [c0000000eb9d3de0] c0000000eb9d3e30 (unreliable)
  [c0000000eb9d3e30] c000000000008ab4 hardware_interrupt_common+0x114/0x120
   --- Exception: 501 (Hardware Interrupt) at c000000000053040 livepatch_handler+0x4c/0x74
  [c0000000eb9d4120] 0000000057ac6e9d (unreliable)
  [d0000000089d9f78] 2e0965747962382e
  SP (965747962342e09) is in userspace

When an interrupt occurs during the livepatch_handler execution, it's
possible for the livepatch_stack and/or thread_info to be corrupted.
eg:

  Task A                        Interrupt Handler
  =========                     =================
  livepatch_handler:
  mr r0, r1
  ld r1, TI_livepatch_sp(r12)
                                hardware_interrupt_common:
                                  do_IRQ+0x8:
                                    mflr    r0          <- saved stack pointer is overwritten
                                    bl      _mcount
                                    ...
                                    std     r27,-40(r1) <- overwrite of thread_info()

  lis r2, STACK_END_MAGIC@h
  ori r2, r2, STACK_END_MAGIC@l
  ld  r12, -8(r1)

Fix the corruption by using r11 register for livepatch stack
manipulation, instead of shuffling task stack and livepatch stack into
r1 register. Using r11 register also avoids disabling/enabling irq's
while setting up the livepatch stack.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-10-10 15:27:42 +11:00
..
boot powerpc: conditionally compile platform-specific serial drivers 2017-08-31 14:26:48 +10:00
configs powerpc/configs: Update for CONFIG_SND changes 2017-09-20 13:30:09 +10:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2017-05-02 15:53:46 -07:00
include Merge branch 'akpm' (patches from Andrew) 2017-09-09 10:30:07 -07:00
kernel powerpc/livepatch: Fix livepatch stack access 2017-10-10 15:27:42 +11:00
kvm kvm,powerpc: Serialize wq active checks in ops->vcpu_kick 2017-09-15 16:57:13 +02:00
lib powerpc/sstep: mullw should calculate a 64 bit signed result 2017-09-20 13:30:09 +10:00
math-emu Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
mm powerpc/mm: Call flush_tlb_kernel_range with interrupts enabled 2017-10-04 22:15:30 +11:00
net powerpc updates for 4.14 2017-09-07 10:15:40 -07:00
oprofile ktime: Cleanup ktime_set() usage 2016-12-25 17:21:22 +01:00
perf powerpc/sysrq: Fix oops whem ppmu is not registered 2017-09-20 13:30:09 +10:00
platforms powerpc/powernv: Increase memory block size to 1GB on radix 2017-10-06 15:50:45 +11:00
purgatory powerpc/asm: Convert .llong directives to .8byte 2017-08-31 14:26:47 +10:00
sysdev powerpc/xive: Clear XIVE internal structures when a CPU is removed 2017-10-04 22:01:57 +11:00
tools powerpc/64: Tool to check head sections location sanity 2017-05-30 14:59:51 +10:00
xmon powerpc/xmon: Add ISA v3.0 SPRs to SPR dump 2017-08-31 14:26:45 +10:00
Kconfig powerpc updates for 4.14 2017-09-07 10:15:40 -07:00
Kconfig.debug powerpc/xmon: Enable disassembly files (compilation changes) 2017-02-15 20:02:42 +11:00
Makefile Merge branch 'fixes' into next 2017-08-23 22:20:10 +10:00
Makefile.postlink powerpc/64: Tool to check head sections location sanity 2017-05-30 14:59:51 +10:00