]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - arch/powerpc/kernel/exceptions-64s.S
UBUNTU: SAUCE: powerpc/64s: Use emergency stack for kernel TM Bad Thing program checks
authorCyril Bur <cyrilbur@gmail.com>
Thu, 17 Aug 2017 10:42:26 +0000 (20:42 +1000)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 6 Oct 2017 19:42:40 +0000 (16:42 -0300)
commit8b1a7b0607a840e73e9b6fd15cc01d800742fe43
tree00ce14dde92eec2e6db20a7f6d4b5ec14338cdd8
parentd0085de3bf52b7b5f79164b89939ba44fcd239f3
UBUNTU: SAUCE: powerpc/64s: Use emergency stack for kernel TM Bad Thing program checks

When using transactional memory (TM), the CPU can be in one of six
states as far as TM is concerned, encoded in the Machine State
Register (MSR). Certain state transitions are illegal and if attempted
trigger a "TM Bad Thing" type program check exception.

If we ever hit one of these exceptions it's treated as a bug, ie. we
oops, and kill the process and/or panic, depending on configuration.

One case where we can trigger a TM Bad Thing, is when returning to
userspace after a system call or interrupt, using RFID. When this
happens the CPU first restores the user register state, in particular
r1 (the stack pointer) and then attempts to update the MSR. However
the MSR update is not allowed and so we take the program check with
the user register state, but the kernel MSR.

This tricks the exception entry code into thinking we have a bad
kernel stack pointer, because the MSR says we're coming from the
kernel, but r1 is pointing to userspace.

To avoid this we instead always switch to the emergency stack if we
take a TM Bad Thing from the kernel. That way none of the user
register values are used, other than for printing in the oops message.

Fixes: 5d176f751ee3 ("powerpc: tm: Enable transactional memory (TM) lazily for userspace")
Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
[mpe: Rewrite change log & comments, tweak asm slightly]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
CVE-2017-1000255
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
arch/powerpc/kernel/exceptions-64s.S