]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
powerpc/32s: Fix kuap_kernel_restore()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 15 Sep 2021 14:12:24 +0000 (16:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Oct 2021 07:42:03 +0000 (09:42 +0200)
commitda0cb12f19838eec245d135b6d59f3fcfe1fa7d0
tree51b49f8725419926fd0ae37d7e8dcc9ac9b72789
parentd7a8e38999fbd6910516e44cb43f9f4317e54f73
powerpc/32s: Fix kuap_kernel_restore()

[ Upstream commit d93f9e23744b7bf11a98b2ddb091d129482ae179 ]

At interrupt exit, kuap_kernel_restore() calls kuap_unlock() with the
value contained in regs->kuap. However, when regs->kuap contains
0xffffffff it means that KUAP was not unlocked so calling kuap_unlock()
is unrelevant and results in jeopardising the contents of kernel space
segment registers.

So check that regs->kuap doesn't contain KUAP_NONE before calling
kuap_unlock(). In the meantime it also means that if KUAP has not
been correcly locked back at interrupt exit, it must be locked
before continuing. This is done by checking the content of
current->thread.kuap which was returned by kuap_get_and_assert_locked()

Fixes: 16132529cee5 ("powerpc/32s: Rework Kernel Userspace Access Protection")
Reported-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0d0c4d0f050a637052287c09ba521bad960a2790.1631715131.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/include/asm/book3s/32/kup.h