]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
powerpc/tm: Avoid possible userspace r1 corruption on reclaim
authorMichael Neuling <mikey@neuling.org>
Tue, 25 Sep 2018 09:36:47 +0000 (19:36 +1000)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:54:27 +0000 (19:54 -0600)
commit855e593547cf42d54de6df9d79e4158c1a37626e
tree801d85dfe6400c547a0273c77a20629fe640116f
parent72b71d06db2a7b521bcf1a3152a6874bc75443ea
powerpc/tm: Avoid possible userspace r1 corruption on reclaim

BugLink: https://bugs.launchpad.net/bugs/1836654
[ Upstream commit 96dc89d526ef77604376f06220e3d2931a0bfd58 ]

Current we store the userspace r1 to PACATMSCRATCH before finally
saving it to the thread struct.

In theory an exception could be taken here (like a machine check or
SLB miss) that could write PACATMSCRATCH and hence corrupt the
userspace r1. The SLB fault currently doesn't touch PACATMSCRATCH, but
others do.

We've never actually seen this happen but it's theoretically
possible. Either way, the code is fragile as it is.

This patch saves r1 to the kernel stack (which can't fault) before we
turn MSR[RI] back on. PACATMSCRATCH is still used but only with
MSR[RI] off. We then copy r1 from the kernel stack to the thread
struct once we have MSR[RI] back on.

Suggested-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/powerpc/kernel/tm.S