]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/tm: Fix illegal TM state in signal handler
authorGustavo Romero <gromero@linux.vnet.ibm.com>
Tue, 22 Aug 2017 21:20:09 +0000 (17:20 -0400)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 6 Oct 2017 11:12:55 +0000 (22:12 +1100)
commit238db83e8b05da67a5da22638cb488d34b5cf42c
tree69c06d82fa7a2313c8a076f8910b61236177aa79
parentef2cc677d4f7950710fbd954dc9b5f1819e06308
powerpc/tm: Fix illegal TM state in signal handler

Currently it's possible that on returning from the signal handler
through the restore_tm_sigcontexts() code path (e.g. from a signal
caught due to a `trap` instruction executed in the middle of an HTM
block, or a deliberately constructed sigframe) an illegal TM state
(like TS=10 TM=0, i.e. "T0") is set in SRR1 and when `rfid` sets
implicitly the MSR register from SRR1 register on return to userspace
it causes a TM Bad Thing exception.

That illegal state can be set (a) by a malicious user that disables
the TM bit by tweaking the bits in uc_mcontext before returning from
the signal handler or (b) by a sufficient number of context switches
occurring such that the load_tm counter overflows and TM is disabled
whilst in the signal handler.

This commit fixes the illegal TM state by ensuring that TM bit is
always enabled before we return from restore_tm_sigcontexts(). A small
comment correction is made as well.

Fixes: b6b262266098 ("powerpc: tm: Enable transactional memory (TM) lazily for userspace")
Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/signal_64.c