Thread (5 messages) flat view 5 messages, 3 authors, 2018-09-27

Re: powerpc/tm: Avoid possible userspace r1 corruption on reclaim

From: Michael Ellerman <hidden>
Date: 2018-09-26 12:13:11

On Tue, 2018-09-25 at 09:36:47 UTC, Michael Neuling wrote:
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 <redacted>
Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/96dc89d526ef77604376f06220e3d2

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help