]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.35/powerpc-tm-limit-tm-code-inside-ppc_transactional_me.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / powerpc-tm-limit-tm-code-inside-ppc_transactional_me.patch
CommitLineData
f7c394c2
SL
1From feca8e36e9f135abdeab5c69bb3a20824d17ec22 Mon Sep 17 00:00:00 2001
2From: Breno Leitao <leitao@debian.org>
3Date: Mon, 8 Apr 2019 16:32:38 +1000
4Subject: powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM
5
6commit 897bc3df8c5aebb54c32d831f917592e873d0559 upstream.
7
8Commit e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint")
9moved a code block around and this block uses a 'msr' variable outside of
10the CONFIG_PPC_TRANSACTIONAL_MEM, however the 'msr' variable is declared
11inside a CONFIG_PPC_TRANSACTIONAL_MEM block, causing a possible error when
12CONFIG_PPC_TRANSACTION_MEM is not defined.
13
14 error: 'msr' undeclared (first use in this function)
15
16This is not causing a compilation error in the mainline kernel, because
17'msr' is being used as an argument of MSR_TM_ACTIVE(), which is defined as
18the following when CONFIG_PPC_TRANSACTIONAL_MEM is *not* set:
19
20 #define MSR_TM_ACTIVE(x) 0
21
22This patch just fixes this issue avoiding the 'msr' variable usage outside
23the CONFIG_PPC_TRANSACTIONAL_MEM block, avoiding trusting in the
24MSR_TM_ACTIVE() definition.
25
26Cc: stable@vger.kernel.org
27Reported-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
28Fixes: e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint")
29Signed-off-by: Breno Leitao <leitao@debian.org>
30Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
31Signed-off-by: Michael Neuling <mikey@neuling.org>
32Signed-off-by: Sasha Levin <sashal@kernel.org>
33---
34 arch/powerpc/kernel/signal_64.c | 23 ++++++++++++++++++-----
35 1 file changed, 18 insertions(+), 5 deletions(-)
36
37diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
38index bbd1c73243d7..14b0f5b6a373 100644
39--- a/arch/powerpc/kernel/signal_64.c
40+++ b/arch/powerpc/kernel/signal_64.c
41@@ -755,12 +755,25 @@ SYSCALL_DEFINE0(rt_sigreturn)
42 if (restore_tm_sigcontexts(current, &uc->uc_mcontext,
43 &uc_transact->uc_mcontext))
44 goto badframe;
45- }
46- else
47- /* Fall through, for non-TM restore */
48+ } else
49 #endif
50- if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext))
51- goto badframe;
52+ {
53+ /*
54+ * Fall through, for non-TM restore
55+ *
56+ * Unset MSR[TS] on the thread regs since MSR from user
57+ * context does not have MSR active, and recheckpoint was
58+ * not called since restore_tm_sigcontexts() was not called
59+ * also.
60+ *
61+ * If not unsetting it, the code can RFID to userspace with
62+ * MSR[TS] set, but without CPU in the proper state,
63+ * causing a TM bad thing.
64+ */
65+ current->thread.regs->msr &= ~MSR_TS_MASK;
66+ if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext))
67+ goto badframe;
68+ }
69
70 if (restore_altstack(&uc->uc_stack))
71 goto badframe;
72--
732.19.1
74