]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - 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
1 From feca8e36e9f135abdeab5c69bb3a20824d17ec22 Mon Sep 17 00:00:00 2001
2 From: Breno Leitao <leitao@debian.org>
3 Date: Mon, 8 Apr 2019 16:32:38 +1000
4 Subject: powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM
5
6 commit 897bc3df8c5aebb54c32d831f917592e873d0559 upstream.
7
8 Commit e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint")
9 moved a code block around and this block uses a 'msr' variable outside of
10 the CONFIG_PPC_TRANSACTIONAL_MEM, however the 'msr' variable is declared
11 inside a CONFIG_PPC_TRANSACTIONAL_MEM block, causing a possible error when
12 CONFIG_PPC_TRANSACTION_MEM is not defined.
13
14 error: 'msr' undeclared (first use in this function)
15
16 This 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
18 the following when CONFIG_PPC_TRANSACTIONAL_MEM is *not* set:
19
20 #define MSR_TM_ACTIVE(x) 0
21
22 This patch just fixes this issue avoiding the 'msr' variable usage outside
23 the CONFIG_PPC_TRANSACTIONAL_MEM block, avoiding trusting in the
24 MSR_TM_ACTIVE() definition.
25
26 Cc: stable@vger.kernel.org
27 Reported-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
28 Fixes: e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint")
29 Signed-off-by: Breno Leitao <leitao@debian.org>
30 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
31 Signed-off-by: Michael Neuling <mikey@neuling.org>
32 Signed-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
37 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
38 index 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 --
73 2.19.1
74